mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
- 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.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
/**
|
|
* 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>$/);
|
|
});
|
|
});
|