diff --git a/src/app/(app)/search/page.test.tsx b/src/app/(app)/search/page.test.tsx index 9d41a1d..16c6128 100644 --- a/src/app/(app)/search/page.test.tsx +++ b/src/app/(app)/search/page.test.tsx @@ -416,9 +416,16 @@ describe("ageLabel", () => { }); describe("UniversalSearchPage — recency and age chip", () => { + // Pinned clock. The chip renders an age relative to NOW, so an + // unpinned `Date.now()` makes this test expire the day after it's + // written — it passed only because 2026-10-14 happened to be exactly + // four days after the fixture's createdAt. + const NOW = new Date("2026-10-14T00:00:00.000Z"); + beforeEach(() => { fetchMock.mockReset(); vi.useFakeTimers({ shouldAdvanceTime: true }); + vi.setSystemTime(NOW); }); afterEach(() => { @@ -436,7 +443,7 @@ describe("UniversalSearchPage — recency and age chip", () => { await vi.advanceTimersByTimeAsync(400); await waitFor(() => expect(screen.getByText("ORD-1")).toBeInTheDocument()); - // Fixture date 2026-10-10 vs a "now" of 2026-10-14. + // Fixture createdAt 2026-10-10, clock pinned to 2026-10-14. expect(screen.getByText("4d")).toBeInTheDocument(); // And the exact date is available on hover, since the chip is compact. expect(