@ultimat3/testing 31.25.0 → 31.26.0

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.
package/CLAUDE.md CHANGED
@@ -87,6 +87,7 @@ the off-barrel entry points `registry-isolation.ts`, `conformance.ts`. Full rule
87
87
  | A catalog restore is a MERGE, never a replace | the other three registries are replaced with the snapshot. `registerCatalog` has no inverse, so all a file can cost its neighbour is a `resetCatalogs()` |
88
88
  | A file's policy environment is ITS import graph | at the body's start the permission set and role map narrow to names a module the file's import graph reaches declared (`import-graph.ts`, `registry-environment.ts`), plus the preload's and any first declared during this load; the body's own declarations end with the file. Framework repo only: an app keeps the union (`loadApp()` is no static edge) |
89
89
  | Noted driver stores and mounted admins end with the file | `driver-store-boundary.ts`: back to the preload's notes (a store noted at a fixture's import is no later file's); `admin-mount-boundary.ts`: back to what the body inherited. Read through the require cache / the global symbol — never an import |
90
+ | So do channels, mcp recipes/remote servers, the authenticator and the persister | `declaration-boundary.ts` (`DECLARATION_TABLES`) and `factory-persist.ts`: back to what the body inherited; an owner unloaded at the body's start is left alone. `process-registries.test.ts` ledgers every module-scope `Map`/`Set` beside a `register*`/`define*` export — a new one reds until its row says restored, rerun, reported, boot or open |
90
91
  | Permissions are still REPLACED at a file boundary, and it is measured | a dynamic `loadApp()`'s `definePermissions()` is dropped there. Open. Full rule: `docs/history/testing.md` |
91
92
  | Guarded state is boot state | the guard covers only registries that must be clean at file end — `declareTags` and `registerTier` are boot installs; "filled" and "cleared" are two questions. Full rule: `docs/history/testing.md` |
92
93
  | An empty registry is a premise you state | a test whose subject is "nothing is declared" — `x db gen` with nothing to generate — calls `isolateEntityRegistry()` and restores in a `finally`. |
package/README.md CHANGED
@@ -345,6 +345,13 @@ It registers `page` and nothing else. `budget`, `signIn` and `deploy` keep refus
345
345
  browser's own network state and a second build id are not things a page port can answer for, and a
346
346
  fixture that silently no-opped would make the assertion after it read as proof.
347
347
 
348
+ **Real input, `As of 2026-11`.** A raw-CDP tab (`cdpE2eTab`, the `E2eTab` the framework implements)
349
+ sends trusted input the page cannot forge: `tab.touchDrag(from, to, steps)` is a finger
350
+ (`Input.dispatchTouchEvent`, touch emulation on once per tab) and `tab.press(key)` a key
351
+ (`Input.dispatchKeyEvent`, so Tab really moves focus) — a key from `PRESS_KEYS`, a letter or a digit.
352
+ A touch `PointerEvent` dispatched from page script is refused by `setPointerCapture`, so a drag
353
+ proven that way proves nothing; `TouchPoint` is the `{ x, y }` both ends take.
354
+
348
355
  **A browser call that is never answered says why.** `X_CDP_TIMEOUT` from the connection carries
349
356
  `meta.reading` — `target-gone` (session detached, target destroyed or crashed), `lost-in-transport`
350
357
  (`meta.framesDropped` frames arrived unparseable after the call) or `no-answer` — beside
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/testing",
3
- "version": "31.25.0",
3
+ "version": "31.26.0",
4
4
  "description": "Test harness: cloned template DBs per worker, frozen clock, sealed network, 6 test types",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -47,26 +47,26 @@
47
47
  "test": "bun test"
48
48
  },
49
49
  "dependencies": {
50
- "@ultimat3/action": "31.25.0",
51
- "@ultimat3/ai": "31.25.0",
52
- "@ultimat3/auth": "31.25.0",
53
- "@ultimat3/cache": "31.25.0",
54
- "@ultimat3/core": "31.25.0",
55
- "@ultimat3/db": "31.25.0",
56
- "@ultimat3/entity": "31.25.0",
57
- "@ultimat3/http": "31.25.0",
58
- "@ultimat3/i18n": "31.25.0",
59
- "@ultimat3/jobs": "31.25.0",
60
- "@ultimat3/mail": "31.25.0",
61
- "@ultimat3/notify": "31.25.0",
62
- "@ultimat3/policy": "31.25.0",
63
- "@ultimat3/pwa": "31.25.0",
64
- "@ultimat3/query": "31.25.0",
65
- "@ultimat3/realtime": "31.25.0",
66
- "@ultimat3/render": "31.25.0",
67
- "@ultimat3/schema": "31.25.0",
68
- "@ultimat3/scraping": "31.25.0",
69
- "@ultimat3/seo": "31.25.0",
70
- "@ultimat3/time": "31.25.0"
50
+ "@ultimat3/action": "31.26.0",
51
+ "@ultimat3/ai": "31.26.0",
52
+ "@ultimat3/auth": "31.26.0",
53
+ "@ultimat3/cache": "31.26.0",
54
+ "@ultimat3/core": "31.26.0",
55
+ "@ultimat3/db": "31.26.0",
56
+ "@ultimat3/entity": "31.26.0",
57
+ "@ultimat3/http": "31.26.0",
58
+ "@ultimat3/i18n": "31.26.0",
59
+ "@ultimat3/jobs": "31.26.0",
60
+ "@ultimat3/mail": "31.26.0",
61
+ "@ultimat3/notify": "31.26.0",
62
+ "@ultimat3/policy": "31.26.0",
63
+ "@ultimat3/pwa": "31.26.0",
64
+ "@ultimat3/query": "31.26.0",
65
+ "@ultimat3/realtime": "31.26.0",
66
+ "@ultimat3/render": "31.26.0",
67
+ "@ultimat3/schema": "31.26.0",
68
+ "@ultimat3/scraping": "31.26.0",
69
+ "@ultimat3/seo": "31.26.0",
70
+ "@ultimat3/time": "31.26.0"
71
71
  }
72
72
  }
@@ -3,8 +3,8 @@
3
3
  // condition, the init scripts, the socket and request log. Launching is `cdp-launch.ts` and the
4
4
  // wire is `cdp-connection.ts`.
5
5
  //
6
- // FIVE methods, which is the whole reason this exists next to `@ultimat3/scraping` rather than
7
- // through it: `ScrapePage` is a full scraping surface whose intended implementation is
6
+ // A handful of methods — and a real finger (`touchDrag`) and key (`press`) — which is why this sits
7
+ // next to `@ultimat3/scraping` rather than going through it: `ScrapePage` is a full scraping surface whose intended implementation is
8
8
  // `puppeteer-core`, and an e2e driver needs none of it.
9
9
 
10
10
  import type { CdpConnection } from '@ultimat3/scraping/cdp';
@@ -70,6 +70,19 @@ export interface E2eTab extends E2eBrowserPage {
70
70
  * dispatches straight at the element and can never see that.
71
71
  */
72
72
  pointerClick(selector: string): Promise<void>;
73
+ /**
74
+ * A REAL finger (`Input.dispatchTouchEvent`, touch emulation on for the tab the first time): a
75
+ * start at `from`, `steps` moves to `to`, an end, in viewport CSS px. Trusted input, so the
76
+ * browser hit-tests it, honours `touch-action`, and may take it for a scroll and send
77
+ * `pointercancel` — what a page-dispatched touch PointerEvent can never show (no active pointer).
78
+ */
79
+ touchDrag(from: TouchPoint, to: TouchPoint, steps?: number): Promise<void>;
80
+ /**
81
+ * A REAL key press (`Input.dispatchKeyEvent`, down then up) at whatever has focus, so its default
82
+ * action runs: Tab moves focus, which a dispatched `KeyboardEvent` never does. A name in
83
+ * `PRESS_KEYS` or one printable character.
84
+ */
85
+ press(key: string): Promise<void>;
73
86
  /** Required on a tab: the audit of every `e2eTest` reads it (`e2e-a11y-run.ts`). */
74
87
  accessibilityTree(request: AxTreeRequest): Promise<readonly AxTreeNode[]>;
75
88
  /** Reload and wait for the load, at the url the tab already had. */
@@ -81,6 +94,52 @@ export interface E2eTab extends E2eBrowserPage {
81
94
  close(): Promise<void>;
82
95
  }
83
96
 
97
+ /** A viewport point in CSS px, as `getBoundingClientRect()` answers it. */
98
+ export interface TouchPoint {
99
+ readonly x: number;
100
+ readonly y: number;
101
+ }
102
+
103
+ /** Named keys `press()` knows, with the Windows virtual key code Chrome routes them by. */
104
+ export const PRESS_KEYS: Readonly<Record<string, number>> = {
105
+ Tab: 9,
106
+ Enter: 13,
107
+ Escape: 27,
108
+ ' ': 32,
109
+ PageUp: 33,
110
+ PageDown: 34,
111
+ End: 35,
112
+ Home: 36,
113
+ ArrowLeft: 37,
114
+ ArrowUp: 38,
115
+ ArrowRight: 39,
116
+ ArrowDown: 40,
117
+ Backspace: 8,
118
+ Delete: 46,
119
+ };
120
+
121
+ /** The key code of a printable character: its upper-case code point for a letter or digit. */
122
+ const charCode = (key: string): number | undefined =>
123
+ key.length === 1 && /[a-z0-9]/i.test(key) ? key.toUpperCase().charCodeAt(0) : undefined;
124
+
125
+ /**
126
+ * The text a key TYPES, as puppeteer's key table has it. A key with text goes down as `keyDown`
127
+ * carrying it, so Chrome raises the character event — what makes Enter submit a focused button's
128
+ * form. A key with none (Tab, the arrows) goes down as `rawKeyDown`.
129
+ */
130
+ const typedText = (key: string): string | undefined =>
131
+ key === 'Enter' ? '\r' : key.length === 1 ? key : undefined;
132
+
133
+ /** `KeyboardEvent.code`: `KeyA`, `Digit7`, `Space`; a named key is its own code. */
134
+ const keyCodeName = (key: string): string =>
135
+ key === ' '
136
+ ? 'Space'
137
+ : /^[a-z]$/i.test(key)
138
+ ? `Key${key.toUpperCase()}`
139
+ : /^[0-9]$/.test(key)
140
+ ? `Digit${key}`
141
+ : key;
142
+
84
143
  export interface CdpE2eTabOptions {
85
144
  readonly connection: CdpConnection;
86
145
  /** The attached tab's flattened session — every page call carries it. */
@@ -135,6 +194,8 @@ export function cdpE2eTab(options: CdpE2eTabOptions): E2eTab {
135
194
  // url is tracked here. Seeded with the tab's own starting url rather than '' so a `reload()`
136
195
  // before any `goto()` navigates somewhere real.
137
196
  let current = 'about:blank';
197
+ // Touch emulation is per tab and stays on: switched on by the first `touchDrag`, once.
198
+ let touchOn = false;
138
199
 
139
200
  const evaluateRaw = (expression: string) =>
140
201
  send('Runtime.evaluate', { expression, returnByValue: true, awaitPromise: true }, sessionId);
@@ -304,6 +365,55 @@ export function cdpE2eTab(options: CdpE2eTabOptions): E2eTab {
304
365
  );
305
366
  }
306
367
  },
368
+ async touchDrag(from: TouchPoint, to: TouchPoint, steps = 5): Promise<void> {
369
+ if (!Number.isInteger(steps) || steps < 1) {
370
+ throw new CdpCallFailedError({
371
+ method: `touchDrag(steps: ${String(steps)})`,
372
+ detail: 'steps is the number of moves, a whole number of at least 1',
373
+ });
374
+ }
375
+ if (!touchOn) {
376
+ await send(
377
+ 'Emulation.setTouchEmulationEnabled',
378
+ { enabled: true, maxTouchPoints: 1 },
379
+ sessionId,
380
+ );
381
+ touchOn = true;
382
+ }
383
+ const touch = (type: string, points: readonly TouchPoint[]) =>
384
+ send(
385
+ 'Input.dispatchTouchEvent',
386
+ { type, touchPoints: points.map((p) => ({ x: p.x, y: p.y })) },
387
+ sessionId,
388
+ );
389
+ await touch('touchStart', [from]);
390
+ for (let step = 1; step <= steps; step += 1) {
391
+ const at = (a: number, b: number): number => a + ((b - a) * step) / steps;
392
+ await touch('touchMove', [{ x: at(from.x, to.x), y: at(from.y, to.y) }]);
393
+ }
394
+ await touch('touchEnd', []);
395
+ },
396
+ async press(key: string): Promise<void> {
397
+ const code = (Object.hasOwn(PRESS_KEYS, key) ? PRESS_KEYS[key] : undefined) ?? charCode(key);
398
+ if (code === undefined) {
399
+ throw new CdpCallFailedError({
400
+ method: `press(${key})`,
401
+ detail: `not a key press() knows: one of ${Object.keys(PRESS_KEYS).join(', ')}, or one letter or digit`,
402
+ });
403
+ }
404
+ const text = typedText(key);
405
+ const common = { key, code: keyCodeName(key), windowsVirtualKeyCode: code };
406
+ await send(
407
+ 'Input.dispatchKeyEvent',
408
+ {
409
+ type: text === undefined ? 'rawKeyDown' : 'keyDown',
410
+ ...common,
411
+ ...(text === undefined ? {} : { text }),
412
+ },
413
+ sessionId,
414
+ );
415
+ await send('Input.dispatchKeyEvent', { type: 'keyUp', ...common }, sessionId);
416
+ },
307
417
  offline: (enabled: boolean) => options.offline(enabled),
308
418
  async accessibilityTree(request: AxTreeRequest): Promise<readonly AxTreeNode[]> {
309
419
  const nodes = toAxTreeNodes((await send(FULL_AX_TREE, {}, sessionId)).result);
@@ -0,0 +1,226 @@
1
+ // The module-scope declaration tables `registry-snapshot.ts` does not hold, put back at the file
2
+ // boundary to what the file's body inherited: realtime's channels and `@ultimat3/mcp`'s declared
3
+ // remote servers and served recipes. Each is read through the module cache, never imported — an
4
+ // unloaded package has nothing to restore, and `testing` does not depend on `@ultimat3/mcp`.
5
+
6
+ import type {
7
+ AuthenticatorOptions,
8
+ configureAuthenticator,
9
+ configuredAuthenticator,
10
+ configuredCredentialTtlMs,
11
+ resetAuthenticator,
12
+ } from '@ultimat3/http';
13
+ import type { Channel } from '@ultimat3/realtime';
14
+ import type { RouteSnapshot, restoreRoutes, routeSnapshot } from '@ultimat3/render';
15
+ import { loaded } from './per-test-reset';
16
+
17
+ /** One table: where it lives, how to read it, and the exact restore its owner publishes. */
18
+ export interface DeclarationTable {
19
+ /** `<package>/<file under src>` — the row `process-registries.test.ts` holds to the source. */
20
+ readonly owner: string;
21
+ /** `undefined` while the owner is unloaded. */
22
+ capture(): unknown;
23
+ /** Called with a defined snapshot only. */
24
+ restore(snapshot: unknown): void;
25
+ }
26
+
27
+ interface ChannelModule {
28
+ readonly registeredChannels: () => readonly Channel[];
29
+ readonly restoreChannels: (declared: readonly Channel[]) => void;
30
+ }
31
+
32
+ interface RouteModule {
33
+ readonly routeSnapshot: typeof routeSnapshot;
34
+ readonly restoreRoutes: typeof restoreRoutes;
35
+ }
36
+
37
+ /** `@ultimat3/ai`'s catalogue, restated: `ai` is reached dynamically only, never type-imported. */
38
+ interface ModelModule {
39
+ readonly registeredModels: () => readonly unknown[];
40
+ readonly restoreModels: (specs: readonly unknown[]) => void;
41
+ }
42
+
43
+ interface HooksModule {
44
+ readonly configureAuthenticator: typeof configureAuthenticator;
45
+ readonly configuredAuthenticator: typeof configuredAuthenticator;
46
+ readonly configuredCredentialTtlMs: typeof configuredCredentialTtlMs;
47
+ readonly resetAuthenticator: typeof resetAuthenticator;
48
+ }
49
+
50
+ interface AuthenticatorSlot {
51
+ readonly authenticate: ReturnType<typeof configuredAuthenticator>;
52
+ readonly ttl: number | undefined;
53
+ }
54
+
55
+ /** `@ultimat3/mcp`'s shapes, restated: `testing` neither depends on nor type-imports the package. */
56
+ interface RecipeModule {
57
+ readonly servedRecipes: () => ReadonlySet<string>;
58
+ readonly resetServedRecipes: () => void;
59
+ readonly noteServedRecipes: (names: readonly string[]) => void;
60
+ }
61
+ /** `@ultimat3/storage`'s registry, restated: `testing` does not depend on the package. */
62
+ interface StorageModule {
63
+ readonly definedStorage: () => unknown;
64
+ readonly resetStorage: () => void;
65
+ }
66
+
67
+ interface RemoteModule {
68
+ readonly declaredMcpServers: () => ReadonlyMap<string, unknown>;
69
+ readonly restoreDeclaredMcpServers: (servers: ReadonlyMap<string, unknown>) => void;
70
+ }
71
+
72
+ const found = new Map<string, string>();
73
+
74
+ /**
75
+ * A loaded module whose path ends in `suffix` and that exports every name in `shape`. For a
76
+ * package `testing` cannot resolve (not a dependency): the cache is scanned until it is seen,
77
+ * then the path is kept. The shape check is what keeps an app's own `packages/mcp/src/` out.
78
+ */
79
+ function cachedModule<M>(suffix: string, shape: readonly string[]): M | undefined {
80
+ const known = found.get(suffix);
81
+ if (known !== undefined) return require.cache[known]?.exports as M | undefined;
82
+ for (const [path, entry] of Object.entries(require.cache)) {
83
+ if (!path.replaceAll('\\', '/').endsWith(suffix)) continue;
84
+ const exports = entry?.exports as Record<string, unknown> | undefined;
85
+ if (exports === undefined || !shape.every((name) => typeof exports[name] === 'function')) {
86
+ continue;
87
+ }
88
+ found.set(suffix, path);
89
+ return exports as M;
90
+ }
91
+ return undefined;
92
+ }
93
+
94
+ const channelModule = (): ChannelModule | undefined => {
95
+ const path = loaded('@ultimat3/realtime', 'channel-registry.ts');
96
+ return path === undefined ? undefined : (require(path) as ChannelModule);
97
+ };
98
+
99
+ const routeModule = (): RouteModule | undefined => {
100
+ const path = loaded('@ultimat3/render', 'registry.ts');
101
+ return path === undefined ? undefined : (require(path) as RouteModule);
102
+ };
103
+
104
+ const modelModule = (): ModelModule | undefined => {
105
+ const path = loaded('@ultimat3/ai', 'models.ts');
106
+ return path === undefined ? undefined : (require(path) as ModelModule);
107
+ };
108
+
109
+ const hooksModule = (): HooksModule | undefined => {
110
+ const path = loaded('@ultimat3/http', 'hooks.ts');
111
+ return path === undefined ? undefined : (require(path) as HooksModule);
112
+ };
113
+
114
+ const STORAGE_SHAPE = ['definedStorage', 'defineStorage', 'resetStorage'] as const;
115
+ const storageModule = (): StorageModule | undefined =>
116
+ cachedModule<StorageModule>('/storage/src/storage.ts', STORAGE_SHAPE);
117
+
118
+ const RECIPE_SHAPE = ['servedRecipes', 'resetServedRecipes', 'noteServedRecipes'] as const;
119
+ const REMOTE_SHAPE = ['declaredMcpServers', 'restoreDeclaredMcpServers'] as const;
120
+ const recipeModule = (): RecipeModule | undefined =>
121
+ cachedModule<RecipeModule>('/mcp/src/recipe-links.ts', RECIPE_SHAPE);
122
+ const remoteModule = (): RemoteModule | undefined =>
123
+ cachedModule<RemoteModule>('/mcp/src/remote-tools.ts', REMOTE_SHAPE);
124
+
125
+ /** Every table the boundary restores. A new module-scope registry joins here, with its restore. */
126
+ export const DECLARATION_TABLES: readonly DeclarationTable[] = [
127
+ {
128
+ // One file's `site/` route was a later fixture app's `budgets` red (`X_STYLES_GLOBAL_MISSING`
129
+ // in `mcp-host-tools.test.ts`): `documentSurfaces()` reads the whole route table.
130
+ owner: '@ultimat3/render/registry.ts',
131
+ capture: () => routeModule()?.routeSnapshot(),
132
+ restore: (snapshot) => routeModule()?.restoreRoutes(snapshot as RouteSnapshot),
133
+ },
134
+ {
135
+ owner: '@ultimat3/ai/models.ts',
136
+ capture: () => modelModule()?.registeredModels(),
137
+ restore: (snapshot) => modelModule()?.restoreModels(snapshot as readonly unknown[]),
138
+ },
139
+ {
140
+ // A slot, not a table: one file's `configureAuthenticator` answered every later file's socket
141
+ // upgrade with its resolver — `role-sync-dev-origin.test.ts` read 401 where it wanted 101.
142
+ owner: '@ultimat3/http/hooks.ts',
143
+ capture: (): AuthenticatorSlot | undefined => {
144
+ const module = hooksModule();
145
+ return module === undefined
146
+ ? undefined
147
+ : {
148
+ authenticate: module.configuredAuthenticator(),
149
+ ttl: module.configuredCredentialTtlMs(),
150
+ };
151
+ },
152
+ restore: (snapshot) => {
153
+ const module = hooksModule();
154
+ if (module === undefined) return;
155
+ const { authenticate, ttl } = snapshot as AuthenticatorSlot;
156
+ if (authenticate === undefined) return module.resetAuthenticator();
157
+ const options: AuthenticatorOptions = ttl === undefined ? {} : { credentialTtlMs: ttl };
158
+ module.configureAuthenticator(authenticate, options);
159
+ },
160
+ },
161
+ {
162
+ // A slot with a reset and no setter: a body that installed storage over NONE is undone; one
163
+ // that replaced an inherited registry cannot be put back and is left (no exact writer exists).
164
+ // One file's `defineStorage({ disks: { assets } })` was every later boot's `appDeclared()`.
165
+ owner: '@ultimat3/storage/storage.ts',
166
+ capture: () => {
167
+ const module = storageModule();
168
+ return module === undefined ? undefined : { storage: module.definedStorage() };
169
+ },
170
+ restore: (snapshot) => {
171
+ const module = storageModule();
172
+ if (module === undefined) return;
173
+ if ((snapshot as { readonly storage: unknown }).storage === undefined) module.resetStorage();
174
+ },
175
+ },
176
+ {
177
+ owner: '@ultimat3/realtime/channel-registry.ts',
178
+ capture: () => channelModule()?.registeredChannels(),
179
+ restore: (snapshot) => {
180
+ const module = channelModule();
181
+ if (module !== undefined) module.restoreChannels(snapshot as readonly Channel[]);
182
+ },
183
+ },
184
+ {
185
+ owner: '@ultimat3/mcp/recipe-links.ts',
186
+ capture: () => {
187
+ const served = recipeModule()?.servedRecipes();
188
+ return served === undefined ? undefined : [...served];
189
+ },
190
+ restore: (snapshot) => {
191
+ const module = recipeModule();
192
+ if (module === undefined) return;
193
+ module.resetServedRecipes();
194
+ module.noteServedRecipes(snapshot as readonly string[]);
195
+ },
196
+ },
197
+ {
198
+ owner: '@ultimat3/mcp/remote-tools.ts',
199
+ capture: () => {
200
+ const declared = remoteModule()?.declaredMcpServers();
201
+ return declared === undefined ? undefined : new Map(declared);
202
+ },
203
+ restore: (snapshot) => {
204
+ const module = remoteModule();
205
+ if (module === undefined) return;
206
+ module.restoreDeclaredMcpServers(snapshot as ReadonlyMap<string, unknown>);
207
+ },
208
+ },
209
+ ];
210
+
211
+ /** Each table's contents now, in `DECLARATION_TABLES` order; `undefined` for an unloaded owner. */
212
+ export function captureDeclarationTables(): readonly unknown[] {
213
+ return DECLARATION_TABLES.map((table) => table.capture());
214
+ }
215
+
216
+ /**
217
+ * Exactly `snapshots` again. A table whose owner was not loaded at the capture is left alone: what
218
+ * it holds was declared by a module this file loaded lazily, at module scope — a cached module
219
+ * never declares again, so taking it away would cost every later file that imports it.
220
+ */
221
+ export function restoreDeclarationTables(snapshots: readonly unknown[]): void {
222
+ DECLARATION_TABLES.forEach((table, index) => {
223
+ const snapshot = snapshots[index];
224
+ if (snapshot !== undefined) table.restore(snapshot);
225
+ });
226
+ }
package/src/e2e-driver.ts CHANGED
@@ -35,19 +35,15 @@ const refuse =
35
35
  Promise.reject(new FixtureUnavailableError({ name, needs }));
36
36
 
37
37
  /**
38
- * `offline()`/`online()` FORWARD, `As of 2026-08-27`. They refused until then on a reason the tree
39
- * contradicted on the day it was written: this file said `CdpPageLike`
40
- * (`packages/scraping/src/cdp-port.ts`) "declares twelve methods and none of them is
41
- * `setOfflineMode`". It declares it at line 71 — optional, guarded, with a coded
42
- * `X_NOT_IMPLEMENTED` in `cdp-target.ts` for a launcher that lacks it — and `page-over-target.ts`
43
- * exposes it as `ScrapePage.offline()`. All of that landed in **the same commit as the comment**
44
- * (#351), so the refusal was never true, and it is the reason issue #390 records a real browser
45
- * check as out of reach.
38
+ * `offline()`/`online()` FORWARD, `As of 2026-08-27`, to `ScrapePage.offline()`
39
+ * (`page-over-target.ts`), which reaches `CdpPageLike.setOfflineMode` — checked when the session
40
+ * opens (scraping's `cdp-complete.ts`), so a driver that lacks it is refused there, never at the
41
+ * first `offline()`. Issue #390 recorded a real browser check as out of reach on a refusal that
42
+ * was never true (#351).
46
43
  *
47
- * Optional on `E2eBrowserPage` rather than required, for the reason `CdpPageLike` gives about the
48
- * same method: this port is the shape of somebody ELSE's object, and a six-line test double must
49
- * still satisfy it. Absent, the refusal stands — and now it names the method the double is missing
50
- * rather than a capability the framework does not have.
44
+ * Optional on `E2eBrowserPage` all the same: this port is the shape of somebody ELSE's object, and
45
+ * a six-line test double must still satisfy it. Absent, the fixture refuses by name — naming the
46
+ * method the double is missing rather than a capability the framework does not have.
51
47
  */
52
48
  const networkFixtures = (browser: E2eBrowserPage): Pick<E2eFixtures, 'offline' | 'online'> => {
53
49
  const setOffline = browser.offline?.bind(browser);
package/src/e2e-page.ts CHANGED
@@ -22,14 +22,14 @@ export interface E2eBrowserPage {
22
22
  click(selector: string): Promise<void>;
23
23
  /**
24
24
  * The browser's own network condition, which `E2eFixtures.offline()`/`online()` forward to.
25
- * `ScrapePage` has it (`page-over-target.ts`), reaching `CdpPageLike.setOfflineMode` through
26
- * `cdp-target.ts`'s guard.
25
+ * `ScrapePage` has it (`page-over-target.ts`), over `CdpPageLike.setOfflineMode` — checked when
26
+ * the session opens (scraping's `cdp-complete.ts`).
27
27
  *
28
- * OPTIONAL for the reason the four above are structural: this port is the shape of somebody
28
+ * OPTIONAL here for the reason the four above are structural: this port is the shape of somebody
29
29
  * ELSE's object, and requiring it would cost every six-line double a type error for a capability
30
- * a test that never goes offline does not need. Absent, `e2e-driver.ts` keeps refusing by name —
31
- * a coded refusal, never a silent no-op, because an `offline()` that did nothing would let the
32
- * app's ONLINE page pass an offline test.
30
+ * a test that never goes offline does not need. Absent, `e2e-driver.ts` refuses by name — a coded
31
+ * refusal, never a silent no-op, because an `offline()` that did nothing would let the app's
32
+ * ONLINE page pass an offline test.
33
33
  */
34
34
  offline?(enabled: boolean): Promise<void>;
35
35
  /**
@@ -34,6 +34,9 @@ export function clearPersister(): void {
34
34
 
35
35
  export const persisterInstalled = (): boolean => current !== undefined;
36
36
 
37
+ /** The installed persister itself: what the registry guard's file boundary hands back. */
38
+ export const installedPersister = (): Persister | undefined => current;
39
+
37
40
  /** Install for one run and hand back what was there: the factory lint's own throwaway writer. */
38
41
  export function swapPersister(next: Persister | undefined): Persister | undefined {
39
42
  const previous = current;
package/src/index.ts CHANGED
@@ -45,8 +45,8 @@ export {
45
45
  } from './cdp-browser';
46
46
  export type { E2eBrowserLease, RunEndHook } from './cdp-browser-lease';
47
47
  export { closeE2eBrowsersAtRunEnd, leaseE2eBrowser } from './cdp-browser-lease';
48
- export type { CdpE2eTabOptions, E2eTab } from './cdp-e2e-page';
49
- export { cdpE2eTab } from './cdp-e2e-page';
48
+ export type { CdpE2eTabOptions, E2eTab, TouchPoint } from './cdp-e2e-page';
49
+ export { cdpE2eTab, PRESS_KEYS } from './cdp-e2e-page';
50
50
  export type { CdpE2eSessionOptions, E2eSession } from './cdp-e2e-session';
51
51
  export { cdpE2eSession } from './cdp-e2e-session';
52
52
  // The exercise pass (plan 101 / 40, phase 2): an app's per-primitive overrides — 39's
@@ -8,8 +8,10 @@ import { knownTags, registeredTiers } from '@ultimat3/cache';
8
8
  import { configureLocales } from '@ultimat3/i18n';
9
9
  import { captureAdminMounts, restoreAdminMounts } from './admin-mount-boundary';
10
10
  import { isAppRoot } from './app-root';
11
+ import { captureDeclarationTables, restoreDeclarationTables } from './declaration-boundary';
11
12
  import { captureDriverStores, restoreDriverStores } from './driver-store-boundary';
12
13
  import { RegistryLeakError } from './errors';
14
+ import { installedPersister, swapPersister } from './factory-persist';
13
15
  import { runBoundaryHooks, runFileBoundary } from './file-boundary';
14
16
  import { type ImportGraph, importGraphReader } from './import-graph';
15
17
  import { ownEnvironment } from './registry-environment';
@@ -167,6 +169,8 @@ export function installRegistryLeakGuard(): void {
167
169
  before: RegistrySample | undefined;
168
170
  readonly snapshot: ProcessRegistrySnapshot;
169
171
  readonly admins: ReturnType<typeof captureAdminMounts>;
172
+ readonly tables: ReturnType<typeof captureDeclarationTables>;
173
+ readonly persister: ReturnType<typeof installedPersister>;
170
174
  }
171
175
  | undefined;
172
176
  const leaks: RegistryLeak[] = [];
@@ -232,6 +236,12 @@ export function installRegistryLeakGuard(): void {
232
236
  // whose drift step then read its fixture app as "a store that owns its own schema".
233
237
  restoreDriverStores(preloadStores);
234
238
  restoreAdminMounts(current.admins);
239
+ // The framework repository's own suites only: in an app these tables hold what `loadApp()`
240
+ // registered once for the worker's life (routes, the authenticator, storage, channels), and a
241
+ // module the cache will not evaluate again cannot put them back for the next file.
242
+ if (!inApp) restoreDeclarationTables(current.tables);
243
+ // A preload's `usePersister` is in every body's start; a file's own `factoryWorld()` is not.
244
+ swapPersister(current.persister);
235
245
  accumulated = mergeSnapshots(accumulated, restored);
236
246
  lastBoundary = restored;
237
247
  current = undefined;
@@ -281,6 +291,8 @@ export function installRegistryLeakGuard(): void {
281
291
  before: undefined,
282
292
  snapshot: narrowed(live, accumulated),
283
293
  admins: captureAdminMounts(),
294
+ tables: captureDeclarationTables(),
295
+ persister: installedPersister(),
284
296
  };
285
297
  pending = undefined;
286
298
  };
@@ -75,7 +75,7 @@ export const SCRAPE_FRAME_CHECKS: readonly ScrapeDriverCheck[] = [
75
75
  },
76
76
  },
77
77
  {
78
- name: 'accessibility() answers the computed role and name, or is refused X_NOT_IMPLEMENTED',
78
+ name: 'accessibility() answers the computed role and name, on every driver',
79
79
  async run({ page }) {
80
80
  await page.goto(SCRAPE_CONFORMANCE_URLS.search);
81
81
  // Screened before any driver is asked, whichever kind this is.
@@ -83,12 +83,6 @@ export const SCRAPE_FRAME_CHECKS: readonly ScrapeDriverCheck[] = [
83
83
  'X_INVARIANT',
84
84
  );
85
85
  expect(await codeOf(() => page.accessibility('#go', { max: 0 }))).toBe('X_INVARIANT');
86
- const refused = await codeOf(() => page.accessibility('#go'));
87
- if (refused !== undefined) {
88
- // An offline driver refuses rather than reading `role=` off the markup and inventing one.
89
- expect(refused).toBe('X_NOT_IMPLEMENTED');
90
- return;
91
- }
92
86
  expect(await page.accessibility('#go')).toMatchObject([
93
87
  { role: 'button', name: 'Run search' },
94
88
  ]);
@@ -98,14 +98,10 @@ export const SCRAPE_PAGE_CHECKS: readonly ScrapeDriverCheck[] = [
98
98
  },
99
99
  },
100
100
  {
101
- name: 'offline(true) cuts the browser off or is refused X_NOT_IMPLEMENTED — never a no-op',
101
+ name: 'offline(true) cuts the browser off — answered by every driver, never a no-op',
102
102
  async run({ page }) {
103
103
  await page.goto(SCRAPE_CONFORMANCE_URLS.orders);
104
- const refused = await codeOf(() => page.offline(true));
105
- if (refused !== undefined) {
106
- expect(refused).toBe('X_NOT_IMPLEMENTED');
107
- return;
108
- }
104
+ expect(await codeOf(() => page.offline(true))).toBeUndefined();
109
105
  // Set: then the browser must actually fail a navigation, or a test proved nothing offline.
110
106
  expect(await codeOf(() => page.goto(SCRAPE_CONFORMANCE_URLS.second))).not.toBeUndefined();
111
107
  await page.offline(false);