mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
Accelerate the chart range switch, prefetch two list pages, calm two polls
placeholderData keeps the previous range painted while a health-chart range switch fetches, paired with its truth condition: the container dims and goes inert while isPlaceholderData is true, so the old range cannot masquerade as the new one. The mood chart needs no pairing — its range is a client-side slice over one static-key query and never drops to a skeleton. /checkups and /mood gain the dashboard-template RSC prefetch: the primary list read moves into a shared lib read (route + wrapper consume one query, so filter/order/wire shape cannot drift), the wrapper honours the DASHBOARD_SSR_PREFETCH kill-switch, resolves identity through getUnswitchedSession, JSON-round-trips the dehydrated state, and fails soft to the bare client on every error path. Page-prefetch unit tests pin the seeded keys and the fail-soft arms; the SSR hydration spec gains an assertion per page. The achievement-unlock poll drops to five minutes (in-app writes already invalidate the cell; the poll only covers out-of-band ingest), and the plan-proposal poll gains the advisor-style bounded attempt ceiling so an open thread stops polling after its budget.
This commit is contained in:
1 parent
ac96e5e975
commit
61114fab90
31 files changed
+962
-326
No files matched your search
@@ -97,4 +97,45 @@ test.describe("dashboard hydration with the SSR prefetch on", () => {
|
||||
expect(witness?.seen).toBe(true);
|
||||
expect(witness?.replaced).toBe(0);
|
||||
});
|
||||
|
||||
// The two list-page prefetch wrappers (`/checkups`, `/mood`) hand TanStack a
|
||||
// server-dehydrated state through the same HydrationBoundary mechanism the
|
||||
// dashboard uses. Their page-clients render behind a `useMounted` gate, so
|
||||
// the streamed HTML is the auth-gate shell by design — the node-identity
|
||||
// witness has nothing to latch. What CAN break, and what these assert, is
|
||||
// the hydration itself: a dehydrated state that disagrees with the client
|
||||
// render surfaces as a React #418 bailout on exactly this server (the
|
||||
// mocked suite runs with the prefetch OFF and can never see it).
|
||||
for (const target of [
|
||||
{
|
||||
path: "/checkups",
|
||||
name: "checkups",
|
||||
readySelector: '[data-testid="checkups-tab-vorsorge"]',
|
||||
},
|
||||
{
|
||||
path: "/mood",
|
||||
name: "mood",
|
||||
readySelector: '[data-tour-id="mood-hero"]',
|
||||
},
|
||||
]) {
|
||||
test(`hydrates ${target.name} with its prefetched list state`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const clientErrors: string[] = [];
|
||||
page.on("pageerror", (error) => clientErrors.push(error.message));
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") clientErrors.push(message.text());
|
||||
});
|
||||
|
||||
await page.goto(target.path);
|
||||
await expect(page.locator(target.readySelector)).toBeVisible();
|
||||
// Let every boundary hydrate and every post-mount refetch land before
|
||||
// the verdict; a bailout that happens late is still a bailout.
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
expect(
|
||||
clientErrors.filter((message) => /418|hydrat/i.test(message)),
|
||||
).toEqual([]);
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user