fix(tests): stats.test.ts topCategory test broken on Sundays — wrong Monday calculation

This commit is contained in:
saravanakumardb1 2026-03-01 16:37:07 -08:00
parent 3adab843cd
commit e0c7f24954
2 changed files with 4 additions and 1 deletions

View File

@ -3,3 +3,4 @@
# Platform Service (backend API for sync, auth, telemetry)
NEXT_PUBLIC_PLATFORM_SERVICE_URL=http://localhost:4003/api
NEXT_PUBLIC_PRODUCT_ID=chronomind

View File

@ -294,7 +294,9 @@ describe('computeWeeklySummary', () => {
it('identifies top category', () => {
const now = Date.now();
const weekStart = new Date(now);
weekStart.setDate(weekStart.getDate() - weekStart.getDay() + 1); // Monday
const day = weekStart.getDay(); // 0=Sun
const diff = day === 0 ? 6 : day - 1; // match getWeekStart logic
weekStart.setDate(weekStart.getDate() - diff); // Monday
weekStart.setHours(12, 0, 0, 0);
const timers = [