Drops document-level View Transitions and the lesson hold: they dropped clicks for 120-180 ms, froze the screen while route code loaded, and let the dock act on a stale lesson. Navigation now swaps immediately; only the content region enters (opacity and a 6 px rise, 160 ms); a 2 px loading line appears when code or data takes over 150 ms; the dock works from the outline and the URL, so a second Next advances again; focus moves to the new h1 and a polite live region announces it. Route chunks of a feature preload together so the sidebar never drops. Scroll restore stops on user input; pdf.js never starts a load after cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
19 lines
771 B
TypeScript
19 lines
771 B
TypeScript
import { afterEach, expect, test } from "bun:test";
|
|
import { renderToString } from "react-dom/server";
|
|
import { LoadingLine, reducedMotion } from "../src";
|
|
|
|
const g = globalThis as Record<string, unknown>;
|
|
afterEach(() => { delete g.window; });
|
|
|
|
test("reducedMotion follows the media query and is false without a window", () => {
|
|
expect(reducedMotion()).toBe(false);
|
|
g.window = { matchMedia: (q: string) => ({ matches: q.includes("prefers-reduced-motion: reduce") }) };
|
|
expect(reducedMotion()).toBe(true);
|
|
g.window = { matchMedia: () => ({ matches: false }) };
|
|
expect(reducedMotion()).toBe(false);
|
|
});
|
|
|
|
test("LoadingLine renders nothing until its delay has passed (fast loads show no indicator)", () => {
|
|
expect(renderToString(<LoadingLine />)).toBe("");
|
|
});
|