mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
test(dashboard): assert the top card switch on its region, not on the day's digest
This commit is contained in:
1 parent
25d0839296
commit
96ee0c7821
2 files changed
+26
-16
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
+19
-13
@@ -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 ? (
|
||||
<TodayHero
|
||||
digest={digestQuery.data}
|
||||
renderFilteredAllClear={renderFilteredHeroAllClear}
|
||||
// Server-persisted hero choice — rides the same resolved layout
|
||||
// as the widget visibility below, so SSR and hydration agree.
|
||||
primaryContent={layout.hero ?? "score"}
|
||||
/>
|
||||
) : !mounted || digestQuery.isLoading ? (
|
||||
<TodayHeroSkeleton />
|
||||
) : digestQuery.isError ? (
|
||||
<QueryErrorCard onRetry={() => digestQuery.refetch()} />
|
||||
) : null
|
||||
layout.todayCardVisible === false ? null : (
|
||||
// `contents`: a stable hook for the switch, no box of its own.
|
||||
<div data-slot="today-card" className="contents">
|
||||
{digestQuery.data ? (
|
||||
<TodayHero
|
||||
digest={digestQuery.data}
|
||||
renderFilteredAllClear={renderFilteredHeroAllClear}
|
||||
// Server-persisted hero choice — rides the same resolved
|
||||
// layout as the widget visibility below, so SSR and
|
||||
// hydration agree.
|
||||
primaryContent={layout.hero ?? "score"}
|
||||
/>
|
||||
) : !mounted || digestQuery.isLoading ? (
|
||||
<TodayHeroSkeleton />
|
||||
) : digestQuery.isError ? (
|
||||
<QueryErrorCard onRetry={() => digestQuery.refetch()} />
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
{/* v1.42 (#615) — a quiet note about the newest stored environment
|
||||
|
||||
Reference in new issue
Block a user