From b660d27af5d16625d5be408f18211cee9df6abd5 Mon Sep 17 00:00:00 2001 From: Cameron Reeves Date: Thu, 6 Aug 2026 04:12:01 +1000 Subject: [PATCH] fix(explore): make the parking clamp test independent of the runner timezone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same fault as the three fixed in #485: the expectation was written as a fixed `+10:00` offset while the clamp applies `bookable_hours` with `Date#setHours`, which is machine-local. On a UTC runner the expected period start came out exactly ten hours adrift, so `nx test explore` failed for anyone outside eastern Australia — including CI, whenever a change touched this library. Input and expectations are now all built from local components. Found by sweeping every app and library under UTC and Pacific/Honolulu after #485; this was the only remaining case. Verified green under UTC, Australia/Sydney, America/New_York, Pacific/Honolulu and Asia/Kolkata. Co-Authored-By: Claude Opus 5 --- .../explore/src/tests/explore-parking.service.spec.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/explore/src/tests/explore-parking.service.spec.ts b/libs/explore/src/tests/explore-parking.service.spec.ts index 4e0052d378..084e16c4ca 100644 --- a/libs/explore/src/tests/explore-parking.service.spec.ts +++ b/libs/explore/src/tests/explore-parking.service.spec.ts @@ -146,7 +146,12 @@ describe('ExploreParkingService', () => { }); it('should clamp all-day parking queries to bookable hours', async () => { - const date = new Date('2026-07-09T13:45:00+10:00').valueOf(); + // The clamp applies `bookable_hours` with `Date#setHours`, which is the + // machine's timezone, so the input and the expectations below are all + // built from local components. Writing them as a fixed UTC offset pins + // the test to a runner in that zone — on a UTC runner the expected + // start came out ten hours adrift. + const date = new Date(2026, 6, 9, 13, 45).valueOf(); const settings = spectator.inject(SettingsService); vi.mocked(settings.get).mockImplementation((key) => key === 'app.parking.bookable_hours' @@ -167,10 +172,10 @@ describe('ExploreParkingService', () => { ); const params = (call[0] as any).query_params; expect(params.period_start).toBe( - getUnixTime(new Date('2026-07-09T08:00:00+10:00')), + getUnixTime(new Date(2026, 6, 9, 8, 0, 0, 0)), ); expect(params.period_end).toBe( - getUnixTime(new Date('2026-07-09T18:00:00+10:00')), + getUnixTime(new Date(2026, 6, 9, 18, 0, 0, 0)), ); });