mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(charts): match chart loading shells to the charts they become
The footer reserve under a day-linked chart's loading shell still held the caption line that was dropped from those charts, so every such shell stood 20 px taller than its chart (40 px on a phone). The dashboard's mood chart loaded behind the generic shell, which is about 30 px shorter than the mood card. When the shared chart chunk arrived late the dashboard's chart row changed height under a reader already scrolled past it; the tablet shell journey measured <main> right after such a swap and found it no longer at its end. The reserve now holds only the day rug, and the mood chart gets a shell built from the same card primitives and boxes. The tablet journey also waits for every chart cell to reveal and every loading shell to go before it scrolls to the end, instead of trusting two equal heights 250 ms apart.
This commit is contained in:
1 parent
23a6f85b0f
commit
e84c358fdf
5 files changed
+103
-16
No files matched your search
@@ -54,6 +54,42 @@ async function openDashboard(page: Page) {
|
||||
).toBeVisible();
|
||||
// The module-gated destinations join the rail once `/api/auth/me` lands.
|
||||
await expect(page.locator('aside nav a[href="/medications"]')).toHaveCount(1);
|
||||
await expectChartRowSettled(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* The dashboard's chart row has swapped every loading shell for its chart.
|
||||
*
|
||||
* The charts are one lazily loaded chunk, and each cell holds a skeleton until
|
||||
* it lands and the row reveals. The swap changes the row's height, so a page
|
||||
* measured before it is not the page the reader ends up with: on a loaded
|
||||
* runner the chunk arrived a second after the dashboard painted, after
|
||||
* `scrollMainToEnd` had already seen two equal heights, and `<main>` was no
|
||||
* longer at its end when it was measured. Waited for on the cells' own state
|
||||
* rather than on time.
|
||||
*/
|
||||
async function expectChartRowSettled(page: Page) {
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
page.evaluate(() => {
|
||||
const main = document.getElementById("main-content")!;
|
||||
const cells = main.querySelectorAll(
|
||||
'[data-slot="dashboard-chart-cell"]',
|
||||
);
|
||||
const held = main.querySelectorAll(
|
||||
'[data-slot="dashboard-chart-cell"]:not([data-revealed="true"])',
|
||||
);
|
||||
const shells = main.querySelectorAll('[data-slot="chart-skeleton"]');
|
||||
return {
|
||||
cells: cells.length > 0,
|
||||
held: held.length,
|
||||
shells: shells.length,
|
||||
};
|
||||
}),
|
||||
{ timeout: 15_000 },
|
||||
)
|
||||
.toEqual({ cells: true, held: 0, shells: 0 });
|
||||
}
|
||||
|
||||
/** The shell fills the window exactly and the document has nothing to scroll. */
|
||||
|
||||
Reference in new issue
Block a user