From 291fb302095854a864c50fb4de1f61febb886fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 26 Jun 2026 12:26:17 +0200 Subject: [PATCH] test(e2e): target the DateField overlay and ISO mirror in the medication wizard The course-window date field now keeps its ISO value on a hidden native input (data-slot) and edits through a text overlay (data-testid). Fill the overlay, then assert the committed ISO value on the hidden input. --- e2e/medications-wizard-daily.spec.ts | 3 +++ e2e/medications-wizard-oneshot.spec.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e/medications-wizard-daily.spec.ts b/e2e/medications-wizard-daily.spec.ts index 65b23df62..7b62a9670 100644 --- a/e2e/medications-wizard-daily.spec.ts +++ b/e2e/medications-wizard-daily.spec.ts @@ -59,6 +59,9 @@ test.describe("medication wizard — daily", () => { // Step 4 — course window (today by default). await expectStep(page, 4); + // `DateField` keeps the ISO value on a hidden native date input + // (data-slot), while the visible overlay paints the locale-formatted + // string. Assert the committed ISO value on the hidden input. await expect( page.locator('[data-slot="course-window-starts"]'), ).toHaveValue(/^\d{4}-\d{2}-\d{2}$/); diff --git a/e2e/medications-wizard-oneshot.spec.ts b/e2e/medications-wizard-oneshot.spec.ts index a5506caa3..9bb93e075 100644 --- a/e2e/medications-wizard-oneshot.spec.ts +++ b/e2e/medications-wizard-oneshot.spec.ts @@ -62,7 +62,15 @@ test.describe("medication wizard — one-shot", () => { // Step 4 — course window. Set startsOn to a deterministic date so // the post body assertion below is stable. await expectStep(page, 4); - await page.locator('[data-slot="course-window-starts"]').fill("2026-10-15"); + // `DateField` rides a visible text overlay (the data-testid) that parses + // a typed ISO string back to the canonical value; the hidden native input + // (data-slot) carries the committed ISO. Type into the overlay, then blur + // so the parse commits. + await page.getByTestId("course-window-starts-field").fill("2026-10-15"); + await page.getByTestId("course-window-starts-field").blur(); + await expect( + page.locator('[data-slot="course-window-starts"]'), + ).toHaveValue("2026-10-15"); await clickNext(page); // Step 5 — pick Einmalig. The path compresses to 5 steps the