From 05315ef7d914adc0142f0a2bccd6da64a5cd83df Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 15 Aug 2026 17:02:27 +0200 Subject: [PATCH] fix(planner): pin the clock in the opening-hours test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FE-PDC-019 asserts that the collapsed row shows one specific line, but the row shows the current day in the place's timezone — and the fixture gives Saturday different hours from the working week. So the test passed Monday to Friday and took the build down every weekend, which reads as a broken feature rather than a test that forgot to say which day it is standing on. Pinned to a Wednesday, with the Saturday case kept as its own test rather than thrown away: it is the one that proves the day lookup happens at all, and it is the exact case that was failing. --- .../Planner/PlaceDetailsColumn.test.tsx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/src/components/Planner/PlaceDetailsColumn.test.tsx b/client/src/components/Planner/PlaceDetailsColumn.test.tsx index 180732589..6b31ae253 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.test.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.test.tsx @@ -307,7 +307,22 @@ describe('PlaceDetailsColumn — hours and rating', () => { }) } + // The collapsed row shows the CURRENT day in the place's timezone, so a test + // that names a specific line has to say which day it is standing on. Without + // this the suite passed Monday to Friday and failed every weekend, which reads + // as a broken build rather than a test that forgot to pin its clock. + // SELECTION is in Cologne, so midday UTC is safely the same date in Berlin. + const pinDay = (iso: string) => { + vi.useFakeTimers({ shouldAdvanceTime: true }) + vi.setSystemTime(new Date(iso)) + } + + afterEach(() => { + vi.useRealTimers() + }) + it('FE-PDC-019: shows only today collapsed, not the whole week', async () => { + pinDay('2026-08-12T12:00:00Z') // Wednesday withHours() renderColumn() @@ -318,6 +333,19 @@ describe('PlaceDetailsColumn — hours and rating', () => { expect(screen.queryByText('10:00-14:00')).not.toBeInTheDocument() }) + it('FE-PDC-019b: the collapsed row follows the day, it is not just the first line', async () => { + // The case that used to take the suite down every Saturday. Worth keeping as + // a test rather than only pinning 019: it is the assertion that the day + // lookup happens at all. + pinDay('2026-08-15T12:00:00Z') // Saturday + withHours() + renderColumn() + + await screen.findByText('inspector.openingHours') + expect(screen.queryAllByText('10:00-14:00')).toHaveLength(1) + expect(screen.queryByText('09:00-18:00')).not.toBeInTheDocument() + }) + it('FE-PDC-020: opens the full week on click', async () => { withHours() renderColumn()