From 96ee0c782136f155e3cdc0f9a227c2eb96866376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 9 Oct 2026 18:23:48 +0200 Subject: [PATCH] test(dashboard): assert the top card switch on its region, not on the day's digest --- e2e/score-history.spec.ts | 10 +++++++--- src/app/page-client.tsx | 32 +++++++++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/e2e/score-history.spec.ts b/e2e/score-history.spec.ts index a22b9382f..9fe5630f8 100644 --- a/e2e/score-history.spec.ts +++ b/e2e/score-history.spec.ts @@ -314,9 +314,13 @@ test.describe("the dashboard's top card", () => { }), ); - const hero = page.locator('[data-slot="today-hero"]'); + // The card's region, present whenever the card is switched on. What it + // shows depends on the day's digest, which the server renders into the + // page before any route mock can answer, so the switch is asserted on + // the region and not on its content. + const hero = page.locator('[data-slot="today-card"]'); await page.goto("/"); - await expect(hero.first()).toBeVisible(); + await expect(hero).toHaveCount(1); async function flip(expected: "checked" | "unchecked") { await page.goto("/settings/layout/dashboard"); @@ -356,6 +360,6 @@ test.describe("the dashboard's top card", () => { await flip("checked"); await page.goto("/"); - await expect(hero.first()).toBeVisible(); + await expect(hero).toHaveCount(1); }); }); diff --git a/src/app/page-client.tsx b/src/app/page-client.tsx index 8e0bbde6a..d4d67a02f 100644 --- a/src/app/page-client.tsx +++ b/src/app/page-client.tsx @@ -971,19 +971,25 @@ export default function DashboardPageClient({ // v1.42 — the top card can be switched off in the layout settings; // only an explicit `false` hides it, and with it its skeleton and // its error card. - layout.todayCardVisible === false ? null : digestQuery.data ? ( - - ) : !mounted || digestQuery.isLoading ? ( - - ) : digestQuery.isError ? ( - digestQuery.refetch()} /> - ) : null + layout.todayCardVisible === false ? null : ( + // `contents`: a stable hook for the switch, no box of its own. +
+ {digestQuery.data ? ( + + ) : !mounted || digestQuery.isLoading ? ( + + ) : digestQuery.isError ? ( + digestQuery.refetch()} /> + ) : null} +
+ ) } {/* v1.42 (#615) — a quiet note about the newest stored environment