Files
Marc-André Bombeck 3ab85f85f9 test(measurements): drive the measurement form in a real browser
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.
2026-10-23 13:07:29 +02:00

15 lines
560 B
TypeScript

/**
* Pin `Date` for a browser test, and nothing else.
*
* Forms default their timestamp to "now" and refuse a future one, so a test
* that asserts the instant a form sends has to say what now is. Only `Date`
* is faked: timers, animation frames and the microtask queue keep running,
* which is what Radix, TanStack Query and the URL-state queue wait on.
* `setup.ts` restores the real clock after every test.
*/
import { vi } from "vitest";
export function pinDate(iso: string): void {
vi.useFakeTimers({ toFake: ["Date"], now: new Date(iso) });
}