From fecc62f7d364d5ac8a63180965ff2b2f72c7764f Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 16 Jan 2026 12:22:05 +0100 Subject: [PATCH] fix(test): use getDbDateStr() in tests to fix timezone-dependent failures Replace UTC date strings (toISOString().split('T')[0]) with getDbDateStr() to match implementation behavior. Fixes 3 CalendarIntegrationService tests and 1 StartupService test that failed in non-UTC timezones. --- src/app/core/startup/startup.service.spec.ts | 3 ++- .../calendar-integration.service.spec.ts | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/core/startup/startup.service.spec.ts b/src/app/core/startup/startup.service.spec.ts index 6666a1d062..06e5e49960 100644 --- a/src/app/core/startup/startup.service.spec.ts +++ b/src/app/core/startup/startup.service.spec.ts @@ -19,6 +19,7 @@ import { LS } from '../persistence/storage-keys.const'; import { provideMockStore } from '@ngrx/store/testing'; import { selectSyncConfig } from '../../features/config/store/global-config.reducer'; import { selectEnabledIssueProviders } from '../../features/issue/store/issue-provider.selectors'; +import { getDbDateStr } from '../../util/get-db-date-str'; describe('StartupService', () => { let service: StartupService; @@ -210,7 +211,7 @@ describe('StartupService', () => { }); it('should not increment count if same day', () => { - const todayStr = new Date().toISOString().split('T')[0]; + const todayStr = getDbDateStr(); (localStorage.getItem as jasmine.Spy).and.callFake((key: string) => { if (key === LS.APP_START_COUNT) return '10'; if (key === LS.APP_START_COUNT_LAST_START_DAY) return todayStr; diff --git a/src/app/features/calendar-integration/calendar-integration.service.spec.ts b/src/app/features/calendar-integration/calendar-integration.service.spec.ts index 2d174434ac..d8ca3228f1 100644 --- a/src/app/features/calendar-integration/calendar-integration.service.spec.ts +++ b/src/app/features/calendar-integration/calendar-integration.service.spec.ts @@ -16,6 +16,7 @@ import { import { SnackService } from '../../core/snack/snack.service'; import { take } from 'rxjs/operators'; import { Subscription } from 'rxjs'; +import { getDbDateStr } from '../../util/get-db-date-str'; describe('CalendarIntegrationService', () => { let service: CalendarIntegrationService; @@ -728,7 +729,7 @@ END:VCALENDAR`; describe('constructor', () => { it('should load skipped events from localStorage on init', () => { const skippedIds = ['event-1', 'event-2']; - const today = new Date().toISOString().split('T')[0]; + const today = getDbDateStr(); localStorage.setItem( 'SUP_CALENDER_EVENTS_SKIPPED_TODAY', @@ -758,7 +759,7 @@ END:VCALENDAR`; it('should not load skipped events from different day', () => { const skippedIds = ['event-1', 'event-2']; - const yesterday = new Date(Date.now() - 86400000).toISOString().split('T')[0]; + const yesterday = getDbDateStr(Date.now() - 86400000); localStorage.setItem( 'SUP_CALENDER_EVENTS_SKIPPED_TODAY', @@ -787,7 +788,7 @@ END:VCALENDAR`; }); it('should handle invalid JSON in localStorage gracefully', () => { - const today = new Date().toISOString().split('T')[0]; + const today = getDbDateStr(); localStorage.setItem('SUP_CALENDER_EVENTS_SKIPPED_TODAY', 'invalid json'); localStorage.setItem('SUP_CALENDER_EVENTS_LAST_SKIP_DAY', today);