mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
Lighten the client shell and finish four client surfaces
- Load each settings section on its own: the section route imported all twenty-one statically. A preload starts the chunk beside the record gate's read, and the loading state paints the settings card shell. /settings/[section] goes from 611 to 403 KB gz. - Take Zod out of the shell every route shares: the account-access parse run on each boot is plain TypeScript now, held to the published schema by an equivalence test over good and broken blocks. The canonical unit table moves to its own module, so the display transform no longer pulls Zod in either. Layout entry 199 to 136 KB gz; /insights 369 to 304, /medications 428 to 365, /labs 400 to 337. - Open a saved Coach conversation at its last answer: an instant jump instead of the smooth scroll that lost the end, then follow late layout (charts, tables) for a few seconds until the reader scrolls. - Show the document archive as a month grid of preview tiles, two across on a phone and three or four on a desktop, with the month headings kept. - Add the admin card for the measurement table maintenance: a status read on the maintenance route, one calm confirmation, and the run's state while it is queued, running, finished or stopped. - Re-base the bundle budget: /insights at 304, /settings/[section] watched at 403, aggregate cap 4335 with the reason written down.
This commit is contained in:
1 parent
bb563b6506
commit
12e422c25e
38 files changed
+2505
-406
No files matched your search
@@ -336,3 +336,40 @@ describe("<UploadStateCard>", () => {
|
||||
expect(html).toContain("1 GB");
|
||||
});
|
||||
});
|
||||
|
||||
describe('<DocumentCard variant="tile"> (the archive grid)', () => {
|
||||
it("puts a 4:3 preview above the title, falling back to the kind icon", () => {
|
||||
const html = render(
|
||||
<DocumentCard
|
||||
variant="tile"
|
||||
document={doc()}
|
||||
selected={false}
|
||||
onToggleSelected={noop}
|
||||
onOpen={noop}
|
||||
highlighted={false}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('data-variant="tile"');
|
||||
const preview = html.indexOf('data-slot="document-preview"');
|
||||
expect(preview).toBeGreaterThan(-1);
|
||||
expect(html).toMatch(/data-slot="document-preview"[^>]*aspect-\[4\/3\]/);
|
||||
// Preview first, title after it.
|
||||
expect(html.indexOf("MRT Knie")).toBeGreaterThan(preview);
|
||||
// No thumbnail rendered yet: the kind icon fills the preview, no <img>.
|
||||
expect(html).not.toContain("<img");
|
||||
});
|
||||
|
||||
it("keeps the row card as the default for every other surface", () => {
|
||||
const html = render(
|
||||
<DocumentCard
|
||||
document={doc()}
|
||||
selected={false}
|
||||
onToggleSelected={noop}
|
||||
onOpen={noop}
|
||||
highlighted={false}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('data-variant="row"');
|
||||
expect(html).not.toContain('data-slot="document-preview"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* The archive grid's shape: two tiles side by side on a phone, three or four
|
||||
* on a desktop, measured from the grid's own width (the AuthShell inset is
|
||||
* already taken off by the time the grid measures itself).
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import {
|
||||
columnsForWidth,
|
||||
DocumentMonthHeading,
|
||||
estimatedRowHeight,
|
||||
} from "../document-month-grid";
|
||||
|
||||
describe("columnsForWidth", () => {
|
||||
it("lays a 390 px phone out in two columns, the narrowest screens in one", () => {
|
||||
// 390 viewport minus the shell's 16 px gutters.
|
||||
expect(columnsForWidth(358)).toBe(2);
|
||||
expect(columnsForWidth(320 - 32)).toBe(1);
|
||||
});
|
||||
|
||||
it("uses three columns on a small desktop and four on a wide one", () => {
|
||||
expect(columnsForWidth(1024 - 48)).toBe(3);
|
||||
// 1440 viewport: the shell caps the container at 1280 minus its gutters.
|
||||
expect(columnsForWidth(1280 - 48)).toBe(4);
|
||||
});
|
||||
|
||||
it("never asks for a fifth column", () => {
|
||||
expect(columnsForWidth(4000)).toBe(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe("estimatedRowHeight", () => {
|
||||
it("grows with the tile's width, so the first guess is close to the measured row", () => {
|
||||
expect(estimatedRowHeight(358, 2)).toBeLessThan(
|
||||
estimatedRowHeight(1232, 2),
|
||||
);
|
||||
expect(estimatedRowHeight(358, 2)).toBeGreaterThan(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe("<DocumentMonthHeading>", () => {
|
||||
it("keeps the month heading as the grid's section label", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<I18nProvider initialLocale="en">
|
||||
<DocumentMonthHeading label="March 2026" />
|
||||
</I18nProvider>,
|
||||
);
|
||||
expect(html).toMatch(/^<h2 [^>]*uppercase[^>]*>March 2026<\/h2>$/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user