From b9ebe6bd0214f321f1a8b178c789931c8b7888c4 Mon Sep 17 00:00:00 2001 From: Alexander Brandon Coles Date: Wed, 13 May 2026 22:43:41 +0200 Subject: [PATCH] Fix timezone service spec in local timezones Mock the guessed timezone when the configuration has no explicit timezone so the UTC expectation is deterministic across developer environments. --- .../app/core/datetime/timezone.service.spec.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/core/datetime/timezone.service.spec.ts b/frontend/src/app/core/datetime/timezone.service.spec.ts index 1fe0ae270372..45ed4a8ca168 100644 --- a/frontend/src/app/core/datetime/timezone.service.spec.ts +++ b/frontend/src/app/core/datetime/timezone.service.spec.ts @@ -32,6 +32,7 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service import { I18nService } from 'core-app/core/i18n/i18n.service'; import { ConfigurationService } from 'core-app/core/config/configuration.service'; import { TimezoneService } from 'core-app/core/datetime/timezone.service'; +import moment from 'moment-timezone'; describe('TimezoneService', () => { const TIME = '2013-02-08T09:30:26'; @@ -44,20 +45,28 @@ describe('TimezoneService', () => { timezone: () => timezone, }; + if (!timezone) { + vi.spyOn(moment.tz, 'guess').mockReturnValue('Etc/UTC'); + } + TestBed.configureTestingModule({ - imports: [], - providers: [ + imports: [], + providers: [ { provide: I18nService, useValue: {} }, { provide: ConfigurationService, useValue: ConfigurationServiceStub }, PathHelperService, TimezoneService, provideHttpClient(withInterceptorsFromDi()), - ] -}); + ], + }); timezoneService = TestBed.inject(TimezoneService); }; + afterEach(() => { + vi.restoreAllMocks(); + }); + describe('without time zone set', () => { beforeEach(() => { compile();