mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
Type into the form, press Save and read the request body off the fetch boundary: blood pressure as one batch, a weight typed in lb stored in kg, a decimal comma, glucose typed in mmol/L stored in mg/dL with its meal context, a sleep typed as 7:30 stored as 450 minutes. Native required validation, the pending state, a refused write's localised message, the module-off type list, the last-used type and the menu's Reset are covered too. The unit-label and glucose-unit markup tests are deleted; their source pins are replaced by the wire assertions. The module-types file keeps its pure ownership checks and drops its render. The browser helper gains a Date-only clock pin, clears localStorage between tests, carries an envelope's meta, and answers the providers' locale mirror without counting it as the component's request.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
/**
|
|
* Setup for the `browser` project (`*.browser.test.tsx`, headless Chromium).
|
|
*
|
|
* - The app stylesheet, compiled by Vite through the project's PostCSS
|
|
* config, so components lay out and hide as they do in the app, under the
|
|
* theme class the boot script sets for a first visit (`dark`, see
|
|
* `src/lib/pwa/theme-color.ts`); without one no colour token resolves.
|
|
* - The EN catalog, the fallback floor of every `t()` chain, loaded through
|
|
* the production loader. `renderWithApp` loads any other locale it is
|
|
* asked for.
|
|
* - After every test: the real `fetch`, the real clock, the page's starting
|
|
* address and an empty `localStorage` come back, so a stub, a pinned date,
|
|
* a URL write or a remembered preference never reaches the next test. Rendered
|
|
* trees are unmounted by `vitest-browser-react` itself.
|
|
*/
|
|
import "@/app/globals.css";
|
|
|
|
import { afterEach, beforeAll, beforeEach, vi } from "vitest";
|
|
|
|
import { loadMessages } from "@/lib/i18n/load-locale";
|
|
|
|
import { restoreFetch } from "./fetch-stub";
|
|
import { rememberAddress, restoreAddress } from "./url";
|
|
|
|
document.documentElement.classList.add("dark");
|
|
|
|
beforeAll(async () => {
|
|
await loadMessages("en");
|
|
});
|
|
|
|
beforeEach(() => {
|
|
rememberAddress();
|
|
});
|
|
|
|
afterEach(() => {
|
|
restoreFetch();
|
|
vi.useRealTimers();
|
|
restoreAddress();
|
|
window.localStorage.clear();
|
|
});
|