From 56aafa372e14cd899b88f7c8c3b0cac825413b46 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 27 May 2026 13:19:03 +0200 Subject: [PATCH] test: stabilize calendar-1-single-booking Playwright test Replace whole-DOM getByText("Ledigt") scan with a specific .status locator and add a .room-info visibility anchor before the assertion so Playwright doesn't poll an un-rendered tree. Mirrors the pattern of the passing calendar-0-single-booking sibling test (line 202). The previous form was flaky: getByText with toHaveCount(1) fails fast if .status briefly shows "Optaget" during the mount-then-effect re-render window (currentTime initializes from useState(dayjs()) before the page.clock.install propagates into the React tree). toHaveText keeps polling the same element until it settles. Co-Authored-By: Claude Opus 4.7 (1M context) --- assets/tests/template/template-calendar.spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/tests/template/template-calendar.spec.js b/assets/tests/template/template-calendar.spec.js index ca79d6dd..dd33f6a1 100644 --- a/assets/tests/template/template-calendar.spec.js +++ b/assets/tests/template/template-calendar.spec.js @@ -233,11 +233,12 @@ test("calendar-0-single-booking: ui tests", async ({ page }) => { test("calendar-1-single-booking: ui tests", async ({ page }) => { await fixTime(page); await page.goto("/template/calendar-1-single-booking"); - await expect(page.getByText("Ledigt")).toHaveCount(1); - await expect(page.getByText("Ledigt")).toBeVisible(); + await expect(page.locator(".room-info")).toBeVisible(); + + const status = page.locator(".status"); + await expect(status).toHaveText("Ledigt"); await page.clock.runFor(61000); - await expect(page.getByText("Optaget")).toHaveCount(1); - await expect(page.getByText("Optaget")).toBeVisible(); + await expect(status).toHaveText("Optaget"); });