strata-react 2.1.17 → 2.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ type IconComponent = React.ComponentType<{
10
10
  type ControlSize = "default" | "sm";
11
11
  declare const buttonVariants: (props?: ({
12
12
  variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
13
- size?: "default" | "sm" | "icon" | "icon-sm" | "lg" | null | undefined;
13
+ size?: "default" | "icon" | "sm" | "icon-sm" | "lg" | null | undefined;
14
14
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
15
15
  type ButtonProps = Omit<React.ComponentProps<"button">, "className" | "style" | "title"> & VariantProps<typeof buttonVariants> & {
16
16
  className?: string;
@@ -234,4 +234,4 @@ declare const MicrophoneContext: React.Context<Microphone>;
234
234
  /** The microphone from the nearest `MicrophoneContext`. */
235
235
  declare const useMicrophone: () => Microphone;
236
236
  export { AsyncActionOptions as A, RowAction as B, useColorScheme as C, DensityName as D, Density as E, useAsyncAction as F, buttonVariants as H, Button$1 as I, ButtonProps as L, AsyncLabels as M, FieldErrors as N, DensityProps as O, Phase as P, IconButton as R, palettes as S, useSystemColorScheme as T, ControlSize as U, RowActionProps as V, IconComponent as W, PaletteOption as _, browserMicrophone as a, colorSchemeScript as b, COLOR_SCHEME_STORAGE_KEY as c, ColorSchemeLabels as d, ColorSchemePreference as f, PaletteChoice as g, PALETTE_STORAGE_KEY as h, MicrophoneStream as i, AsyncButton as j, AsyncAction as k, ColorScheme as l, DEFAULT_PALETTE as m, MicrophoneContext as n, explainMicrophoneError as o, ColorSchemeState as p, MicrophoneError as r, useMicrophone as s, Microphone as t, ColorSchemeChoice as u, PaletteState as v, usePalette as w, paletteScript as x, ThemeProvider as y, IconButtonProps as z };
237
- //# sourceMappingURL=microphone-DWh4OaMH.d.ts.map
237
+ //# sourceMappingURL=microphone-xGKxcK6p.d.ts.map
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Phase, f as ColorSchemePreference, t as Microphone } from "./microphone-DWh4OaMH.js";
1
+ import { P as Phase, f as ColorSchemePreference, t as Microphone } from "./microphone-xGKxcK6p.js";
2
2
  import * as React from "react";
3
3
  import { RouteObject, To } from "react-router";
4
4
  import { QueryClient } from "@tanstack/react-query";
@@ -230,6 +230,8 @@ type FakeSpeech = {
230
230
  texts(): string[];
231
231
  /** The clips played so far, in order (cut-off ones included). */
232
232
  clips(): string[];
233
+ /** The clips fetched so far, in order: each part's is fetched while the part before it plays, so it joins with no gap. */
234
+ loaded(): string[];
233
235
  /** Ends the utterance or clip being said, as the browser does when it has finished. */
234
236
  finish(): void;
235
237
  /** Makes the clip playing now fail (a missing file, a refused autoplay): the rest of the prompt goes to the browser's voice. */
package/dist/testing.js CHANGED
@@ -175,9 +175,14 @@ function installFakeSpeech(voices = []) {
175
175
  this.text = text;
176
176
  }
177
177
  }
178
+ const fetched = [];
178
179
  class FakeAudio {
179
180
  src = "";
180
181
  title = "";
182
+ preload = "";
183
+ constructor() {
184
+ fetched.push(this);
185
+ }
181
186
  onended = null;
182
187
  onerror = null;
183
188
  play() {
@@ -249,6 +254,7 @@ function installFakeSpeech(voices = []) {
249
254
  said,
250
255
  texts: () => said.filter((s) => !s.cancelled).map((s) => s.text),
251
256
  clips: () => said.flatMap((s) => s.clip === null ? [] : [s.clip]),
257
+ loaded: () => fetched.map((a) => a.src),
252
258
  finish() {
253
259
  if (clip) {
254
260
  const done = clip;
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/storage.ts","../src/testing/layout.ts","../src/testing/setup.ts","../src/testing/speech.ts","../src/testing/microphone.ts","../src/testing/buttons.ts","../src/testing/intersection-observer.ts","../src/testing/index.tsx"],"sourcesContent":["// Node 25 and later define a global `localStorage` that is undefined unless Node runs with\n// `--localstorage-file`, and it shadows jsdom's. In a Vitest jsdom project on Node 26 (Strata's floor)\n// `localStorage.getItem` then throws, so any app code that reads storage (a remembered choice, a\n// `ColorSchemeChoice` on a settings screen tested with storage on) fails in its tests. Strata's own\n// tests never hit it because `renderWithStrata` turns theme storage off. Every app would have copied\n// the same dozen lines (issue #298), so `installLayoutShims` installs this when, and only when, the\n// platform's storage is unusable; where it works nothing is replaced.\n\n/** An in-memory `Storage`, with the platform's behaviour (values are strings, `key` and `length` work). */\nexport function memoryStorage(): Storage {\n const data = new Map<string, string>();\n return {\n get length() {\n return data.size;\n },\n clear: () => data.clear(),\n getItem: (key) => data.get(String(key)) ?? null,\n key: (index) => [...data.keys()][index] ?? null,\n removeItem: (key) => void data.delete(String(key)),\n setItem: (key, value) => void data.set(String(key), String(value)),\n };\n}\n\nfunction usable(name: \"localStorage\" | \"sessionStorage\"): boolean {\n try {\n return typeof (globalThis as unknown as Record<string, Storage | undefined>)[name]?.getItem === \"function\";\n } catch {\n return false;\n }\n}\n\n/**\n * Replaces `localStorage` and `sessionStorage` with in-memory ones where the runtime's are missing or throw (Node 25+ under jsdom), and empties them after each test when the test runner has a global `afterEach`.\n * Does nothing where storage works. Returns a function that puts the originals back. Called by `installLayoutShims`.\n */\nexport function installStorageShim(): () => void {\n const restore: (() => void)[] = [];\n for (const name of [\"localStorage\", \"sessionStorage\"] as const) {\n if (usable(name)) continue;\n const storage = memoryStorage();\n const targets = [globalThis, typeof window !== \"undefined\" ? window : undefined].filter(\n (t): t is typeof globalThis => t !== undefined,\n );\n for (const target of new Set(targets)) {\n const before = Object.getOwnPropertyDescriptor(target, name);\n Object.defineProperty(target, name, { configurable: true, value: storage });\n restore.push(() => {\n if (before) Object.defineProperty(target, name, before);\n else delete (target as unknown as Record<string, unknown>)[name];\n });\n }\n const after = (globalThis as { afterEach?: (fn: () => void) => void }).afterEach;\n if (typeof after === \"function\") after(() => storage.clear());\n }\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","// jsdom does no layout: every box is 0×0 and there is no ResizeObserver. Components that measure\n// (LineChart's width; React Aria's Virtualizer draws every row of a list in a test unless the box is mocked, which these shims do not make smaller. A virtualised table with detail rows, or a virtualised grid of tiles, measures each row by its scroll size, which jsdom reports as 0: a test of one gives `Element.prototype.scrollHeight` a value) then render nothing to\n// assert on, so an app testing a screen built from them hits the same wall Strata's own suite did.\n// These shims give every element one fixed box and a ResizeObserver that reports it once on\n// observe (and, on Node 25+, a working in-memory localStorage: see storage.ts). Real layout is checked by the visual suite in Chromium, never here.\n\nimport { installStorageShim } from \"./storage\";\n\n// jsdom has no DOMRect constructor in every version, so rects are plain objects of the same shape.\n/** A DOMRect-shaped object, for stand-ins that report geometry. */\nexport function box(x: number, y: number, width: number, height: number): DOMRect {\n return {\n x,\n y,\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n toJSON() {\n return this;\n },\n } as DOMRect;\n}\n\n/** The box every element reports while the shims are installed. */\nexport interface LayoutBox {\n width: number;\n height: number;\n}\n\n/**\n * Give jsdom a fixed box for every element (`getBoundingClientRect`, `offset*`, `client*`) and a\n * ResizeObserver that reports it on observe, so measuring components render, and an in-memory `localStorage` and `sessionStorage` where the runtime's throw (Node 25+). Defaults to 640×280.\n * Call once in a Vitest setup file (or let `setupStrataTests` do it); does nothing, and returns a no-op, where there is no DOM (a node-environment test); returns a function that puts the originals back.\n */\nexport function installLayoutShims({ width = 640, height = 280 }: Partial<LayoutBox> = {}): () => void {\n // A setup file shared by jsdom tests and `// @vitest-environment node` ones runs this in both; with\n // no DOM there is nothing to measure and no component to render, so it does nothing (#363).\n if (typeof Element === \"undefined\" || typeof HTMLElement === \"undefined\") return () => {};\n const restore: (() => void)[] = [];\n const replace = (target: object, prop: string, descriptor: PropertyDescriptor) => {\n const before = Object.getOwnPropertyDescriptor(target, prop);\n Object.defineProperty(target, prop, { configurable: true, ...descriptor });\n restore.push(() => {\n if (before) Object.defineProperty(target, prop, before);\n else delete (target as Record<string, unknown>)[prop];\n });\n };\n\n class FixedResizeObserver implements ResizeObserver {\n constructor(private readonly callback: ResizeObserverCallback) {}\n observe(target: Element) {\n this.callback([{ target, contentRect: { width, height } } as unknown as ResizeObserverEntry], this);\n }\n unobserve() {}\n disconnect() {}\n }\n if (!globalThis.ResizeObserver) replace(globalThis, \"ResizeObserver\", { writable: true, value: FixedResizeObserver });\n\n replace(Element.prototype, \"getBoundingClientRect\", {\n writable: true,\n value: () => box(0, 0, width, height),\n });\n for (const [prop, value] of [\n [\"offsetWidth\", width],\n [\"offsetHeight\", height],\n [\"clientWidth\", width],\n [\"clientHeight\", height],\n ] as const) {\n replace(HTMLElement.prototype, prop, { get: () => value });\n }\n\n restore.push(installStorageShim());\n\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","import { cleanup } from \"@testing-library/react\";\nimport { toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { installLayoutShims, type LayoutBox } from \"./layout\";\n\n// What every Strata app's test setup file repeats (issue #363, from the Quake 2 explorer's suite):\n// unmount what each test rendered, give jsdom a layout, and forget module state between tests.\n// With Vitest's `globals` off (its default) Testing Library does not register its own\n// `afterEach(cleanup)`, so each `renderRoutes` stacked on the last (a second test found four\n// `treegrid`s with the same name). Strata's own `tests/utils/setup.ts` calls `cleanup()` itself,\n// which hid it from us.\n//\n// It takes the runner's `afterEach` rather than importing `vitest`: the runner is the app's, and\n// naming it here would make it a dependency of the package (the stack decision is Jonathan's).\n// MSW and jest-dom stay the app's, in the lines around this call.\n\n/** The options of `setupStrataTests`. */\nexport type StrataTestSetup = {\n /** The runner's `afterEach` (`import { afterEach } from \"vitest\"`). */\n afterEach: (hook: () => void | Promise<void>) => void;\n /** The box every element reports (`installLayoutShims`); `false` to skip the shims. */\n layout?: Partial<LayoutBox> | false;\n};\n\n/**\n * One call in a Vitest setup file: installs the layout shims (a no-op without a DOM), and after each\n * test unmounts what it rendered, clears the toast queue and forgets loaded thumbnails. Returns a\n * function that puts the layout back. Add jest-dom and MSW's `server` lifecycle beside it.\n */\nexport function setupStrataTests({ afterEach, layout = {} }: StrataTestSetup): () => void {\n const restore = layout === false ? () => {} : installLayoutShims(layout);\n afterEach(() => {\n cleanup(); // a no-op where nothing was rendered, so node-environment files can share the setup\n toast.clear();\n forgetLoadedThumbnails();\n });\n return restore;\n}\n","// jsdom has no `speechSynthesis`, and the device's voices are a true external, so a test of a screen\n// that speaks needs a stand-in that records what was said (strata-react issue #299). This is the one\n// stand-in an app would otherwise write: it has `speak`, `cancel`, `getVoices`, `speaking` and the\n// voiceschanged event, it ends an utterance when the test says so (`finish()`), and it never makes a sound.\n// It stands in for `Audio` too (issue #310): a recorded clip that plays is said with its `clip`, `finish()`\n// ends it (the next part starts) and `failClip()` makes it fail, as a missing file or a refused autoplay does.\n\n/** One thing said aloud. */\nexport type Spoken = {\n text: string;\n lang: string;\n rate: number;\n voice: string | null;\n cancelled: boolean;\n /** The recording that was played, or null when the browser's voice said it. */\n clip: string | null;\n};\n\n/** The recording stand-in `installFakeSpeech` puts on `window`. */\nexport type FakeSpeech = {\n /** Everything said so far, in order; an utterance cut off by a later one has `cancelled: true`. */\n said: Spoken[];\n /** The texts said so far that were not cancelled. */\n texts(): string[];\n /** The clips played so far, in order (cut-off ones included). */\n clips(): string[];\n /** Ends the utterance or clip being said, as the browser does when it has finished. */\n finish(): void;\n /** Makes the clip playing now fail (a missing file, a refused autoplay): the rest of the prompt goes to the browser's voice. */\n failClip(): void;\n /** Makes these voices the device's, and fires `voiceschanged` (the late arrival some browsers have). */\n setVoices(voices: { name: string; lang: string }[]): void;\n /** Puts the browser's own back (or none). */\n uninstall(): void;\n};\n\n/**\n * Installs a recording `speechSynthesis` and `SpeechSynthesisUtterance` on `window` and returns what was said.\n * `uninstall()` after each test. `const speech = installFakeSpeech(); … expect(speech.texts()).toEqual([\"Which one is the cat?\"])`.\n */\nexport function installFakeSpeech(voices: { name: string; lang: string }[] = []): FakeSpeech {\n const hadSynth = Object.getOwnPropertyDescriptor(window, \"speechSynthesis\");\n const hadUtterance = Object.getOwnPropertyDescriptor(globalThis, \"SpeechSynthesisUtterance\");\n const hadAudio = Object.getOwnPropertyDescriptor(window, \"Audio\");\n let clip: { entry: Spoken; audio: FakeAudio } | undefined;\n let current: { entry: Spoken; utterance: FakeUtterance } | undefined;\n let installed = voices.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n const listeners = new Set<EventListener>();\n const said: Spoken[] = [];\n\n class FakeUtterance {\n lang = \"\";\n rate = 1;\n voice: SpeechSynthesisVoice | null = null;\n onend: (() => void) | null = null;\n onerror: (() => void) | null = null;\n constructor(public text: string) {}\n }\n\n // Only what `speak` uses of an audio element: src, title (the words), play, pause and the two events.\n class FakeAudio {\n src = \"\";\n title = \"\";\n onended: (() => void) | null = null;\n onerror: (() => void) | null = null;\n play() {\n const entry: Spoken = { text: this.title, lang: \"\", rate: 1, voice: null, cancelled: false, clip: this.src };\n said.push(entry);\n clip = { entry, audio: this };\n return Promise.resolve();\n }\n pause() {\n if (clip?.audio !== this) return;\n clip.entry.cancelled = true;\n clip = undefined;\n }\n }\n\n const synth = {\n get speaking() {\n return current !== undefined;\n },\n speak(utterance: FakeUtterance) {\n const entry: Spoken = {\n text: utterance.text,\n lang: utterance.lang,\n rate: utterance.rate,\n voice: utterance.voice?.name ?? null,\n cancelled: false,\n clip: null,\n };\n said.push(entry);\n current = { entry, utterance };\n },\n cancel() {\n if (!current) return;\n const { entry, utterance } = current;\n current = undefined;\n entry.cancelled = true;\n utterance.onerror?.();\n },\n getVoices: () => installed,\n addEventListener: (_: string, l: EventListener) => void listeners.add(l),\n removeEventListener: (_: string, l: EventListener) => void listeners.delete(l),\n };\n\n Object.defineProperty(window, \"speechSynthesis\", { configurable: true, value: synth });\n Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", {\n configurable: true,\n writable: true,\n value: FakeUtterance,\n });\n Object.defineProperty(window, \"Audio\", { configurable: true, writable: true, value: FakeAudio });\n\n return {\n said,\n texts: () => said.filter((s) => !s.cancelled).map((s) => s.text),\n clips: () => said.flatMap((s) => (s.clip === null ? [] : [s.clip])),\n finish() {\n if (clip) {\n const done = clip;\n clip = undefined;\n done.audio.onended?.();\n return;\n }\n const done = current;\n current = undefined;\n done?.utterance.onend?.();\n },\n failClip() {\n const failed = clip;\n clip = undefined;\n failed?.audio.onerror?.();\n },\n setVoices(next) {\n installed = next.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n for (const l of listeners) l(new Event(\"voiceschanged\"));\n },\n uninstall() {\n if (hadSynth) Object.defineProperty(window, \"speechSynthesis\", hadSynth);\n else delete (window as unknown as Record<string, unknown>).speechSynthesis;\n if (hadUtterance) Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", hadUtterance);\n else delete (globalThis as unknown as Record<string, unknown>).SpeechSynthesisUtterance;\n if (hadAudio) Object.defineProperty(window, \"Audio\", hadAudio);\n else delete (window as unknown as Record<string, unknown>).Audio;\n },\n };\n}\n","import { MicrophoneError, type Microphone } from \"../lib/microphone\";\n\n// The microphone is hardware, the one true external a recording screen has, and jsdom, Storybook and\n// the visual suite have none. This stand-in sends a sine tone at a chosen level, `speed` times faster\n// than real time (ten by default, so a test of a two-second take waits a fifth of a second), or refuses\n// to open with a sentence as the browser's refusals become (`explainMicrophoneError`). Give it to the\n// screen through `MicrophoneContext`, or `renderWithStrata(ui, { microphone })`.\n// For a hands-free screen (`useAutoRecorder`), `script` plays stretches of tone and quiet in turn, as a\n// speaker reading prompts with gaps between them would, once (then quiet) or over and over (`loop`).\n\n/** `fakeMicrophone`'s options. */\nexport type FakeMicrophoneOptions = {\n /** Peak of the tone, 0 to 1. Default 0.3 (about -10 dBFS, a good level for speech). */\n amplitude?: number;\n /** Refuse to open with this sentence, as a `MicrophoneError` (what a screen shows). */\n refuse?: string;\n /** Throw something that is not a `MicrophoneError` (an audio graph that failed). */\n crash?: boolean;\n /** What the browser calls the device. Default \"Fake USB microphone\". */\n device?: string | null;\n /** Open but never send a sample: a take held in its first moment, for a screenshot. */\n silent?: boolean;\n /** Samples a second. Default 16 000. */\n sampleRate?: number;\n /** How many times faster than real time the samples arrive. Default 10. */\n speed?: number;\n /** Stretches of tone at their own `amplitude` (0 for quiet), played in order instead of one steady tone. */\n script?: readonly FakeSpeechStretch[];\n /** Play `script` again from the start when it ends, instead of falling quiet. */\n loop?: boolean;\n};\n\n/** One stretch of a fake microphone's `script`: so many seconds at a peak (0 is quiet). */\nexport type FakeSpeechStretch = { seconds: number; amplitude: number };\n\n/** A script of `takes` stretches of speech, each `speak` seconds after `gap` seconds of quiet, at `amplitude`. */\nexport function speechScript(\n takes: number,\n { speak = 1.5, gap = 1.5, amplitude = 0.3 }: { speak?: number; gap?: number; amplitude?: number } = {},\n): FakeSpeechStretch[] {\n return Array.from({ length: takes }, () => [\n { seconds: gap, amplitude: 0 },\n { seconds: speak, amplitude },\n ]).flat();\n}\n\n/** A microphone that sends a tone (or refuses), for tests and stories; hardware is never touched. */\nexport function fakeMicrophone({\n amplitude = 0.3,\n refuse,\n crash,\n device = \"Fake USB microphone\",\n silent,\n sampleRate = 16_000,\n speed = 10,\n script,\n loop,\n}: FakeMicrophoneOptions = {}): Microphone {\n // The amplitude at sample `t`: the script's stretch it falls in, or the steady tone's.\n const ends = (script ?? []).reduce<number[]>(\n (acc, s) => [...acc, (acc.at(-1) ?? 0) + Math.round(s.seconds * sampleRate)],\n [],\n );\n const total = ends.at(-1) ?? 0;\n const at = (t: number): number => {\n if (!script) return amplitude;\n if (total === 0) return 0;\n const n = loop ? t % total : t;\n if (n >= total) return 0;\n const i = ends.findIndex((end) => n < end);\n return script[i].amplitude;\n };\n return {\n open(onSamples) {\n if (crash) return Promise.reject(new TypeError(\"audio graph exploded\"));\n if (refuse) return Promise.reject(new MicrophoneError(refuse));\n let t = 0;\n // A tenth of a second of sound each tick, every 100 / speed ms of real time.\n const frames = Math.round(sampleRate / 10);\n const timer = silent\n ? undefined\n : setInterval(() => {\n const chunk = new Float32Array(frames);\n for (let i = 0; i < frames; i++) chunk[i] = at(t) * Math.sin((2 * Math.PI * 220 * t++) / sampleRate);\n onSamples(chunk);\n }, 100 / speed);\n return Promise.resolve({ sampleRate, device, close: () => clearInterval(timer) });\n },\n };\n}\n","import type { Phase } from \"../components/async-button\";\n\n// Assertions for the rules a screen keeps, read from what the components draw rather than from\n// their class names (strata-react issue #48, from the Tubes Library test, which matched\n// `bg-primary`). `Button` marks its variant (`data-variant`), so \"one filled button per view\"\n// (ux-research patterns.md §2, with the BulkBar hand-over: while rows are chosen the bulk action is\n// the filled one) is a check a screen test can make after every interaction. `AsyncButton` marks\n// its phase (`data-phase`), because it keeps every phase's label in the DOM to hold its width, so\n// its text reads \"AddAdding…AddedTry again\" and only the phase says which one shows.\n\n/** Whether an element is out of the view: hidden, inert or aria-hidden, itself or by an ancestor. */\nfunction outOfView(el: Element) {\n return Boolean(el.closest('[hidden], [inert], [aria-hidden=\"true\"]'));\n}\n\n/** An element's name as a person reads it: its `aria-label`, else its text without the parts hidden from screen readers. */\nfunction nameOf(el: Element): string {\n const label = el.getAttribute(\"aria-label\");\n if (label) return label;\n const walk = (node: Node): string =>\n node.nodeType === 3\n ? (node.textContent ?? \"\")\n : node instanceof Element && node.getAttribute(\"aria-hidden\") === \"true\"\n ? \"\"\n : [...node.childNodes].map(walk).join(\"\");\n return walk(el).replace(/\\s+/g, \" \").trim();\n}\n\n/** The filled (`variant=\"default\"`) buttons and links in `container` (default the whole document) that are in view. */\nexport function filledButtons(container: ParentNode = document.body): HTMLElement[] {\n return [...container.querySelectorAll<HTMLElement>('[data-variant=\"default\"]')].filter((el) => !outOfView(el));\n}\n\n/** Throws unless `container` (default the whole document) has exactly one filled button in view; the message names the ones found. */\nexport function expectOneFilledButton(container: ParentNode = document.body): HTMLElement {\n const found = filledButtons(container);\n if (found.length === 1) return found[0];\n const names = found.map((el) => `\"${nameOf(el)}\"`).join(\", \");\n throw new Error(`Expected one filled button in the view, found ${found.length}${names ? `: ${names}` : \"\"}.`);\n}\n\n/** The phase an `AsyncButton` is in (`idle`, `pending`, `done`, `error`), from the button or any element inside it. */\nexport function asyncButtonPhase(el: Element): Phase {\n const phase = el.closest(\"[data-phase]\")?.getAttribute(\"data-phase\");\n if (phase === \"idle\" || phase === \"pending\" || phase === \"done\" || phase === \"error\") return phase;\n throw new Error(`Not an AsyncButton: ${el.outerHTML.slice(0, 120)}`);\n}\n","// jsdom has no IntersectionObserver and does no layout, so nothing a component observes ever comes\n// into view in a unit test. Infinite lists load the next page when a sentinel at the end of the\n// list intersects, and before this helper every app wrote its own firable fake to test that\n// (strata-react issue #12, from strata-listory). This one stands in for the global, records what\n// each observer watches, and lets the test say when something scrolls into view: `scrollToEnd()`\n// for the common case, `intersect(el)` for one element. Entries are delivered inside `act` so the\n// state updates they cause are flushed before the next assertion, as a real scroll would be.\n\nimport { act } from \"@testing-library/react\";\nimport { box } from \"./layout\";\n\n/** One stand-in observer: its callback, options and the elements it currently watches. */\nexport interface FakeObserver {\n readonly callback: IntersectionObserverCallback;\n readonly options: IntersectionObserverInit;\n readonly targets: ReadonlySet<Element>;\n}\n\n/** The controls `installFakeIntersectionObserver` returns. */\nexport interface FakeIntersectionObserverControls {\n /** Every observer created since install, including disconnected ones (their target sets are empty). */\n readonly observers: readonly FakeObserver[];\n /** Report `el` to every observer watching it: in view by default, or out of view with `false`. Returns how many observers were told. */\n intersect(el: Element, isIntersecting?: boolean): number;\n /** Report every watched element as in view, as if the person scrolled to the end of the list. Returns how many elements were reported. */\n scrollToEnd(): number;\n /** Put back whatever `IntersectionObserver` was there before install. */\n uninstall(): void;\n}\n\nfunction entryFor(target: Element, isIntersecting: boolean): IntersectionObserverEntry {\n const rect = target.getBoundingClientRect();\n return {\n target,\n isIntersecting,\n intersectionRatio: isIntersecting ? 1 : 0,\n boundingClientRect: rect,\n intersectionRect: isIntersecting ? rect : box(0, 0, 0, 0),\n rootBounds: null,\n time: performance.now(),\n };\n}\n\n/**\n * Replace `globalThis.IntersectionObserver` with a stand-in the test fires by hand. Call it in\n * `beforeEach` and call `uninstall()` in `afterEach`.\n *\n * @example\n * let io: FakeIntersectionObserverControls;\n * beforeEach(() => { io = installFakeIntersectionObserver(); });\n * afterEach(() => io.uninstall());\n *\n * it(\"loads the next page at the end of the list\", async () => {\n * renderWithStrata(<Pieces />);\n * await screen.findByRole(\"list\", { name: \"Pieces\" });\n * io.scrollToEnd();\n * expect(await screen.findByText(\"Celadon bowl\")).toBeInTheDocument();\n * });\n */\nexport function installFakeIntersectionObserver(): FakeIntersectionObserverControls {\n const previous = Object.getOwnPropertyDescriptor(globalThis, \"IntersectionObserver\");\n const observers: (FakeObserver & { targets: Set<Element>; self: IntersectionObserver })[] = [];\n\n class FakeIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly thresholds: readonly number[];\n readonly scrollMargin = \"0px\";\n private readonly record: (typeof observers)[number];\n\n constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit = {}) {\n this.root = options.root ?? null;\n this.rootMargin = options.rootMargin ?? \"0px\";\n const threshold = options.threshold ?? 0;\n this.thresholds = Array.isArray(threshold) ? threshold : [threshold];\n this.record = { callback, options, targets: new Set(), self: this };\n observers.push(this.record);\n }\n observe(target: Element) {\n this.record.targets.add(target);\n }\n unobserve(target: Element) {\n this.record.targets.delete(target);\n }\n disconnect() {\n this.record.targets.clear();\n }\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n }\n\n Object.defineProperty(globalThis, \"IntersectionObserver\", {\n configurable: true,\n writable: true,\n value: FakeIntersectionObserver,\n });\n\n const deliver = (observer: (typeof observers)[number], targets: readonly Element[], isIntersecting: boolean) => {\n act(() =>\n observer.callback(\n targets.map((t) => entryFor(t, isIntersecting)),\n observer.self,\n ),\n );\n };\n\n return {\n observers,\n intersect(el, isIntersecting = true) {\n const watching = observers.filter((o) => o.targets.has(el));\n for (const o of watching) deliver(o, [el], isIntersecting);\n return watching.length;\n },\n scrollToEnd() {\n // Snapshot every observer's targets before any callback runs: a callback that loads more\n // may observe a new sentinel, on this observer or another, which the person has not\n // scrolled to yet.\n const batches = observers.map((o) => [o, [...o.targets]] as const).filter(([, targets]) => targets.length > 0);\n for (const [o, targets] of batches) deliver(o, targets, true);\n return batches.reduce((n, [, targets]) => n + targets.length, 0);\n },\n uninstall() {\n if (previous) Object.defineProperty(globalThis, \"IntersectionObserver\", previous);\n else delete (globalThis as { IntersectionObserver?: unknown }).IntersectionObserver;\n },\n };\n}\n","/**\n * Test helpers: render a component, or a whole route tree, inside a router and a query client, as\n * a Strata app runs it,\n * and fill the gaps jsdom leaves (layout, ResizeObserver, IntersectionObserver). Use with MSW for\n * the network, never module mocks.\n *\n * @module strata-react/testing\n */\nimport * as React from \"react\";\nimport { act, render, type RenderOptions } from \"@testing-library/react\";\nimport { MemoryRouter, RouterProvider, createMemoryRouter, type RouteObject, type To } from \"react-router\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { StrataQueryProvider, createQueryClient } from \"../query\";\nimport { ThemeProvider, type ColorSchemePreference } from \"../components/theme\";\nimport { StrataToastRegion, toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { MicrophoneContext, type Microphone } from \"../lib/microphone\";\n\nexport { installLayoutShims, type LayoutBox } from \"./layout\";\nexport { setupStrataTests, type StrataTestSetup } from \"./setup\";\nexport { installStorageShim, memoryStorage } from \"./storage\";\nexport { installFakeSpeech, type FakeSpeech, type Spoken } from \"./speech\";\nexport { fakeMicrophone, speechScript, type FakeMicrophoneOptions, type FakeSpeechStretch } from \"./microphone\";\nexport { filledButtons, expectOneFilledButton, asyncButtonPhase } from \"./buttons\";\nexport {\n installFakeIntersectionObserver,\n type FakeIntersectionObserverControls,\n type FakeObserver,\n} from \"./intersection-observer\";\n\n// Render a component the way a Strata app runs it: inside a router and a query client. Tests use\n// MSW for the network (see CLAUDE.md), never module mocks, so the real fetch/query/DataView path\n// runs. Each call gets a fresh QueryClient with retries off, so a test that serves a 500 sees the\n// error at once instead of after the retry delay. It also runs inside a ThemeProvider with\n// storage off, so `useColorScheme` works and a test can render the dark scheme with\n// `colorScheme: \"dark\"` without touching localStorage or leaking state into the next test.\n\n/** A query client for tests: no retries, and nothing goes stale or is collected mid-test. */\nexport function createTestQueryClient() {\n return createQueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, gcTime: Infinity } } });\n}\n\n/** The options `renderWithStrata` and `renderRoutes` share, beside Testing Library's own. */\nexport type StrataRenderOptions = Omit<RenderOptions, \"wrapper\"> & {\n /** The URL the test starts at, with its search and hash (`/bookings?sort=pieces.desc`). Defaults to `/`. */\n route?: string;\n /** The query client; a fresh `createTestQueryClient()` when left out. */\n client?: QueryClient;\n /** The colour scheme to render; `light` when left out. */\n colorScheme?: ColorSchemePreference;\n /** Render the one `StrataToastRegion`, so `toast.show(...)` has somewhere to appear and a test can find it. Default true; pass `false` when the app's own route tree renders the region (a root layout route), or a test would see every toast twice. The queue is cleared at the start of each render, so a toast never carries into the next test. */\n toasts?: boolean;\n /** The microphone a recording screen gets from `useMicrophone()`, such as `fakeMicrophone()`; the browser's when left out (which jsdom cannot open). */\n microphone?: Microphone;\n /** The mount point of an app served behind a proxy (`\"/_home/\"`): a `<base href>` is in the document while the render lasts and removed when it unmounts, so `withBase`, `createApi` and `useSystemInfo` read what they read in production and in `strata-visual`. None when left out. */\n base?: string;\n};\n\n// A <base href> for one render (#350): `appBase()` reads the page's <base>, which jsdom does not have.\n// It is installed before the render (and before `renderRoutes` creates its router, whose loaders run\n// at creation and may call `withBase`), first in <head> so it wins over one a setup file left. It is\n// made once per render call, outside React's render, so Strict Mode cannot leave a second one behind;\n// the provider removes it when the tree unmounts (Testing Library's cleanup does that after each\n// test) and puts it back if Strict Mode's rehearsal of the effect took it out.\nfunction installBase(base: string | undefined): HTMLBaseElement | null {\n if (base === undefined || typeof document === \"undefined\") return null;\n const el = document.createElement(\"base\");\n el.setAttribute(\"href\", base);\n document.head.prepend(el);\n return el;\n}\n\nfunction useBaseElement(element: HTMLBaseElement | null | undefined) {\n React.useEffect(() => {\n if (element && !element.isConnected) document.head.prepend(element);\n return () => element?.remove();\n }, [element]);\n}\n\n// The providers every Strata app has above its router, in the order an app nests them.\nfunction StrataProviders({\n client,\n colorScheme,\n toasts,\n microphone,\n base,\n children,\n}: {\n base?: HTMLBaseElement | null;\n client: QueryClient;\n colorScheme: ColorSchemePreference;\n toasts: boolean;\n microphone?: Microphone;\n children: React.ReactNode;\n}) {\n useBaseElement(base);\n const tree = (\n <ThemeProvider defaultPreference={colorScheme} storageKey={null}>\n <StrataQueryProvider client={client}>\n {children}\n {toasts && <StrataToastRegion />}\n </StrataQueryProvider>\n </ThemeProvider>\n );\n return microphone ? <MicrophoneContext.Provider value={microphone}>{tree}</MicrophoneContext.Provider> : tree;\n}\n\n/** Testing Library's `render` inside `StrataQueryProvider` and a `MemoryRouter` at `route`. */\nexport function renderWithStrata(\n ui: React.ReactElement,\n {\n route = \"/\",\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: StrataRenderOptions = {},\n) {\n toast.clear(); // module state: a toast from the last test must not show in this one\n forgetLoadedThumbnails(); // likewise the pictures a Thumbnail has loaded: each test starts from skeletons\n const baseElement = installBase(base);\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>\n </StrataProviders>\n );\n return { client, ...render(ui, { wrapper: Wrapper, ...options }) };\n}\n\n// Render an app's own route tree: its layout routes and <Outlet />s, index routes, redirects\n// (<Navigate /> or a loader's redirect()), loaders, actions and error elements. Those only run in\n// a data router, which <MemoryRouter> is not, so renderWithStrata cannot show them; this builds\n// the memory twin of the app's createBrowserRouter from the same RouteObject[] the app exports,\n// so the test and the app cannot drift. The providers and options are renderWithStrata's.\n// `basename` is the app's own (the kiln app runs under /kiln), and `route` is the full URL,\n// basename included, as the browser would show it. The router is returned so a test can assert\n// where a redirect landed (`router.state.location`), and `navigate` moves it inside act().\n\n/** `renderRoutes`'s options: `renderWithStrata`'s, plus the app's `basename`. */\nexport type RenderRoutesOptions = StrataRenderOptions & {\n /** The base path the app is served under, as passed to `createBrowserRouter`. */\n basename?: string;\n};\n\n/** Testing Library's `render` of an app's route tree in a memory data router at `route`, with Strata's providers. */\nexport function renderRoutes(\n routes: RouteObject[],\n {\n route,\n basename,\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: RenderRoutesOptions = {},\n) {\n toast.clear();\n forgetLoadedThumbnails();\n const baseElement = installBase(base);\n const router = createMemoryRouter(routes, { initialEntries: [route ?? basename ?? \"/\"], basename });\n const result = render(\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <RouterProvider router={router} />\n </StrataProviders>,\n options,\n );\n const navigate = (to: To | number) =>\n act(async () => {\n await (typeof to === \"number\" ? router.navigate(to) : router.navigate(to));\n });\n return { client, router, navigate, ...result };\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,gBAAyB;CACvC,MAAM,uBAAO,IAAI,IAAoB;CACrC,OAAO;EACL,IAAI,SAAS;GACX,OAAO,KAAK;EACd;EACA,aAAa,KAAK,MAAM;EACxB,UAAU,QAAQ,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK;EAC3C,MAAM,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU;EAC3C,aAAa,QAAQ,KAAK,KAAK,OAAO,OAAO,GAAG,CAAC;EACjD,UAAU,KAAK,UAAU,KAAK,KAAK,IAAI,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;CACnE;AACF;AAEA,SAAS,OAAO,MAAkD;CAChE,IAAI;EACF,OAAO,OAAQ,WAA8D,KAAK,EAAE,YAAY;CAClG,QAAQ;EACN,OAAO;CACT;AACF;;;;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AAW,EAAE,eACjB,oBAAC,iBAAD;EACU;EACK;EACL;EACI;EACZ,MAAM;YAEN,oBAAC,cAAD;GAAc,gBAAgB,CAAC,KAAK;GAAI;EAAuB;CAChD;CAEnB,OAAO;EAAE;EAAQ,GAAG,OAAO,IAAI;GAAE,SAAS;GAAS,GAAG;EAAQ,CAAC;CAAE;AACnE;;AAkBA,SAAgB,aACd,QACA,EACE,OACA,UACA,SAAS,sBAAsB,GAC/B,cAAc,SACd,SAAS,MACT,YACA,MACA,GAAG,YACoB,CAAC,GAC1B;CACA,MAAM,MAAM;CACZ,uBAAuB;CACvB,MAAM,cAAc,YAAY,IAAI;CACpC,MAAM,SAAS,mBAAmB,QAAQ;EAAE,gBAAgB,CAAC,SAAS,YAAY,GAAG;EAAG;CAAS,CAAC;CAClG,MAAM,SAAS,OACb,oBAAC,iBAAD;EACU;EACK;EACL;EACI;EACZ,MAAM;YAEN,oBAAC,gBAAD,EAAwB,OAAS;CAClB,IACjB,OACF;CACA,MAAM,YAAY,OAChB,IAAI,YAAY;EACd,OAAO,OAAO,OAAO,WAAW,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE;CAC1E,CAAC;CACH,OAAO;EAAE;EAAQ;EAAQ;EAAU,GAAG;CAAO;AAC/C"}
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/storage.ts","../src/testing/layout.ts","../src/testing/setup.ts","../src/testing/speech.ts","../src/testing/microphone.ts","../src/testing/buttons.ts","../src/testing/intersection-observer.ts","../src/testing/index.tsx"],"sourcesContent":["// Node 25 and later define a global `localStorage` that is undefined unless Node runs with\n// `--localstorage-file`, and it shadows jsdom's. In a Vitest jsdom project on Node 26 (Strata's floor)\n// `localStorage.getItem` then throws, so any app code that reads storage (a remembered choice, a\n// `ColorSchemeChoice` on a settings screen tested with storage on) fails in its tests. Strata's own\n// tests never hit it because `renderWithStrata` turns theme storage off. Every app would have copied\n// the same dozen lines (issue #298), so `installLayoutShims` installs this when, and only when, the\n// platform's storage is unusable; where it works nothing is replaced.\n\n/** An in-memory `Storage`, with the platform's behaviour (values are strings, `key` and `length` work). */\nexport function memoryStorage(): Storage {\n const data = new Map<string, string>();\n return {\n get length() {\n return data.size;\n },\n clear: () => data.clear(),\n getItem: (key) => data.get(String(key)) ?? null,\n key: (index) => [...data.keys()][index] ?? null,\n removeItem: (key) => void data.delete(String(key)),\n setItem: (key, value) => void data.set(String(key), String(value)),\n };\n}\n\nfunction usable(name: \"localStorage\" | \"sessionStorage\"): boolean {\n try {\n return typeof (globalThis as unknown as Record<string, Storage | undefined>)[name]?.getItem === \"function\";\n } catch {\n return false;\n }\n}\n\n/**\n * Replaces `localStorage` and `sessionStorage` with in-memory ones where the runtime's are missing or throw (Node 25+ under jsdom), and empties them after each test when the test runner has a global `afterEach`.\n * Does nothing where storage works. Returns a function that puts the originals back. Called by `installLayoutShims`.\n */\nexport function installStorageShim(): () => void {\n const restore: (() => void)[] = [];\n for (const name of [\"localStorage\", \"sessionStorage\"] as const) {\n if (usable(name)) continue;\n const storage = memoryStorage();\n const targets = [globalThis, typeof window !== \"undefined\" ? window : undefined].filter(\n (t): t is typeof globalThis => t !== undefined,\n );\n for (const target of new Set(targets)) {\n const before = Object.getOwnPropertyDescriptor(target, name);\n Object.defineProperty(target, name, { configurable: true, value: storage });\n restore.push(() => {\n if (before) Object.defineProperty(target, name, before);\n else delete (target as unknown as Record<string, unknown>)[name];\n });\n }\n const after = (globalThis as { afterEach?: (fn: () => void) => void }).afterEach;\n if (typeof after === \"function\") after(() => storage.clear());\n }\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","// jsdom does no layout: every box is 0×0 and there is no ResizeObserver. Components that measure\n// (LineChart's width; React Aria's Virtualizer draws every row of a list in a test unless the box is mocked, which these shims do not make smaller. A virtualised table with detail rows, or a virtualised grid of tiles, measures each row by its scroll size, which jsdom reports as 0: a test of one gives `Element.prototype.scrollHeight` a value) then render nothing to\n// assert on, so an app testing a screen built from them hits the same wall Strata's own suite did.\n// These shims give every element one fixed box and a ResizeObserver that reports it once on\n// observe (and, on Node 25+, a working in-memory localStorage: see storage.ts). Real layout is checked by the visual suite in Chromium, never here.\n\nimport { installStorageShim } from \"./storage\";\n\n// jsdom has no DOMRect constructor in every version, so rects are plain objects of the same shape.\n/** A DOMRect-shaped object, for stand-ins that report geometry. */\nexport function box(x: number, y: number, width: number, height: number): DOMRect {\n return {\n x,\n y,\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n toJSON() {\n return this;\n },\n } as DOMRect;\n}\n\n/** The box every element reports while the shims are installed. */\nexport interface LayoutBox {\n width: number;\n height: number;\n}\n\n/**\n * Give jsdom a fixed box for every element (`getBoundingClientRect`, `offset*`, `client*`) and a\n * ResizeObserver that reports it on observe, so measuring components render, and an in-memory `localStorage` and `sessionStorage` where the runtime's throw (Node 25+). Defaults to 640×280.\n * Call once in a Vitest setup file (or let `setupStrataTests` do it); does nothing, and returns a no-op, where there is no DOM (a node-environment test); returns a function that puts the originals back.\n */\nexport function installLayoutShims({ width = 640, height = 280 }: Partial<LayoutBox> = {}): () => void {\n // A setup file shared by jsdom tests and `// @vitest-environment node` ones runs this in both; with\n // no DOM there is nothing to measure and no component to render, so it does nothing (#363).\n if (typeof Element === \"undefined\" || typeof HTMLElement === \"undefined\") return () => {};\n const restore: (() => void)[] = [];\n const replace = (target: object, prop: string, descriptor: PropertyDescriptor) => {\n const before = Object.getOwnPropertyDescriptor(target, prop);\n Object.defineProperty(target, prop, { configurable: true, ...descriptor });\n restore.push(() => {\n if (before) Object.defineProperty(target, prop, before);\n else delete (target as Record<string, unknown>)[prop];\n });\n };\n\n class FixedResizeObserver implements ResizeObserver {\n constructor(private readonly callback: ResizeObserverCallback) {}\n observe(target: Element) {\n this.callback([{ target, contentRect: { width, height } } as unknown as ResizeObserverEntry], this);\n }\n unobserve() {}\n disconnect() {}\n }\n if (!globalThis.ResizeObserver) replace(globalThis, \"ResizeObserver\", { writable: true, value: FixedResizeObserver });\n\n replace(Element.prototype, \"getBoundingClientRect\", {\n writable: true,\n value: () => box(0, 0, width, height),\n });\n for (const [prop, value] of [\n [\"offsetWidth\", width],\n [\"offsetHeight\", height],\n [\"clientWidth\", width],\n [\"clientHeight\", height],\n ] as const) {\n replace(HTMLElement.prototype, prop, { get: () => value });\n }\n\n restore.push(installStorageShim());\n\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","import { cleanup } from \"@testing-library/react\";\nimport { toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { installLayoutShims, type LayoutBox } from \"./layout\";\n\n// What every Strata app's test setup file repeats (issue #363, from the Quake 2 explorer's suite):\n// unmount what each test rendered, give jsdom a layout, and forget module state between tests.\n// With Vitest's `globals` off (its default) Testing Library does not register its own\n// `afterEach(cleanup)`, so each `renderRoutes` stacked on the last (a second test found four\n// `treegrid`s with the same name). Strata's own `tests/utils/setup.ts` calls `cleanup()` itself,\n// which hid it from us.\n//\n// It takes the runner's `afterEach` rather than importing `vitest`: the runner is the app's, and\n// naming it here would make it a dependency of the package (the stack decision is Jonathan's).\n// MSW and jest-dom stay the app's, in the lines around this call.\n\n/** The options of `setupStrataTests`. */\nexport type StrataTestSetup = {\n /** The runner's `afterEach` (`import { afterEach } from \"vitest\"`). */\n afterEach: (hook: () => void | Promise<void>) => void;\n /** The box every element reports (`installLayoutShims`); `false` to skip the shims. */\n layout?: Partial<LayoutBox> | false;\n};\n\n/**\n * One call in a Vitest setup file: installs the layout shims (a no-op without a DOM), and after each\n * test unmounts what it rendered, clears the toast queue and forgets loaded thumbnails. Returns a\n * function that puts the layout back. Add jest-dom and MSW's `server` lifecycle beside it.\n */\nexport function setupStrataTests({ afterEach, layout = {} }: StrataTestSetup): () => void {\n const restore = layout === false ? () => {} : installLayoutShims(layout);\n afterEach(() => {\n cleanup(); // a no-op where nothing was rendered, so node-environment files can share the setup\n toast.clear();\n forgetLoadedThumbnails();\n });\n return restore;\n}\n","// jsdom has no `speechSynthesis`, and the device's voices are a true external, so a test of a screen\n// that speaks needs a stand-in that records what was said (strata-react issue #299). This is the one\n// stand-in an app would otherwise write: it has `speak`, `cancel`, `getVoices`, `speaking` and the\n// voiceschanged event, it ends an utterance when the test says so (`finish()`), and it never makes a sound.\n// It stands in for `Audio` too (issue #310): a recorded clip that plays is said with its `clip`, `finish()`\n// ends it (the next part starts) and `failClip()` makes it fail, as a missing file or a refused autoplay does;\n// `loaded()` lists every clip fetched, so a test sees the next part's fetched while this one plays.\n\n/** One thing said aloud. */\nexport type Spoken = {\n text: string;\n lang: string;\n rate: number;\n voice: string | null;\n cancelled: boolean;\n /** The recording that was played, or null when the browser's voice said it. */\n clip: string | null;\n};\n\n/** The recording stand-in `installFakeSpeech` puts on `window`. */\nexport type FakeSpeech = {\n /** Everything said so far, in order; an utterance cut off by a later one has `cancelled: true`. */\n said: Spoken[];\n /** The texts said so far that were not cancelled. */\n texts(): string[];\n /** The clips played so far, in order (cut-off ones included). */\n clips(): string[];\n /** The clips fetched so far, in order: each part's is fetched while the part before it plays, so it joins with no gap. */\n loaded(): string[];\n /** Ends the utterance or clip being said, as the browser does when it has finished. */\n finish(): void;\n /** Makes the clip playing now fail (a missing file, a refused autoplay): the rest of the prompt goes to the browser's voice. */\n failClip(): void;\n /** Makes these voices the device's, and fires `voiceschanged` (the late arrival some browsers have). */\n setVoices(voices: { name: string; lang: string }[]): void;\n /** Puts the browser's own back (or none). */\n uninstall(): void;\n};\n\n/**\n * Installs a recording `speechSynthesis` and `SpeechSynthesisUtterance` on `window` and returns what was said.\n * `uninstall()` after each test. `const speech = installFakeSpeech(); … expect(speech.texts()).toEqual([\"Which one is the cat?\"])`.\n */\nexport function installFakeSpeech(voices: { name: string; lang: string }[] = []): FakeSpeech {\n const hadSynth = Object.getOwnPropertyDescriptor(window, \"speechSynthesis\");\n const hadUtterance = Object.getOwnPropertyDescriptor(globalThis, \"SpeechSynthesisUtterance\");\n const hadAudio = Object.getOwnPropertyDescriptor(window, \"Audio\");\n let clip: { entry: Spoken; audio: FakeAudio } | undefined;\n let current: { entry: Spoken; utterance: FakeUtterance } | undefined;\n let installed = voices.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n const listeners = new Set<EventListener>();\n const said: Spoken[] = [];\n\n class FakeUtterance {\n lang = \"\";\n rate = 1;\n voice: SpeechSynthesisVoice | null = null;\n onend: (() => void) | null = null;\n onerror: (() => void) | null = null;\n constructor(public text: string) {}\n }\n\n const fetched: FakeAudio[] = [];\n\n // Only what `speak` uses of an audio element: src, title (the words), preload, play, pause and the two events.\n class FakeAudio {\n src = \"\";\n title = \"\";\n preload = \"\";\n constructor() {\n fetched.push(this);\n }\n onended: (() => void) | null = null;\n onerror: (() => void) | null = null;\n play() {\n const entry: Spoken = { text: this.title, lang: \"\", rate: 1, voice: null, cancelled: false, clip: this.src };\n said.push(entry);\n clip = { entry, audio: this };\n return Promise.resolve();\n }\n pause() {\n if (clip?.audio !== this) return;\n clip.entry.cancelled = true;\n clip = undefined;\n }\n }\n\n const synth = {\n get speaking() {\n return current !== undefined;\n },\n speak(utterance: FakeUtterance) {\n const entry: Spoken = {\n text: utterance.text,\n lang: utterance.lang,\n rate: utterance.rate,\n voice: utterance.voice?.name ?? null,\n cancelled: false,\n clip: null,\n };\n said.push(entry);\n current = { entry, utterance };\n },\n cancel() {\n if (!current) return;\n const { entry, utterance } = current;\n current = undefined;\n entry.cancelled = true;\n utterance.onerror?.();\n },\n getVoices: () => installed,\n addEventListener: (_: string, l: EventListener) => void listeners.add(l),\n removeEventListener: (_: string, l: EventListener) => void listeners.delete(l),\n };\n\n Object.defineProperty(window, \"speechSynthesis\", { configurable: true, value: synth });\n Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", {\n configurable: true,\n writable: true,\n value: FakeUtterance,\n });\n Object.defineProperty(window, \"Audio\", { configurable: true, writable: true, value: FakeAudio });\n\n return {\n said,\n texts: () => said.filter((s) => !s.cancelled).map((s) => s.text),\n clips: () => said.flatMap((s) => (s.clip === null ? [] : [s.clip])),\n loaded: () => fetched.map((a) => a.src),\n finish() {\n if (clip) {\n const done = clip;\n clip = undefined;\n done.audio.onended?.();\n return;\n }\n const done = current;\n current = undefined;\n done?.utterance.onend?.();\n },\n failClip() {\n const failed = clip;\n clip = undefined;\n failed?.audio.onerror?.();\n },\n setVoices(next) {\n installed = next.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n for (const l of listeners) l(new Event(\"voiceschanged\"));\n },\n uninstall() {\n if (hadSynth) Object.defineProperty(window, \"speechSynthesis\", hadSynth);\n else delete (window as unknown as Record<string, unknown>).speechSynthesis;\n if (hadUtterance) Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", hadUtterance);\n else delete (globalThis as unknown as Record<string, unknown>).SpeechSynthesisUtterance;\n if (hadAudio) Object.defineProperty(window, \"Audio\", hadAudio);\n else delete (window as unknown as Record<string, unknown>).Audio;\n },\n };\n}\n","import { MicrophoneError, type Microphone } from \"../lib/microphone\";\n\n// The microphone is hardware, the one true external a recording screen has, and jsdom, Storybook and\n// the visual suite have none. This stand-in sends a sine tone at a chosen level, `speed` times faster\n// than real time (ten by default, so a test of a two-second take waits a fifth of a second), or refuses\n// to open with a sentence as the browser's refusals become (`explainMicrophoneError`). Give it to the\n// screen through `MicrophoneContext`, or `renderWithStrata(ui, { microphone })`.\n// For a hands-free screen (`useAutoRecorder`), `script` plays stretches of tone and quiet in turn, as a\n// speaker reading prompts with gaps between them would, once (then quiet) or over and over (`loop`).\n\n/** `fakeMicrophone`'s options. */\nexport type FakeMicrophoneOptions = {\n /** Peak of the tone, 0 to 1. Default 0.3 (about -10 dBFS, a good level for speech). */\n amplitude?: number;\n /** Refuse to open with this sentence, as a `MicrophoneError` (what a screen shows). */\n refuse?: string;\n /** Throw something that is not a `MicrophoneError` (an audio graph that failed). */\n crash?: boolean;\n /** What the browser calls the device. Default \"Fake USB microphone\". */\n device?: string | null;\n /** Open but never send a sample: a take held in its first moment, for a screenshot. */\n silent?: boolean;\n /** Samples a second. Default 16 000. */\n sampleRate?: number;\n /** How many times faster than real time the samples arrive. Default 10. */\n speed?: number;\n /** Stretches of tone at their own `amplitude` (0 for quiet), played in order instead of one steady tone. */\n script?: readonly FakeSpeechStretch[];\n /** Play `script` again from the start when it ends, instead of falling quiet. */\n loop?: boolean;\n};\n\n/** One stretch of a fake microphone's `script`: so many seconds at a peak (0 is quiet). */\nexport type FakeSpeechStretch = { seconds: number; amplitude: number };\n\n/** A script of `takes` stretches of speech, each `speak` seconds after `gap` seconds of quiet, at `amplitude`. */\nexport function speechScript(\n takes: number,\n { speak = 1.5, gap = 1.5, amplitude = 0.3 }: { speak?: number; gap?: number; amplitude?: number } = {},\n): FakeSpeechStretch[] {\n return Array.from({ length: takes }, () => [\n { seconds: gap, amplitude: 0 },\n { seconds: speak, amplitude },\n ]).flat();\n}\n\n/** A microphone that sends a tone (or refuses), for tests and stories; hardware is never touched. */\nexport function fakeMicrophone({\n amplitude = 0.3,\n refuse,\n crash,\n device = \"Fake USB microphone\",\n silent,\n sampleRate = 16_000,\n speed = 10,\n script,\n loop,\n}: FakeMicrophoneOptions = {}): Microphone {\n // The amplitude at sample `t`: the script's stretch it falls in, or the steady tone's.\n const ends = (script ?? []).reduce<number[]>(\n (acc, s) => [...acc, (acc.at(-1) ?? 0) + Math.round(s.seconds * sampleRate)],\n [],\n );\n const total = ends.at(-1) ?? 0;\n const at = (t: number): number => {\n if (!script) return amplitude;\n if (total === 0) return 0;\n const n = loop ? t % total : t;\n if (n >= total) return 0;\n const i = ends.findIndex((end) => n < end);\n return script[i].amplitude;\n };\n return {\n open(onSamples) {\n if (crash) return Promise.reject(new TypeError(\"audio graph exploded\"));\n if (refuse) return Promise.reject(new MicrophoneError(refuse));\n let t = 0;\n // A tenth of a second of sound each tick, every 100 / speed ms of real time.\n const frames = Math.round(sampleRate / 10);\n const timer = silent\n ? undefined\n : setInterval(() => {\n const chunk = new Float32Array(frames);\n for (let i = 0; i < frames; i++) chunk[i] = at(t) * Math.sin((2 * Math.PI * 220 * t++) / sampleRate);\n onSamples(chunk);\n }, 100 / speed);\n return Promise.resolve({ sampleRate, device, close: () => clearInterval(timer) });\n },\n };\n}\n","import type { Phase } from \"../components/async-button\";\n\n// Assertions for the rules a screen keeps, read from what the components draw rather than from\n// their class names (strata-react issue #48, from the Tubes Library test, which matched\n// `bg-primary`). `Button` marks its variant (`data-variant`), so \"one filled button per view\"\n// (ux-research patterns.md §2, with the BulkBar hand-over: while rows are chosen the bulk action is\n// the filled one) is a check a screen test can make after every interaction. `AsyncButton` marks\n// its phase (`data-phase`), because it keeps every phase's label in the DOM to hold its width, so\n// its text reads \"AddAdding…AddedTry again\" and only the phase says which one shows.\n\n/** Whether an element is out of the view: hidden, inert or aria-hidden, itself or by an ancestor. */\nfunction outOfView(el: Element) {\n return Boolean(el.closest('[hidden], [inert], [aria-hidden=\"true\"]'));\n}\n\n/** An element's name as a person reads it: its `aria-label`, else its text without the parts hidden from screen readers. */\nfunction nameOf(el: Element): string {\n const label = el.getAttribute(\"aria-label\");\n if (label) return label;\n const walk = (node: Node): string =>\n node.nodeType === 3\n ? (node.textContent ?? \"\")\n : node instanceof Element && node.getAttribute(\"aria-hidden\") === \"true\"\n ? \"\"\n : [...node.childNodes].map(walk).join(\"\");\n return walk(el).replace(/\\s+/g, \" \").trim();\n}\n\n/** The filled (`variant=\"default\"`) buttons and links in `container` (default the whole document) that are in view. */\nexport function filledButtons(container: ParentNode = document.body): HTMLElement[] {\n return [...container.querySelectorAll<HTMLElement>('[data-variant=\"default\"]')].filter((el) => !outOfView(el));\n}\n\n/** Throws unless `container` (default the whole document) has exactly one filled button in view; the message names the ones found. */\nexport function expectOneFilledButton(container: ParentNode = document.body): HTMLElement {\n const found = filledButtons(container);\n if (found.length === 1) return found[0];\n const names = found.map((el) => `\"${nameOf(el)}\"`).join(\", \");\n throw new Error(`Expected one filled button in the view, found ${found.length}${names ? `: ${names}` : \"\"}.`);\n}\n\n/** The phase an `AsyncButton` is in (`idle`, `pending`, `done`, `error`), from the button or any element inside it. */\nexport function asyncButtonPhase(el: Element): Phase {\n const phase = el.closest(\"[data-phase]\")?.getAttribute(\"data-phase\");\n if (phase === \"idle\" || phase === \"pending\" || phase === \"done\" || phase === \"error\") return phase;\n throw new Error(`Not an AsyncButton: ${el.outerHTML.slice(0, 120)}`);\n}\n","// jsdom has no IntersectionObserver and does no layout, so nothing a component observes ever comes\n// into view in a unit test. Infinite lists load the next page when a sentinel at the end of the\n// list intersects, and before this helper every app wrote its own firable fake to test that\n// (strata-react issue #12, from strata-listory). This one stands in for the global, records what\n// each observer watches, and lets the test say when something scrolls into view: `scrollToEnd()`\n// for the common case, `intersect(el)` for one element. Entries are delivered inside `act` so the\n// state updates they cause are flushed before the next assertion, as a real scroll would be.\n\nimport { act } from \"@testing-library/react\";\nimport { box } from \"./layout\";\n\n/** One stand-in observer: its callback, options and the elements it currently watches. */\nexport interface FakeObserver {\n readonly callback: IntersectionObserverCallback;\n readonly options: IntersectionObserverInit;\n readonly targets: ReadonlySet<Element>;\n}\n\n/** The controls `installFakeIntersectionObserver` returns. */\nexport interface FakeIntersectionObserverControls {\n /** Every observer created since install, including disconnected ones (their target sets are empty). */\n readonly observers: readonly FakeObserver[];\n /** Report `el` to every observer watching it: in view by default, or out of view with `false`. Returns how many observers were told. */\n intersect(el: Element, isIntersecting?: boolean): number;\n /** Report every watched element as in view, as if the person scrolled to the end of the list. Returns how many elements were reported. */\n scrollToEnd(): number;\n /** Put back whatever `IntersectionObserver` was there before install. */\n uninstall(): void;\n}\n\nfunction entryFor(target: Element, isIntersecting: boolean): IntersectionObserverEntry {\n const rect = target.getBoundingClientRect();\n return {\n target,\n isIntersecting,\n intersectionRatio: isIntersecting ? 1 : 0,\n boundingClientRect: rect,\n intersectionRect: isIntersecting ? rect : box(0, 0, 0, 0),\n rootBounds: null,\n time: performance.now(),\n };\n}\n\n/**\n * Replace `globalThis.IntersectionObserver` with a stand-in the test fires by hand. Call it in\n * `beforeEach` and call `uninstall()` in `afterEach`.\n *\n * @example\n * let io: FakeIntersectionObserverControls;\n * beforeEach(() => { io = installFakeIntersectionObserver(); });\n * afterEach(() => io.uninstall());\n *\n * it(\"loads the next page at the end of the list\", async () => {\n * renderWithStrata(<Pieces />);\n * await screen.findByRole(\"list\", { name: \"Pieces\" });\n * io.scrollToEnd();\n * expect(await screen.findByText(\"Celadon bowl\")).toBeInTheDocument();\n * });\n */\nexport function installFakeIntersectionObserver(): FakeIntersectionObserverControls {\n const previous = Object.getOwnPropertyDescriptor(globalThis, \"IntersectionObserver\");\n const observers: (FakeObserver & { targets: Set<Element>; self: IntersectionObserver })[] = [];\n\n class FakeIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly thresholds: readonly number[];\n readonly scrollMargin = \"0px\";\n private readonly record: (typeof observers)[number];\n\n constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit = {}) {\n this.root = options.root ?? null;\n this.rootMargin = options.rootMargin ?? \"0px\";\n const threshold = options.threshold ?? 0;\n this.thresholds = Array.isArray(threshold) ? threshold : [threshold];\n this.record = { callback, options, targets: new Set(), self: this };\n observers.push(this.record);\n }\n observe(target: Element) {\n this.record.targets.add(target);\n }\n unobserve(target: Element) {\n this.record.targets.delete(target);\n }\n disconnect() {\n this.record.targets.clear();\n }\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n }\n\n Object.defineProperty(globalThis, \"IntersectionObserver\", {\n configurable: true,\n writable: true,\n value: FakeIntersectionObserver,\n });\n\n const deliver = (observer: (typeof observers)[number], targets: readonly Element[], isIntersecting: boolean) => {\n act(() =>\n observer.callback(\n targets.map((t) => entryFor(t, isIntersecting)),\n observer.self,\n ),\n );\n };\n\n return {\n observers,\n intersect(el, isIntersecting = true) {\n const watching = observers.filter((o) => o.targets.has(el));\n for (const o of watching) deliver(o, [el], isIntersecting);\n return watching.length;\n },\n scrollToEnd() {\n // Snapshot every observer's targets before any callback runs: a callback that loads more\n // may observe a new sentinel, on this observer or another, which the person has not\n // scrolled to yet.\n const batches = observers.map((o) => [o, [...o.targets]] as const).filter(([, targets]) => targets.length > 0);\n for (const [o, targets] of batches) deliver(o, targets, true);\n return batches.reduce((n, [, targets]) => n + targets.length, 0);\n },\n uninstall() {\n if (previous) Object.defineProperty(globalThis, \"IntersectionObserver\", previous);\n else delete (globalThis as { IntersectionObserver?: unknown }).IntersectionObserver;\n },\n };\n}\n","/**\n * Test helpers: render a component, or a whole route tree, inside a router and a query client, as\n * a Strata app runs it,\n * and fill the gaps jsdom leaves (layout, ResizeObserver, IntersectionObserver). Use with MSW for\n * the network, never module mocks.\n *\n * @module strata-react/testing\n */\nimport * as React from \"react\";\nimport { act, render, type RenderOptions } from \"@testing-library/react\";\nimport { MemoryRouter, RouterProvider, createMemoryRouter, type RouteObject, type To } from \"react-router\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { StrataQueryProvider, createQueryClient } from \"../query\";\nimport { ThemeProvider, type ColorSchemePreference } from \"../components/theme\";\nimport { StrataToastRegion, toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { MicrophoneContext, type Microphone } from \"../lib/microphone\";\n\nexport { installLayoutShims, type LayoutBox } from \"./layout\";\nexport { setupStrataTests, type StrataTestSetup } from \"./setup\";\nexport { installStorageShim, memoryStorage } from \"./storage\";\nexport { installFakeSpeech, type FakeSpeech, type Spoken } from \"./speech\";\nexport { fakeMicrophone, speechScript, type FakeMicrophoneOptions, type FakeSpeechStretch } from \"./microphone\";\nexport { filledButtons, expectOneFilledButton, asyncButtonPhase } from \"./buttons\";\nexport {\n installFakeIntersectionObserver,\n type FakeIntersectionObserverControls,\n type FakeObserver,\n} from \"./intersection-observer\";\n\n// Render a component the way a Strata app runs it: inside a router and a query client. Tests use\n// MSW for the network (see CLAUDE.md), never module mocks, so the real fetch/query/DataView path\n// runs. Each call gets a fresh QueryClient with retries off, so a test that serves a 500 sees the\n// error at once instead of after the retry delay. It also runs inside a ThemeProvider with\n// storage off, so `useColorScheme` works and a test can render the dark scheme with\n// `colorScheme: \"dark\"` without touching localStorage or leaking state into the next test.\n\n/** A query client for tests: no retries, and nothing goes stale or is collected mid-test. */\nexport function createTestQueryClient() {\n return createQueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, gcTime: Infinity } } });\n}\n\n/** The options `renderWithStrata` and `renderRoutes` share, beside Testing Library's own. */\nexport type StrataRenderOptions = Omit<RenderOptions, \"wrapper\"> & {\n /** The URL the test starts at, with its search and hash (`/bookings?sort=pieces.desc`). Defaults to `/`. */\n route?: string;\n /** The query client; a fresh `createTestQueryClient()` when left out. */\n client?: QueryClient;\n /** The colour scheme to render; `light` when left out. */\n colorScheme?: ColorSchemePreference;\n /** Render the one `StrataToastRegion`, so `toast.show(...)` has somewhere to appear and a test can find it. Default true; pass `false` when the app's own route tree renders the region (a root layout route), or a test would see every toast twice. The queue is cleared at the start of each render, so a toast never carries into the next test. */\n toasts?: boolean;\n /** The microphone a recording screen gets from `useMicrophone()`, such as `fakeMicrophone()`; the browser's when left out (which jsdom cannot open). */\n microphone?: Microphone;\n /** The mount point of an app served behind a proxy (`\"/_home/\"`): a `<base href>` is in the document while the render lasts and removed when it unmounts, so `withBase`, `createApi` and `useSystemInfo` read what they read in production and in `strata-visual`. None when left out. */\n base?: string;\n};\n\n// A <base href> for one render (#350): `appBase()` reads the page's <base>, which jsdom does not have.\n// It is installed before the render (and before `renderRoutes` creates its router, whose loaders run\n// at creation and may call `withBase`), first in <head> so it wins over one a setup file left. It is\n// made once per render call, outside React's render, so Strict Mode cannot leave a second one behind;\n// the provider removes it when the tree unmounts (Testing Library's cleanup does that after each\n// test) and puts it back if Strict Mode's rehearsal of the effect took it out.\nfunction installBase(base: string | undefined): HTMLBaseElement | null {\n if (base === undefined || typeof document === \"undefined\") return null;\n const el = document.createElement(\"base\");\n el.setAttribute(\"href\", base);\n document.head.prepend(el);\n return el;\n}\n\nfunction useBaseElement(element: HTMLBaseElement | null | undefined) {\n React.useEffect(() => {\n if (element && !element.isConnected) document.head.prepend(element);\n return () => element?.remove();\n }, [element]);\n}\n\n// The providers every Strata app has above its router, in the order an app nests them.\nfunction StrataProviders({\n client,\n colorScheme,\n toasts,\n microphone,\n base,\n children,\n}: {\n base?: HTMLBaseElement | null;\n client: QueryClient;\n colorScheme: ColorSchemePreference;\n toasts: boolean;\n microphone?: Microphone;\n children: React.ReactNode;\n}) {\n useBaseElement(base);\n const tree = (\n <ThemeProvider defaultPreference={colorScheme} storageKey={null}>\n <StrataQueryProvider client={client}>\n {children}\n {toasts && <StrataToastRegion />}\n </StrataQueryProvider>\n </ThemeProvider>\n );\n return microphone ? <MicrophoneContext.Provider value={microphone}>{tree}</MicrophoneContext.Provider> : tree;\n}\n\n/** Testing Library's `render` inside `StrataQueryProvider` and a `MemoryRouter` at `route`. */\nexport function renderWithStrata(\n ui: React.ReactElement,\n {\n route = \"/\",\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: StrataRenderOptions = {},\n) {\n toast.clear(); // module state: a toast from the last test must not show in this one\n forgetLoadedThumbnails(); // likewise the pictures a Thumbnail has loaded: each test starts from skeletons\n const baseElement = installBase(base);\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>\n </StrataProviders>\n );\n return { client, ...render(ui, { wrapper: Wrapper, ...options }) };\n}\n\n// Render an app's own route tree: its layout routes and <Outlet />s, index routes, redirects\n// (<Navigate /> or a loader's redirect()), loaders, actions and error elements. Those only run in\n// a data router, which <MemoryRouter> is not, so renderWithStrata cannot show them; this builds\n// the memory twin of the app's createBrowserRouter from the same RouteObject[] the app exports,\n// so the test and the app cannot drift. The providers and options are renderWithStrata's.\n// `basename` is the app's own (the kiln app runs under /kiln), and `route` is the full URL,\n// basename included, as the browser would show it. The router is returned so a test can assert\n// where a redirect landed (`router.state.location`), and `navigate` moves it inside act().\n\n/** `renderRoutes`'s options: `renderWithStrata`'s, plus the app's `basename`. */\nexport type RenderRoutesOptions = StrataRenderOptions & {\n /** The base path the app is served under, as passed to `createBrowserRouter`. */\n basename?: string;\n};\n\n/** Testing Library's `render` of an app's route tree in a memory data router at `route`, with Strata's providers. */\nexport function renderRoutes(\n routes: RouteObject[],\n {\n route,\n basename,\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: RenderRoutesOptions = {},\n) {\n toast.clear();\n forgetLoadedThumbnails();\n const baseElement = installBase(base);\n const router = createMemoryRouter(routes, { initialEntries: [route ?? basename ?? \"/\"], basename });\n const result = render(\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <RouterProvider router={router} />\n </StrataProviders>,\n options,\n );\n const navigate = (to: To | number) =>\n act(async () => {\n await (typeof to === \"number\" ? router.navigate(to) : router.navigate(to));\n });\n return { client, router, navigate, ...result };\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,gBAAyB;CACvC,MAAM,uBAAO,IAAI,IAAoB;CACrC,OAAO;EACL,IAAI,SAAS;GACX,OAAO,KAAK;EACd;EACA,aAAa,KAAK,MAAM;EACxB,UAAU,QAAQ,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK;EAC3C,MAAM,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU;EAC3C,aAAa,QAAQ,KAAK,KAAK,OAAO,OAAO,GAAG,CAAC;EACjD,UAAU,KAAK,UAAU,KAAK,KAAK,IAAI,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;CACnE;AACF;AAEA,SAAS,OAAO,MAAkD;CAChE,IAAI;EACF,OAAO,OAAQ,WAA8D,KAAK,EAAE,YAAY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Q,KACR,SAAS,sBAAsB,GAC/B,cAAc,SACd,SAAS,MACT,YACA,MACA,GAAG,YACoB,CAAC,GAC1B;CACA,MAAM,MAAM;CACZ,uBAAuB;CACvB,MAAM,cAAc,YAAY,IAAI;CACpC,MAAM,WAAW,EAAE,eACjB,oBAAC,iBAAD;EACU;EACK;EACL;EACI;EACZ,MAAM;YAEN,oBAAC,cAAD;GAAc,gBAAgB,CAAC,KAAK;GAAI;EAAuB;CAChD;CAEnB,OAAO;EAAE;EAAQ,GAAG,OAAO,IAAI;GAAE,SAAS;GAAS,GAAG;EAAQ,CAAC;CAAE;AACnE;;AAkBA,SAAgB,aACd,QACA,EACE,OACA,UACA,SAAS,sBAAsB,GAC/B,cAAc,SACd,SAAS,MACT,YACA,MACA,GAAG,YACoB,CAAC,GAC1B;CACA,MAAM,MAAM;CACZ,uBAAuB;CACvB,MAAM,cAAc,YAAY,IAAI;CACpC,MAAM,SAAS,mBAAmB,QAAQ;EAAE,gBAAgB,CAAC,SAAS,YAAY,GAAG;EAAG;CAAS,CAAC;CAClG,MAAM,SAAS,OACb,oBAAC,iBAAD;EACU;EACK;EACL;EACI;EACZ,MAAM;YAEN,oBAAC,gBAAD,EAAwB,OAAS;CAClB,IACjB,OACF;CACA,MAAM,YAAY,OAChB,IAAI,YAAY;EACd,OAAO,OAAO,OAAO,WAAW,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE;CAC1E,CAAC;CACH,OAAO;EAAE;EAAQ;EAAQ;EAAU,GAAG;CAAO;AAC/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strata-react",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
4
4
  "description": "React + Tailwind v4 components that ship structure, behaviour, states and a token contract, and no look: each product brings a theme generated from its own subject.",
5
5
  "repository": {
6
6
  "type": "git",