@ultimat3/testing 31.40.1 → 31.42.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/package.json +22 -22
- package/src/cdp-browser.ts +7 -1
- package/src/errors.ts +2 -0
- package/src/fixture-island.ts +27 -3
- package/src/island-errors.ts +16 -0
- package/src/island-state-mount.ts +7 -5
- package/src/registry-leak-guard.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/testing",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.42.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,27 +47,27 @@
|
|
|
47
47
|
"test": "bun test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@ultimat3/action": "31.
|
|
51
|
-
"@ultimat3/ai": "31.
|
|
52
|
-
"@ultimat3/auth": "31.
|
|
53
|
-
"@ultimat3/cache": "31.
|
|
54
|
-
"@ultimat3/core": "31.
|
|
55
|
-
"@ultimat3/db": "31.
|
|
56
|
-
"@ultimat3/entity": "31.
|
|
57
|
-
"@ultimat3/http": "31.
|
|
58
|
-
"@ultimat3/i18n": "31.
|
|
59
|
-
"@ultimat3/jobs": "31.
|
|
60
|
-
"@ultimat3/mail": "31.
|
|
61
|
-
"@ultimat3/notify": "31.
|
|
62
|
-
"@ultimat3/policy": "31.
|
|
63
|
-
"@ultimat3/pwa": "31.
|
|
64
|
-
"@ultimat3/query": "31.
|
|
65
|
-
"@ultimat3/realtime": "31.
|
|
66
|
-
"@ultimat3/render": "31.
|
|
67
|
-
"@ultimat3/schema": "31.
|
|
68
|
-
"@ultimat3/scraping": "31.
|
|
69
|
-
"@ultimat3/seo": "31.
|
|
70
|
-
"@ultimat3/time": "31.
|
|
50
|
+
"@ultimat3/action": "31.42.0",
|
|
51
|
+
"@ultimat3/ai": "31.42.0",
|
|
52
|
+
"@ultimat3/auth": "31.42.0",
|
|
53
|
+
"@ultimat3/cache": "31.42.0",
|
|
54
|
+
"@ultimat3/core": "31.42.0",
|
|
55
|
+
"@ultimat3/db": "31.42.0",
|
|
56
|
+
"@ultimat3/entity": "31.42.0",
|
|
57
|
+
"@ultimat3/http": "31.42.0",
|
|
58
|
+
"@ultimat3/i18n": "31.42.0",
|
|
59
|
+
"@ultimat3/jobs": "31.42.0",
|
|
60
|
+
"@ultimat3/mail": "31.42.0",
|
|
61
|
+
"@ultimat3/notify": "31.42.0",
|
|
62
|
+
"@ultimat3/policy": "31.42.0",
|
|
63
|
+
"@ultimat3/pwa": "31.42.0",
|
|
64
|
+
"@ultimat3/query": "31.42.0",
|
|
65
|
+
"@ultimat3/realtime": "31.42.0",
|
|
66
|
+
"@ultimat3/render": "31.42.0",
|
|
67
|
+
"@ultimat3/schema": "31.42.0",
|
|
68
|
+
"@ultimat3/scraping": "31.42.0",
|
|
69
|
+
"@ultimat3/seo": "31.42.0",
|
|
70
|
+
"@ultimat3/time": "31.42.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"solid-js": "^1.9.18"
|
package/src/cdp-browser.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { LaunchedBrowser } from '@ultimat3/scraping/cdp';
|
|
|
12
12
|
import {
|
|
13
13
|
CdpBrowserMissingError,
|
|
14
14
|
CHROME_CANDIDATES,
|
|
15
|
+
CHROME_RESTRICTED_PORTS,
|
|
15
16
|
findChrome,
|
|
16
17
|
LAUNCH_BUDGET_MS,
|
|
17
18
|
launchChrome,
|
|
@@ -134,7 +135,12 @@ async function openLaunched(
|
|
|
134
135
|
timeoutMs: number,
|
|
135
136
|
acceptLanguage: string | undefined,
|
|
136
137
|
): Promise<E2eBrowser> {
|
|
137
|
-
|
|
138
|
+
// The e2e browser loads pages its own tests serve on `port: 0`, which may be a port Chrome refuses.
|
|
139
|
+
const launched = await launchChrome({
|
|
140
|
+
executable,
|
|
141
|
+
timeoutMs,
|
|
142
|
+
allowedPorts: CHROME_RESTRICTED_PORTS,
|
|
143
|
+
});
|
|
138
144
|
const { connection } = launched;
|
|
139
145
|
try {
|
|
140
146
|
const session = await cdpE2eSession({
|
package/src/errors.ts
CHANGED
|
@@ -82,6 +82,7 @@ export const TESTING_ERROR_CODES = [
|
|
|
82
82
|
'X_TEST_PROPERTY_FAILED',
|
|
83
83
|
'X_TEST_SOAK_HEAP_GROWTH',
|
|
84
84
|
'X_TEST_TEMP_TREE_LEFT',
|
|
85
|
+
'X_TEST_ISLAND_BUILD_REUSED',
|
|
85
86
|
] as const;
|
|
86
87
|
|
|
87
88
|
export type TestingErrorCode = (typeof TESTING_ERROR_CODES)[number];
|
|
@@ -167,6 +168,7 @@ export const TESTING_ERROR_TITLES: Readonly<Record<TestingErrorCode, string>> =
|
|
|
167
168
|
X_TEST_PROPERTY_FAILED: 'a property() run found an input its claim refuses',
|
|
168
169
|
X_TEST_SOAK_HEAP_GROWTH: 'a soak() run grew the live heap past its stated bound',
|
|
169
170
|
X_TEST_TEMP_TREE_LEFT: 'a temp tree survived its own remove',
|
|
171
|
+
X_TEST_ISLAND_BUILD_REUSED: 'an island builder answered the shipped build with the coverage one',
|
|
170
172
|
};
|
|
171
173
|
|
|
172
174
|
// Titles must be registered for `format()` to render the contract's first line. Every code above is
|
package/src/fixture-island.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { basename, join } from 'node:path';
|
|
|
8
8
|
import { onFileBoundary } from './file-boundary';
|
|
9
9
|
import { islandCoverageDir, recordChunkMap } from './fixture-island-coverage';
|
|
10
10
|
import { createIslandDocument, FakeElement, handlerFor, parseHtml } from './island-dom';
|
|
11
|
-
import { islandMountMissing, islandNotBuilt } from './island-errors';
|
|
11
|
+
import { IslandBuildReusedError, islandMountMissing, islandNotBuilt } from './island-errors';
|
|
12
12
|
import { installGlobals } from './island-globals';
|
|
13
13
|
import type { ResizeInput } from './island-observers';
|
|
14
14
|
import { deliverResize } from './island-observers';
|
|
@@ -90,7 +90,12 @@ export interface MountIslandOptions {
|
|
|
90
90
|
* one — `return render(…)`), then hands the process its globals back. Both, in that order.
|
|
91
91
|
*/
|
|
92
92
|
export interface MountedIsland extends Disposable {
|
|
93
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* The SHIPPED chunk's source — what did or did not reach the browser, and its minified size.
|
|
95
|
+
* Under the gate's coverage run (`ISLAND_COVERAGE_ENV`) the chunk that RUNS is a second,
|
|
96
|
+
* unminified build for the source map; `code` is still the shipped one, so a byte ceiling reads
|
|
97
|
+
* the same under `bun test` and `x verify`.
|
|
98
|
+
*/
|
|
94
99
|
readonly code: string;
|
|
95
100
|
/** The host element `mount` was given. */
|
|
96
101
|
readonly el: FakeElement;
|
|
@@ -203,6 +208,21 @@ export function disposeLiveIslands(): number {
|
|
|
203
208
|
// guard that runs the boundary, and a mount a file forgot is one only this module can see.
|
|
204
209
|
onFileBoundary(disposeLiveIslands);
|
|
205
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The shipped chunk's source, asked of the builder a second time under a coverage run. The SAME
|
|
213
|
+
* bundle back is a memo that ignored `options` (`X_TEST_ISLAND_BUILD_REUSED`); a builder that
|
|
214
|
+
* ignores `coverage` altogether answers a fresh bundle and its chunk is what it is.
|
|
215
|
+
*/
|
|
216
|
+
async function shippedCode(
|
|
217
|
+
options: MountIslandOptions,
|
|
218
|
+
covered: IslandBundleLike,
|
|
219
|
+
chunk: IslandChunkLike,
|
|
220
|
+
): Promise<string> {
|
|
221
|
+
const bundle = await options.build(options.root, { only: options.file });
|
|
222
|
+
if (bundle === covered) throw new IslandBuildReusedError({ file: options.file });
|
|
223
|
+
return bundle.chunks.find((each) => each.file === options.file)?.code ?? chunk.code;
|
|
224
|
+
}
|
|
225
|
+
|
|
206
226
|
export async function mountIsland(options: MountIslandOptions): Promise<MountedIsland> {
|
|
207
227
|
// `only`, because this fixture has always KNOWN which island it wants and asked for all of them
|
|
208
228
|
// anyway — `island-bundle.ts` added the option for exactly this caller ("a test that mounts a
|
|
@@ -231,6 +251,10 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
|
|
|
231
251
|
);
|
|
232
252
|
}
|
|
233
253
|
|
|
254
|
+
// What `code` answers is what ships: a coverage build keeps whitespace for its map, and an app's
|
|
255
|
+
// size ceiling read it as the chunk (31.27–31.40: green under `bun test`, red in `x verify`).
|
|
256
|
+
const shipped = coverage === undefined ? chunk.code : await shippedCode(options, bundle, chunk);
|
|
257
|
+
|
|
234
258
|
const { documentElement, globals, resizeObservers } = createIslandDocument();
|
|
235
259
|
const restore = installGlobals({ ...globals, ...options.globals });
|
|
236
260
|
let dir: string | undefined;
|
|
@@ -298,7 +322,7 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
|
|
|
298
322
|
const resolve = (target: string | FakeElement | null | undefined): FakeElement | null =>
|
|
299
323
|
typeof target === 'string' ? el.querySelector(target) : (target ?? null);
|
|
300
324
|
return {
|
|
301
|
-
code:
|
|
325
|
+
code: shipped,
|
|
302
326
|
el,
|
|
303
327
|
documentElement,
|
|
304
328
|
find: (selector) => el.querySelector(selector),
|
package/src/island-errors.ts
CHANGED
|
@@ -80,3 +80,19 @@ export class IslandMountMissingError extends UltimateError {
|
|
|
80
80
|
|
|
81
81
|
export const islandMountMissing = (file: string, exported: readonly string[]): UltimateError =>
|
|
82
82
|
new IslandMountMissingError({ file, exported });
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Under the gate's coverage run a mount asks its builder twice — covered to run, shipped for `code`
|
|
86
|
+
* — and got the SAME bundle back: a memo round `buildIslands` that ignores `options`. Measured
|
|
87
|
+
* instead, every size ceiling would read the unminified chunk, green under `bun test` and red in
|
|
88
|
+
* `x verify`.
|
|
89
|
+
*/
|
|
90
|
+
export class IslandBuildReusedError extends UltimateError {
|
|
91
|
+
constructor(input: { file: string }) {
|
|
92
|
+
super({
|
|
93
|
+
code: 'X_TEST_ISLAND_BUILD_REUSED',
|
|
94
|
+
cause: `the builder handed ${renderCauseValue(input.file)}'s mount the same bundle for the coverage build and the shipped one, so code would be the unminified chunk`,
|
|
95
|
+
fix: 'mountIsland({ build: buildIslands, root, file }) # the builder itself (describeIslandState already builds once per file), or key your memo by options.coverage',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -38,10 +38,10 @@ export interface IslandStateSuiteOptions extends IslandStateMountOptions, TestOp
|
|
|
38
38
|
export const ISLAND_MOUNT_TIMEOUT_MS = 60_000;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Bundles already built in this process, per builder, by `<root>\0<island>`.
|
|
42
|
-
* states used to build its island three times; the source cannot change between
|
|
43
|
-
* test run, so the second is a lookup. A build that REJECTS is forgotten, so the
|
|
44
|
-
* reports its own failure rather than a cached one.
|
|
41
|
+
* Bundles already built in this process, per builder, by `<root>\0<island>\0<covered|shipped>`.
|
|
42
|
+
* A file with three states used to build its island three times; the source cannot change between
|
|
43
|
+
* two mounts of one test run, so the second is a lookup. A build that REJECTS is forgotten, so the
|
|
44
|
+
* next mount reports its own failure rather than a cached one.
|
|
45
45
|
*/
|
|
46
46
|
const bundles = new WeakMap<IslandBuilder, Map<string, Promise<IslandBundleLike>>>();
|
|
47
47
|
|
|
@@ -50,7 +50,9 @@ const buildOnce =
|
|
|
50
50
|
(root, options) => {
|
|
51
51
|
const built = bundles.get(build) ?? new Map<string, Promise<IslandBundleLike>>();
|
|
52
52
|
bundles.set(build, built);
|
|
53
|
-
|
|
53
|
+
// The coverage build and the shipped one are two bundles of one island (`mountIsland`).
|
|
54
|
+
const flavour = options?.coverage === true ? 'covered' : 'shipped';
|
|
55
|
+
const key = `${root}\0${options?.only ?? ''}\0${flavour}`;
|
|
54
56
|
const known = built.get(key);
|
|
55
57
|
if (known !== undefined) return known;
|
|
56
58
|
const pending = build(root, options);
|
|
@@ -211,7 +211,9 @@ export function installRegistryLeakGuard(): void {
|
|
|
211
211
|
// them. The framework repository's own suites keep the exact restore: many of them lean on an
|
|
212
212
|
// EMPTY permission set (no validation), and a test body's declaration must not switch it on for
|
|
213
213
|
// every later file. Tasks go back EXACTLY everywhere: one a test body registered must not fire
|
|
214
|
-
// in the next file's scheduler round.
|
|
214
|
+
// in the next file's scheduler round. Jobs go back exactly in the framework repository only: in
|
|
215
|
+
// an app, a job a lazily imported module declared is every later file's (it never declares
|
|
216
|
+
// again), and an exact restore left its queue holding a job "nothing registered" (31.25–31.40).
|
|
215
217
|
const live = captureProcessRegistries();
|
|
216
218
|
const merged = inApp ? mergeSnapshots(live, current.snapshot) : current.snapshot;
|
|
217
219
|
// Locales likewise, in one case: the file's baseline still held the framework's pristine
|
|
@@ -228,7 +230,7 @@ export function installRegistryLeakGuard(): void {
|
|
|
228
230
|
...merged,
|
|
229
231
|
locales: declaredLazily ? live.locales : current.snapshot.locales,
|
|
230
232
|
tasks: current.snapshot.tasks,
|
|
231
|
-
jobs: current.snapshot.jobs,
|
|
233
|
+
jobs: inApp ? merged.jobs : current.snapshot.jobs,
|
|
232
234
|
};
|
|
233
235
|
restoreProcessRegistries(restored);
|
|
234
236
|
// To the PRELOAD's notes, never the body's start: a store is noted as its driver is built,
|