From e5048643f87982993094b76855e02db685a9dc44 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 31 Oct 2026 00:39:38 +0000 Subject: [PATCH] test(assistant): pin the clock in FE-AI-PICK-004 Trip 7 ran until 2026-10-30, so from 2026-10-31 on the hook ranked it as past and the test failed. Pin the date to the file's TODAY. --- .../components/Assistant/useAssistantTripPicker.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/components/Assistant/useAssistantTripPicker.test.ts b/client/src/components/Assistant/useAssistantTripPicker.test.ts index 066a6a39b..1cd94b145 100644 --- a/client/src/components/Assistant/useAssistantTripPicker.test.ts +++ b/client/src/components/Assistant/useAssistantTripPicker.test.ts @@ -20,7 +20,10 @@ const trip = (id: number, start: string | null, end: string | null) => ({ end_date: end, }); -afterEach(() => vi.restoreAllMocks()); +afterEach(() => { + vi.useRealTimers(); + vi.restoreAllMocks(); +}); describe('rankPickerTrips', () => { it('FE-AI-PICK-001: the running trip leads, then the soonest to come, then the latest past one', () => { @@ -59,6 +62,9 @@ describe('rankPickerTrips', () => { describe('useAssistantTripPicker', () => { it('FE-AI-PICK-004: loads the trips once and ranks them; a failed load offers none', async () => { + // The hook ranks against the real clock; pin it so trip 7 keeps running. + vi.useFakeTimers({ shouldAdvanceTime: true, toFake: ['Date'] }); + vi.setSystemTime(new Date(`${TODAY}T12:00:00`)); const list = vi .spyOn(tripRepo, 'list') .mockResolvedValueOnce({ trips: [trip(7, '2026-10-01', '2026-10-30') as Trip], archivedTrips: [] });