From 33358c796003e63419dc5781316ed087d71fea4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Wed, 3 Jun 2026 08:59:31 +0200 Subject: [PATCH] test(medications): pin the GLP-1 card clock off the schedule window Two assertions depended on the live wall-clock: the card suppresses the upcoming-injection line while now sits inside a schedule window, so a CI run during the 08:00-20:00 window rendered the pill instead of the Next/Recommended-next line. Pin to 07:00 Berlin on a non-scheduled day. --- .../__tests__/medication-card-glp1.test.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/medications/__tests__/medication-card-glp1.test.tsx b/src/components/medications/__tests__/medication-card-glp1.test.tsx index 2c1c6bc95..260b1d1d3 100644 --- a/src/components/medications/__tests__/medication-card-glp1.test.tsx +++ b/src/components/medications/__tests__/medication-card-glp1.test.tsx @@ -1,4 +1,4 @@ -import { describe, expect, it, vi, beforeEach } from "vitest"; +import { afterEach, describe, expect, it, vi, beforeEach } from "vitest"; import { renderToStaticMarkup } from "react-dom/server"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; @@ -163,6 +163,17 @@ function render( beforeEach(() => { vi.clearAllMocks(); + // Pin the clock so the schedule-driven window pill never displaces the + // upcoming-injection line under a CI run at a live wall-clock. The card + // suppresses the next/last line while `now` sits inside a schedule + // window, so pin to 07:00 Berlin (before the 08:00–20:00 fixture window) + // on a non-scheduled weekday — the upcoming line then always renders. + vi.useFakeTimers({ toFake: ["Date"] }); + vi.setSystemTime(new Date("2026-06-02T05:00:00Z")); +}); + +afterEach(() => { + vi.useRealTimers(); }); describe(" — GLP-1 variant rendering", () => {