@unframework.dev/testing 0.0.0-stage → 0.0.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/README.md +511 -2
- package/dist/browser/axe.js +34 -0
- package/dist/browser/behaviour.js +59 -0
- package/dist/browser/capabilities.js +58 -0
- package/dist/browser/clock.d.ts +17 -0
- package/dist/browser/clock.js +69 -0
- package/dist/browser/console.d.ts +27 -0
- package/dist/browser/console.js +142 -0
- package/dist/browser/determinism.js +108 -0
- package/dist/browser/element-timeout.js +28 -0
- package/dist/browser/events.js +68 -0
- package/dist/browser/geometry.js +135 -0
- package/dist/browser/keys.js +62 -0
- package/dist/browser/matchers.d.ts +39 -0
- package/dist/browser/matchers.js +78 -0
- package/dist/browser/navigation.js +38 -0
- package/dist/browser/parity.d.ts +10 -0
- package/dist/browser/parity.js +93 -0
- package/dist/browser/spec.d.ts +25 -0
- package/dist/browser/spec.js +38 -0
- package/dist/browser/target.d.ts +16 -0
- package/dist/browser/target.js +27 -0
- package/dist/browser/text-runs.js +68 -0
- package/dist/browser/thrown.js +71 -0
- package/dist/browser/trace.d.ts +21 -0
- package/dist/browser/trace.js +73 -0
- package/dist/browser/user.d.ts +45 -0
- package/dist/browser/user.js +184 -0
- package/dist/browser/view.d.ts +114 -0
- package/dist/browser/view.js +282 -0
- package/dist/browser/visual.d.ts +20 -0
- package/dist/browser/visual.js +36 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +90 -0
- package/dist/commands.d.ts +107 -0
- package/dist/config/broadcast.js +29 -0
- package/dist/config/cases.d.ts +28 -0
- package/dist/config/cases.js +94 -0
- package/dist/config/index.d.ts +81 -0
- package/dist/config/index.js +275 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +92 -0
- package/dist/dom/serialize.js +236 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +38 -0
- package/dist/harness.d.ts +184 -0
- package/dist/harness.js +53 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +12 -0
- package/dist/internal.d.ts +8 -0
- package/dist/internal.js +6 -0
- package/dist/layers.d.ts +183 -0
- package/dist/layers.js +241 -0
- package/dist/node/browser.d.ts +33 -0
- package/dist/node/browser.js +64 -0
- package/dist/node/commands.d.ts +137 -0
- package/dist/node/commands.js +139 -0
- package/dist/node/context.d.ts +28 -0
- package/dist/node/context.js +55 -0
- package/dist/node/events.d.ts +25 -0
- package/dist/node/events.js +50 -0
- package/dist/node/finished.d.ts +12 -0
- package/dist/node/finished.js +28 -0
- package/dist/node/index.d.ts +21 -0
- package/dist/node/index.js +20 -0
- package/dist/node/matrix.d.ts +219 -0
- package/dist/node/matrix.js +309 -0
- package/dist/node/mode.d.ts +101 -0
- package/dist/node/mode.js +201 -0
- package/dist/node/names.d.ts +4 -0
- package/dist/node/names.js +5 -0
- package/dist/node/policy.d.ts +44 -0
- package/dist/node/policy.js +140 -0
- package/dist/node/reporter.d.ts +101 -0
- package/dist/node/reporter.js +251 -0
- package/dist/node/summary.d.ts +99 -0
- package/dist/node/summary.js +352 -0
- package/dist/node/thrown.js +78 -0
- package/dist/node/viewport.d.ts +7 -0
- package/dist/node/viewport.js +8 -0
- package/dist/node/visual.d.ts +85 -0
- package/dist/node/visual.js +370 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/protocol.d.ts +23930 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/structs.d.ts +22 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/types.d.ts +22221 -0
- package/dist/normalize/display.js +309 -0
- package/dist/normalize/index.d.ts +34 -0
- package/dist/normalize/index.js +38 -0
- package/dist/normalize/pipeline.d.ts +19 -0
- package/dist/normalize/pipeline.js +45 -0
- package/dist/normalize/print.js +103 -0
- package/dist/normalize/rules/angular-hosts.js +53 -0
- package/dist/normalize/rules/aria-hosts.js +48 -0
- package/dist/normalize/rules/comments.js +16 -0
- package/dist/normalize/rules/control-values.js +65 -0
- package/dist/normalize/rules/engine-aliases.js +34 -0
- package/dist/normalize/rules/framework-attributes.js +85 -0
- package/dist/normalize/rules/generated-ids.js +64 -0
- package/dist/normalize/rules/ordering.js +39 -0
- package/dist/normalize/rules/qwik-styles.js +21 -0
- package/dist/normalize/rules/qwik-templates.js +20 -0
- package/dist/normalize/rules/values.js +125 -0
- package/dist/normalize/rules/whitespace.js +381 -0
- package/dist/normalize/style.js +121 -0
- package/dist/normalize/targets.d.ts +8 -0
- package/dist/normalize/targets.js +17 -0
- package/dist/normalize/tree.d.ts +1 -0
- package/dist/normalize/tree.js +151 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +149 -0
- package/dist/ssr/index.d.ts +10 -0
- package/dist/ssr/index.js +103 -0
- package/dist/ssr/spec.d.ts +1 -0
- package/dist/ssr/spec.js +7 -0
- package/dist/targets/angular.d.ts +1 -0
- package/dist/targets/angular.js +5 -0
- package/dist/targets/astro.d.ts +1 -0
- package/dist/targets/astro.js +5 -0
- package/dist/targets/qwik.d.ts +1 -0
- package/dist/targets/qwik.js +5 -0
- package/dist/targets/react.d.ts +1 -0
- package/dist/targets/react.js +5 -0
- package/dist/targets/solid.d.ts +1 -0
- package/dist/targets/solid.js +5 -0
- package/dist/targets/svelte.d.ts +1 -0
- package/dist/targets/svelte.js +5 -0
- package/dist/targets/vue.d.ts +1 -0
- package/dist/targets/vue.js +5 -0
- package/dist/visual-types.d.ts +92 -0
- package/dist/visual-types.js +24 -0
- package/package.json +135 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { caseReference, isReference } from "../harness.js";
|
|
2
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
//#region src/node/context.ts
|
|
5
|
+
/** The calling project's target and harness context; throws if the project does not provide them. */
|
|
6
|
+
function projectHarness(context) {
|
|
7
|
+
const provided = context.project.getProvidedContext();
|
|
8
|
+
if (!provided.target || !provided.ufHarness) throw new Error(`[uf] Project "${context.project.name}" does not provide "target" and "ufHarness": the harness's browser commands only run in harness projects.`);
|
|
9
|
+
return {
|
|
10
|
+
target: provided.target,
|
|
11
|
+
harness: provided.ufHarness
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** The case directory of a case id, refusing ids that are not known cases. */
|
|
15
|
+
function caseDirectory(harness, id) {
|
|
16
|
+
if (!Object.hasOwn(harness.cases, id) || id.split("/").includes("..")) throw new Error(`[uf] Unknown case "${id}".`);
|
|
17
|
+
return join(harness.casesDir, id);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The main `.uf.tsx` source of a case (absolute): the one its `case.json`'s `main` names,
|
|
21
|
+
* relative to the case's directory and maybe outside it (ADR-0086), or else the directory's only
|
|
22
|
+
* `.uf.tsx`. A spec mounts it, and the server render renders it.
|
|
23
|
+
*/
|
|
24
|
+
function caseMainSource(harness, id) {
|
|
25
|
+
const directory = caseDirectory(harness, id);
|
|
26
|
+
const main = harness.cases[id]?.main;
|
|
27
|
+
if (main !== void 0) {
|
|
28
|
+
const source = resolve(directory, main);
|
|
29
|
+
if (!main.endsWith(".uf.tsx") || !existsSync(source)) throw new Error(`[uf] Case ${id} names ${main} as its main input, which it does not hold.`);
|
|
30
|
+
return source;
|
|
31
|
+
}
|
|
32
|
+
const sources = readdirSync(directory).filter((file) => file.endsWith(".uf.tsx"));
|
|
33
|
+
if (sources.length !== 1) throw new Error(`[uf] Case ${id} must hold one .uf.tsx input, or name its main one in case.json, to mount; found ${sources.length}.`);
|
|
34
|
+
return join(directory, sources[0]);
|
|
35
|
+
}
|
|
36
|
+
/** The directory artefact paths are shown relative to: the cases directory's parent. */
|
|
37
|
+
function displayRoot(harness) {
|
|
38
|
+
return dirname(harness.casesDir);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* How a target settles a case's artefacts every target shares (`__expected__/*`): the case's
|
|
42
|
+
* reference (ADR-0057) writes them in update mode, everyone else compares.
|
|
43
|
+
*/
|
|
44
|
+
function sharedArtefactContext(harness, target, caseId) {
|
|
45
|
+
return {
|
|
46
|
+
role: isReference(harness, target, caseId) ? "reference" : "follower",
|
|
47
|
+
update: harness.update,
|
|
48
|
+
root: displayRoot(harness),
|
|
49
|
+
ledgerDir: harness.ledgerDir,
|
|
50
|
+
...harness.updateCommand === void 0 ? {} : { updateCommand: harness.updateCommand },
|
|
51
|
+
reference: caseReference(harness, caseId)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { caseDirectory, caseMainSource, displayRoot, projectHarness, sharedArtefactContext };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UfModule } from "@unframework.dev/ir";
|
|
2
|
+
import { MountEvent } from "@unframework.dev/codegen";
|
|
3
|
+
//#region src/node/events.d.ts
|
|
4
|
+
/** A module a project compiled, as the unplugin's `onCompile` reports it. */
|
|
5
|
+
export interface CompiledModule {
|
|
6
|
+
/** The authored `.uf.tsx` file, absolute. */
|
|
7
|
+
file: string;
|
|
8
|
+
/** The target the project compiles to. */
|
|
9
|
+
target: string;
|
|
10
|
+
/** The compile's IR, or nothing when the module did not parse. */
|
|
11
|
+
ir?: UfModule | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** Records the latest compile of a module for a target: the harness calls it from `onCompile`. */
|
|
14
|
+
export declare function recordCompiledModule(module: CompiledModule): void;
|
|
15
|
+
/**
|
|
16
|
+
* The events the component of a compiled module declares, in declaration order, each with the
|
|
17
|
+
* optional members of its payload. A module of several components must declare the same events
|
|
18
|
+
* in each: a case mounts one component, and cannot tell which of a module's it is. A test that
|
|
19
|
+
* composes components mounts a harness parent from a source of its own (ADR-0057). Throws
|
|
20
|
+
* when the module was never compiled for the target, or failed to.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compiledEvents(file: string, target: string): MountEvent[];
|
|
23
|
+
/** The events a module's component declares (see {@link compiledEvents}). */
|
|
24
|
+
export declare function eventsOfModule(ir: UfModule, file?: string): MountEvent[];
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
//#region src/node/events.ts
|
|
3
|
+
/**
|
|
4
|
+
* One store per process, whatever copy of this module records or reads it: the config that
|
|
5
|
+
* builds the projects and the commands it registers may load it apart.
|
|
6
|
+
*/
|
|
7
|
+
const STORE = Symbol.for("@unframework.dev/testing:compiled-modules");
|
|
8
|
+
function store() {
|
|
9
|
+
const holder = globalThis;
|
|
10
|
+
return holder[STORE] ??= /* @__PURE__ */ new Map();
|
|
11
|
+
}
|
|
12
|
+
/** The key of a file's compile for a target: its real path, so links never split it. */
|
|
13
|
+
function keyOf(file, target) {
|
|
14
|
+
let path = file;
|
|
15
|
+
try {
|
|
16
|
+
path = realpathSync(file);
|
|
17
|
+
} catch {}
|
|
18
|
+
return `${target}\0${path}`;
|
|
19
|
+
}
|
|
20
|
+
/** Records the latest compile of a module for a target: the harness calls it from `onCompile`. */
|
|
21
|
+
function recordCompiledModule(module) {
|
|
22
|
+
store().set(keyOf(module.file, module.target), module.ir);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The events the component of a compiled module declares, in declaration order, each with the
|
|
26
|
+
* optional members of its payload. A module of several components must declare the same events
|
|
27
|
+
* in each: a case mounts one component, and cannot tell which of a module's it is. A test that
|
|
28
|
+
* composes components mounts a harness parent from a source of its own (ADR-0057). Throws
|
|
29
|
+
* when the module was never compiled for the target, or failed to.
|
|
30
|
+
*/
|
|
31
|
+
function compiledEvents(file, target) {
|
|
32
|
+
const key = keyOf(file, target);
|
|
33
|
+
const entries = store();
|
|
34
|
+
if (!entries.has(key)) throw new Error(`[uf] No ${target} compile of ${file} was recorded: the project's unplugin must report every compile to recordCompiledModule (its onCompile hook) before a spec mounts the component.`);
|
|
35
|
+
const ir = entries.get(key);
|
|
36
|
+
if (!ir) throw new Error(`[uf] The ${target} compile of ${file} produced no IR: it has nothing to mount.`);
|
|
37
|
+
return eventsOfModule(ir, file);
|
|
38
|
+
}
|
|
39
|
+
/** The events a module's component declares (see {@link compiledEvents}). */
|
|
40
|
+
function eventsOfModule(ir, file = ir.file) {
|
|
41
|
+
const lists = ir.components.map((component) => (component.emits?.events ?? []).map((event) => ({
|
|
42
|
+
name: event.name,
|
|
43
|
+
optional: event.parameters.map((parameter) => parameter.optional === true)
|
|
44
|
+
})));
|
|
45
|
+
const [first = [], ...rest] = lists;
|
|
46
|
+
if (rest.some((list) => JSON.stringify(list) !== JSON.stringify(first))) throw new Error(`[uf] ${file} holds ${lists.length} components that declare different events, and a case mounts one of them: a test cannot tell which one it mounts until components can be composed (M3).`);
|
|
47
|
+
return first;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { compiledEvents, eventsOfModule, recordCompiledModule };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SpecFinishedRequest } from "../commands.js";
|
|
2
|
+
import { CommandProject } from "./context.js";
|
|
3
|
+
//#region src/node/finished.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `ufSpecFinished`: records that the calling project finished a case's spec file. The setup
|
|
6
|
+
* file calls it from an `aroundAll` hook after the file's tests and its afterAll hooks, so it
|
|
7
|
+
* resolves before the file ends, and so before any later `sequence.groupOrder` group starts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ufSpecFinished(context: CommandProject, request: SpecFinishedRequest): void;
|
|
10
|
+
/** Whether a target's browser project finished a case's spec file in a run. */
|
|
11
|
+
export declare function specFinished(runId: string, target: string, caseId: string): boolean;
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { caseDirectory, projectHarness } from "./context.js";
|
|
2
|
+
//#region src/node/finished.ts
|
|
3
|
+
const STATE = Symbol.for("unframework.visual.finished");
|
|
4
|
+
/** Run id and target → the cases whose spec file that target's browser project finished. */
|
|
5
|
+
function finished() {
|
|
6
|
+
const store = globalThis;
|
|
7
|
+
return store[STATE] ??= /* @__PURE__ */ new Map();
|
|
8
|
+
}
|
|
9
|
+
const keyOf = (runId, target) => `${runId}:${target}`;
|
|
10
|
+
/**
|
|
11
|
+
* `ufSpecFinished`: records that the calling project finished a case's spec file. The setup
|
|
12
|
+
* file calls it from an `aroundAll` hook after the file's tests and its afterAll hooks, so it
|
|
13
|
+
* resolves before the file ends, and so before any later `sequence.groupOrder` group starts.
|
|
14
|
+
*/
|
|
15
|
+
function ufSpecFinished(context, request) {
|
|
16
|
+
const { target, harness } = projectHarness(context);
|
|
17
|
+
caseDirectory(harness, request.case);
|
|
18
|
+
const key = keyOf(harness.runId, target);
|
|
19
|
+
const cases = finished().get(key) ?? /* @__PURE__ */ new Set();
|
|
20
|
+
cases.add(request.case);
|
|
21
|
+
finished().set(key, cases);
|
|
22
|
+
}
|
|
23
|
+
/** Whether a target's browser project finished a case's spec file in a run. */
|
|
24
|
+
function specFinished(runId, target, caseId) {
|
|
25
|
+
return finished().get(keyOf(runId, target))?.has(caseId) ?? false;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { specFinished, ufSpecFinished };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BROWSER_LAYERS, LAYERS, LayerCheck, LayerFailure, LayerName, LayerOutcome, LayerSkip, LayerSubject, LayerTask, NOT_IN_THIS_RUN_SKIP, NOT_RENDERED_SKIP, NO_INTERACTION_SKIP, NO_OUTPUT_SKIP, NO_OUTPUT_TEST_SKIP, NO_SPEC_SKIP, QuarantineEntry, REQUIRES_SKIP, UfLayerMeta, checkLayers, layerFailures, mergeOutcomes, noOutputSkip, quarantineFor, recordLayer, recordStandIn, requiresSkip, settleOutcome } from "../layers.js";
|
|
2
|
+
import { BROWSER_ENGINES, BrowserEngine, COLOR_SCHEMES, CaseConfig, ColorScheme, HarnessContext, PixelMode, SsrScenario, caseOfFile, caseReference, caseReferences, isReference, ssrScenarios } from "../harness.js";
|
|
3
|
+
import { formatConsoleArgs } from "../browser/console.js";
|
|
4
|
+
import { CaptureAttachment, CaptureOutcome, CaptureRequest, CaptureResult, FONT_AUDIT_SKIP, GeometryDelta, GeometrySnapshot, LIVE_REFERENCE_SKIP, PixelTolerance, REFERENCE_NOT_RUN_SKIP, referenceNotRunSkip } from "../visual-types.js";
|
|
5
|
+
import { MapStackRequest, MapStackResult, SpecFinishedRequest } from "../commands.js";
|
|
6
|
+
import { VIEWPORT } from "./viewport.js";
|
|
7
|
+
import { ACTION_TIMEOUT, AnyBrowserCommand, ParityBrowserOptions, parityBrowser } from "./browser.js";
|
|
8
|
+
import { ArtefactContext, ArtefactOutcome, ArtefactRole, ArtefactStatus, settleArtefact, settleArtefactDirectory, writeIfChanged } from "./policy.js";
|
|
9
|
+
import { CommandProject, caseDirectory, displayRoot, projectHarness, sharedArtefactContext } from "./context.js";
|
|
10
|
+
import { specFinished, ufSpecFinished } from "./finished.js";
|
|
11
|
+
import { ALLOWED_FONTS, CaptureLocation, VisualCommandContext, baselineFileName, captureAt, caseCaptureLocation, diffGeometry, formatGeometryDiff, ufVisualCapture } from "./visual.js";
|
|
12
|
+
import { AriaCommandContext, ColorSchemeContext, FocusCommandContext, InputCommandContext, browserCommands, ufAriaSnapshot, ufArtefact, ufColorScheme, ufComponentEvents, ufFocus, ufResetInput } from "./commands.js";
|
|
13
|
+
import { CompiledModule, compiledEvents, eventsOfModule, recordCompiledModule } from "./events.js";
|
|
14
|
+
import { MATRIX_VERSION, MatrixCells, MatrixTest, MatrixTests, MergedMatrix, ParityMatrix, PartialMatrix, ProjectRecord, RunInfo, RunMode, Shard, buildCells, buildPartialMatrix, buildTests, cellHeadline, cellOf, mergeCells, mergeMatrices, mergeTests, narrowing, outcomeOfCell, settleQuarantine, stringifyMatrix, withoutProjects } from "./matrix.js";
|
|
15
|
+
import { BASELINE_ENVIRONMENT, HarnessMode, HarnessRunOptions, ModeInput, ProjectKind, createHarnessRun, groupOrder, resolveBrowser, resolveHarnessMode } from "./mode.js";
|
|
16
|
+
import { KEBAB_CASE } from "./names.js";
|
|
17
|
+
import { ParityReporter, ParityReporterOptions, isPartialMatrixFile, readPartialMatrices, runName, testKey } from "./reporter.js";
|
|
18
|
+
import { SummaryExpectations, SummaryJudgement, SummaryOptions, SummaryResult, renderMarkdown, summarise, summaryName, unacceptedSkip, writeSummary } from "./summary.js";
|
|
19
|
+
import { DiffOptions, diffLines } from "../diff.js";
|
|
20
|
+
import { errorMessages, formatError } from "../errors.js";
|
|
21
|
+
export { ACTION_TIMEOUT, ALLOWED_FONTS, type AnyBrowserCommand, type AriaCommandContext, type ArtefactContext, type ArtefactOutcome, type ArtefactRole, type ArtefactStatus, BASELINE_ENVIRONMENT, BROWSER_ENGINES, BROWSER_LAYERS, type BrowserEngine, COLOR_SCHEMES, type CaptureAttachment, type CaptureLocation, type CaptureOutcome, type CaptureRequest, type CaptureResult, type CaseConfig, type ColorScheme, type ColorSchemeContext, type CommandProject, type CompiledModule, type DiffOptions, FONT_AUDIT_SKIP, type FocusCommandContext, type GeometryDelta, type GeometrySnapshot, type HarnessContext, type HarnessMode, type HarnessRunOptions, type InputCommandContext, KEBAB_CASE, LAYERS, LIVE_REFERENCE_SKIP, type LayerCheck, LayerFailure, type LayerName, type LayerOutcome, type LayerSkip, type LayerSubject, type LayerTask, MATRIX_VERSION, type MapStackRequest, type MapStackResult, type MatrixCells, type MatrixTest, type MatrixTests, type MergedMatrix, type ModeInput, NOT_IN_THIS_RUN_SKIP, NOT_RENDERED_SKIP, NO_INTERACTION_SKIP, NO_OUTPUT_SKIP, NO_OUTPUT_TEST_SKIP, NO_SPEC_SKIP, type ParityBrowserOptions, type ParityMatrix, ParityReporter, type ParityReporterOptions, type PartialMatrix, type PixelMode, type PixelTolerance, type ProjectKind, type ProjectRecord, type QuarantineEntry, REFERENCE_NOT_RUN_SKIP, REQUIRES_SKIP, type RunInfo, type RunMode, type Shard, type SpecFinishedRequest, type SsrScenario, type SummaryExpectations, type SummaryJudgement, type SummaryOptions, type SummaryResult, type UfLayerMeta, VIEWPORT, type VisualCommandContext, baselineFileName, browserCommands, buildCells, buildPartialMatrix, buildTests, captureAt, caseCaptureLocation, caseDirectory, caseOfFile, caseReference, caseReferences, cellHeadline, cellOf, checkLayers, compiledEvents, createHarnessRun, diffGeometry, diffLines, displayRoot, errorMessages, eventsOfModule, formatConsoleArgs, formatError, formatGeometryDiff, groupOrder, isPartialMatrixFile, isReference, layerFailures, mergeCells, mergeMatrices, mergeOutcomes, mergeTests, narrowing, noOutputSkip, outcomeOfCell, parityBrowser, projectHarness, quarantineFor, readPartialMatrices, recordCompiledModule, recordLayer, recordStandIn, referenceNotRunSkip, renderMarkdown, requiresSkip, resolveBrowser, resolveHarnessMode, runName, settleArtefact, settleArtefactDirectory, settleOutcome, settleQuarantine, sharedArtefactContext, specFinished, ssrScenarios, stringifyMatrix, summarise, summaryName, testKey, ufAriaSnapshot, ufArtefact, ufColorScheme, ufComponentEvents, ufFocus, ufResetInput, ufSpecFinished, ufVisualCapture, unacceptedSkip, withoutProjects, writeIfChanged, writeSummary };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BROWSER_ENGINES, COLOR_SCHEMES, caseOfFile, caseReference, caseReferences, isReference, ssrScenarios } from "../harness.js";
|
|
2
|
+
import { caseDirectory, displayRoot, projectHarness, sharedArtefactContext } from "./context.js";
|
|
3
|
+
import { compiledEvents, eventsOfModule, recordCompiledModule } from "./events.js";
|
|
4
|
+
import { specFinished, ufSpecFinished } from "./finished.js";
|
|
5
|
+
import { KEBAB_CASE } from "./names.js";
|
|
6
|
+
import { diffLines } from "../diff.js";
|
|
7
|
+
import { settleArtefact, settleArtefactDirectory, writeIfChanged } from "./policy.js";
|
|
8
|
+
import { VIEWPORT } from "./viewport.js";
|
|
9
|
+
import { BASELINE_ENVIRONMENT, createHarnessRun, groupOrder, resolveBrowser, resolveHarnessMode } from "./mode.js";
|
|
10
|
+
import { ALLOWED_FONTS, baselineFileName, captureAt, caseCaptureLocation, diffGeometry, formatGeometryDiff, ufVisualCapture } from "./visual.js";
|
|
11
|
+
import { browserCommands, ufAriaSnapshot, ufArtefact, ufColorScheme, ufComponentEvents, ufFocus, ufResetInput } from "./commands.js";
|
|
12
|
+
import { ACTION_TIMEOUT, parityBrowser } from "./browser.js";
|
|
13
|
+
import { formatConsoleArgs } from "../browser/console.js";
|
|
14
|
+
import { errorMessages, formatError } from "../errors.js";
|
|
15
|
+
import { FONT_AUDIT_SKIP, LIVE_REFERENCE_SKIP, REFERENCE_NOT_RUN_SKIP, referenceNotRunSkip } from "../visual-types.js";
|
|
16
|
+
import { BROWSER_LAYERS, LAYERS, LayerFailure, NOT_IN_THIS_RUN_SKIP, NOT_RENDERED_SKIP, NO_INTERACTION_SKIP, NO_OUTPUT_SKIP, NO_OUTPUT_TEST_SKIP, NO_SPEC_SKIP, REQUIRES_SKIP, checkLayers, layerFailures, mergeOutcomes, noOutputSkip, quarantineFor, recordLayer, recordStandIn, requiresSkip, settleOutcome } from "../layers.js";
|
|
17
|
+
import { MATRIX_VERSION, buildCells, buildPartialMatrix, buildTests, cellHeadline, cellOf, mergeCells, mergeMatrices, mergeTests, narrowing, outcomeOfCell, settleQuarantine, stringifyMatrix, withoutProjects } from "./matrix.js";
|
|
18
|
+
import { ParityReporter, isPartialMatrixFile, readPartialMatrices, runName, testKey } from "./reporter.js";
|
|
19
|
+
import { renderMarkdown, summarise, summaryName, unacceptedSkip, writeSummary } from "./summary.js";
|
|
20
|
+
export { ACTION_TIMEOUT, ALLOWED_FONTS, BASELINE_ENVIRONMENT, BROWSER_ENGINES, BROWSER_LAYERS, COLOR_SCHEMES, FONT_AUDIT_SKIP, KEBAB_CASE, LAYERS, LIVE_REFERENCE_SKIP, LayerFailure, MATRIX_VERSION, NOT_IN_THIS_RUN_SKIP, NOT_RENDERED_SKIP, NO_INTERACTION_SKIP, NO_OUTPUT_SKIP, NO_OUTPUT_TEST_SKIP, NO_SPEC_SKIP, ParityReporter, REFERENCE_NOT_RUN_SKIP, REQUIRES_SKIP, VIEWPORT, baselineFileName, browserCommands, buildCells, buildPartialMatrix, buildTests, captureAt, caseCaptureLocation, caseDirectory, caseOfFile, caseReference, caseReferences, cellHeadline, cellOf, checkLayers, compiledEvents, createHarnessRun, diffGeometry, diffLines, displayRoot, errorMessages, eventsOfModule, formatConsoleArgs, formatError, formatGeometryDiff, groupOrder, isPartialMatrixFile, isReference, layerFailures, mergeCells, mergeMatrices, mergeOutcomes, mergeTests, narrowing, noOutputSkip, outcomeOfCell, parityBrowser, projectHarness, quarantineFor, readPartialMatrices, recordCompiledModule, recordLayer, recordStandIn, referenceNotRunSkip, renderMarkdown, requiresSkip, resolveBrowser, resolveHarnessMode, runName, settleArtefact, settleArtefactDirectory, settleOutcome, settleQuarantine, sharedArtefactContext, specFinished, ssrScenarios, stringifyMatrix, summarise, summaryName, testKey, ufAriaSnapshot, ufArtefact, ufColorScheme, ufComponentEvents, ufFocus, ufResetInput, ufSpecFinished, ufVisualCapture, unacceptedSkip, withoutProjects, writeIfChanged, writeSummary };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { LayerName, LayerOutcome, QuarantineEntry, UfLayerMeta } from "../layers.js";
|
|
2
|
+
import { PixelMode } from "../harness.js";
|
|
3
|
+
//#region src/node/matrix.d.ts
|
|
4
|
+
/** Case → target → layer → cell. */
|
|
5
|
+
export type MatrixCells = Record<string, Record<string, Partial<Record<LayerName, string>>>>;
|
|
6
|
+
/** Case → target → the parity scenarios its tests checked (`expectParity` names), sorted. */
|
|
7
|
+
export type MatrixScenarios = Record<string, Record<string, string[]>>;
|
|
8
|
+
/**
|
|
9
|
+
* What the matrix keeps of one test: the scenarios it checked, or why it was skipped or ran
|
|
10
|
+
* against a stand-in.
|
|
11
|
+
*/
|
|
12
|
+
export interface MatrixTest {
|
|
13
|
+
/** The parity scenarios the test checked, sorted. */
|
|
14
|
+
scenarios: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Why the test was skipped on this target: a capability it requires is unsupported, or the
|
|
17
|
+
* target has no output for the case.
|
|
18
|
+
*/
|
|
19
|
+
skipped?: string;
|
|
20
|
+
/** Why the test ran against a stand-in on this target: it cannot compile the case yet. */
|
|
21
|
+
standIn?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Case → target → test (its name without the target, `UfLayerMeta.test`) → what it checked. The
|
|
25
|
+
* summary compares each target's tests of a case with the reference's, test by test, and
|
|
26
|
+
* excuses a test that a target skipped, alone.
|
|
27
|
+
*/
|
|
28
|
+
export type MatrixTests = Record<string, Record<string, Record<string, MatrixTest>>>;
|
|
29
|
+
/** The version of the matrix files; a file of another version is never merged. */
|
|
30
|
+
export declare const MATRIX_VERSION = 5;
|
|
31
|
+
/** One run's (or a merged) parity matrix. */
|
|
32
|
+
export interface ParityMatrix {
|
|
33
|
+
version: typeof MATRIX_VERSION;
|
|
34
|
+
/** The run that wrote it: `all`, a project list, or `merged`. */
|
|
35
|
+
run: string;
|
|
36
|
+
/** The projects whose tests fed the matrix, sorted. */
|
|
37
|
+
projects: string[];
|
|
38
|
+
/** Case → target → layer → cell, merged across projects. */
|
|
39
|
+
cases: MatrixCells;
|
|
40
|
+
/**
|
|
41
|
+
* Case → target → the parity scenarios checked, merged across projects. Every target runs the
|
|
42
|
+
* same spec, so each must check the reference's scenarios (see `summarise`).
|
|
43
|
+
*/
|
|
44
|
+
scenarios: MatrixScenarios;
|
|
45
|
+
/**
|
|
46
|
+
* Case → target → test → the scenarios it checked, or why it was skipped by capability: the
|
|
47
|
+
* skips the cells cannot show (a skipped test's cells merge with its case's other tests'), and
|
|
48
|
+
* what the summary compares test by test.
|
|
49
|
+
*/
|
|
50
|
+
tests: MatrixTests;
|
|
51
|
+
}
|
|
52
|
+
/** How a run treated artefacts (the harness mode), for the reader of a matrix. */
|
|
53
|
+
export interface RunMode {
|
|
54
|
+
update: boolean;
|
|
55
|
+
pixels: PixelMode;
|
|
56
|
+
canary: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One part of a sharded run (`--shard <index>/<count>`): Vitest splits the test files of the
|
|
60
|
+
* selected projects into `count` parts and runs part `index` (from 1).
|
|
61
|
+
*/
|
|
62
|
+
export interface Shard {
|
|
63
|
+
index: number;
|
|
64
|
+
count: number;
|
|
65
|
+
}
|
|
66
|
+
/** When and how a partial matrix's run ran. */
|
|
67
|
+
export interface RunInfo {
|
|
68
|
+
run: string;
|
|
69
|
+
/** When the run ended (ISO 8601). Of two records of one project's cell, the newer counts. */
|
|
70
|
+
finishedAt: string;
|
|
71
|
+
/** The harness mode, or `null` for a run outside the harness. */
|
|
72
|
+
mode: RunMode | null;
|
|
73
|
+
/**
|
|
74
|
+
* Why the run covered only part of its projects' tests besides a shard (a file, test-name,
|
|
75
|
+
* tags or changed-files filter, or watch mode), or `null` when nothing else narrowed it.
|
|
76
|
+
*/
|
|
77
|
+
filtered: string | null;
|
|
78
|
+
/**
|
|
79
|
+
* The run's shard, or `null`. Kept apart from `filtered` because shards add up: shards 1 to
|
|
80
|
+
* `count` of one selection, with no other filter, ran every test of its projects.
|
|
81
|
+
*/
|
|
82
|
+
shard: Shard | null;
|
|
83
|
+
projects: string[];
|
|
84
|
+
/**
|
|
85
|
+
* The selected projects that collected no tests. A run nothing narrowed fails on one itself;
|
|
86
|
+
* a shard may hold none of a project's files, so the summary judges them once every shard ran.
|
|
87
|
+
*/
|
|
88
|
+
empty: string[];
|
|
89
|
+
}
|
|
90
|
+
/** Why a run covered only part of its projects' tests, its shard included, or `null`. */
|
|
91
|
+
export declare function narrowing(run: Pick<RunInfo, "filtered" | "shard">): string | null;
|
|
92
|
+
/** What one Vitest run writes: `parity-matrix.<run>.json`. */
|
|
93
|
+
export interface PartialMatrix extends ParityMatrix, RunInfo {
|
|
94
|
+
/**
|
|
95
|
+
* The quarantine the run applied. A merge judges every record by the newest run's, the one
|
|
96
|
+
* `harness/quarantine.ts` held last.
|
|
97
|
+
*/
|
|
98
|
+
quarantine: QuarantineEntry[];
|
|
99
|
+
/**
|
|
100
|
+
* The run's reference target (D10), whose parity scenarios every target's must equal, or
|
|
101
|
+
* `null` for a run outside the harness. A merge takes the newest run's.
|
|
102
|
+
*/
|
|
103
|
+
reference: string | null;
|
|
104
|
+
/**
|
|
105
|
+
* The cases that name their own reference (ADR-0057), with it: their scenarios are judged
|
|
106
|
+
* against that target's. A merge takes the newest run's.
|
|
107
|
+
*/
|
|
108
|
+
references?: Record<string, string>;
|
|
109
|
+
/**
|
|
110
|
+
* The errors Vitest reported outside every test in this run, each as its message and its
|
|
111
|
+
* causes' on one line, such as the closed browser connection that stopped the reference's
|
|
112
|
+
* project (ADR-0091). Absent when there were none.
|
|
113
|
+
*/
|
|
114
|
+
errors?: string[];
|
|
115
|
+
/** Project → its own cells, so a later run of a project replaces exactly its cells. */
|
|
116
|
+
byProject: Record<string, MatrixCells>;
|
|
117
|
+
/** Project → its own scenarios, kept and replaced with its cells. */
|
|
118
|
+
scenariosByProject: Record<string, MatrixScenarios>;
|
|
119
|
+
/** Project → its own tests, kept and replaced with its cells. */
|
|
120
|
+
testsByProject: Record<string, MatrixTests>;
|
|
121
|
+
}
|
|
122
|
+
/** A merge of partial matrices (`parity-matrix.json`), with what it was merged from. */
|
|
123
|
+
export interface MergedMatrix extends ParityMatrix {
|
|
124
|
+
/** The partial matrices merged, oldest first. */
|
|
125
|
+
runs: RunInfo[];
|
|
126
|
+
}
|
|
127
|
+
/** A test's record and the project it ran in. */
|
|
128
|
+
export interface ProjectRecord {
|
|
129
|
+
project: string;
|
|
130
|
+
record: UfLayerMeta;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* An outcome as a matrix cell. A failure keeps its whole message, every sub-check's included
|
|
134
|
+
* (both the DOM and the ARIA diff of L7, the server's and the page's console of L13), so a
|
|
135
|
+
* canary can require the evidence of each.
|
|
136
|
+
*/
|
|
137
|
+
export declare function cellOf(outcome: LayerOutcome): string;
|
|
138
|
+
/** A matrix cell as an outcome. Throws on text that is not a cell, so a corrupt matrix is loud. */
|
|
139
|
+
export declare function outcomeOfCell(cell: string): LayerOutcome;
|
|
140
|
+
/** The first line of a cell, for a one-line summary; the matrix file has the rest. */
|
|
141
|
+
export declare function cellHeadline(cell: string): string;
|
|
142
|
+
/** Builds cells from test records, merging every record of a cell (fail beats pass). */
|
|
143
|
+
export declare function buildCells(records: readonly UfLayerMeta[]): MatrixCells;
|
|
144
|
+
/**
|
|
145
|
+
* The tests of test records: each named test's sorted scenarios, capability skip and stand-in.
|
|
146
|
+
* Records without a test name (a file's own) and tests that checked nothing and were neither
|
|
147
|
+
* skipped nor run against a stand-in are left out: they have nothing to compare.
|
|
148
|
+
*/
|
|
149
|
+
export declare function buildTests(records: readonly UfLayerMeta[]): MatrixTests;
|
|
150
|
+
/**
|
|
151
|
+
* Merges sets of tests, a later set's record of a test replacing an earlier one's (a newer run
|
|
152
|
+
* of the test). Within one set a test is recorded once: two tests of a case never share a name.
|
|
153
|
+
*/
|
|
154
|
+
export declare function mergeTests(sets: readonly MatrixTests[]): MatrixTests;
|
|
155
|
+
/** Merges several projects' cells into one set, cell by cell (fail beats pass). */
|
|
156
|
+
export declare function mergeCells(sets: readonly MatrixCells[]): MatrixCells;
|
|
157
|
+
/** Builds a run's partial matrix from its test records. */
|
|
158
|
+
export declare function buildPartialMatrix(input: {
|
|
159
|
+
run: string;
|
|
160
|
+
/** Every project the run selected, also those that recorded nothing. */
|
|
161
|
+
projects: readonly string[];
|
|
162
|
+
records: readonly ProjectRecord[];
|
|
163
|
+
finishedAt: string;
|
|
164
|
+
mode: RunMode | null;
|
|
165
|
+
filtered: string | null;
|
|
166
|
+
shard: Shard | null;
|
|
167
|
+
/** The selected projects that collected no tests. */
|
|
168
|
+
empty: readonly string[];
|
|
169
|
+
quarantine: readonly QuarantineEntry[];
|
|
170
|
+
/** The run's reference target; none outside the harness. */
|
|
171
|
+
reference?: string | null;
|
|
172
|
+
/** The cases that name their own reference, with it. */
|
|
173
|
+
references?: Record<string, string>;
|
|
174
|
+
/** The errors Vitest reported outside every test, one line each. */
|
|
175
|
+
errors?: readonly string[];
|
|
176
|
+
}): PartialMatrix;
|
|
177
|
+
/**
|
|
178
|
+
* The part of a project a newer run re-judged: only some targets' cells (a run of some targets,
|
|
179
|
+
* `UF_TARGETS`), or only some cases' (a target the run adds for the cases that name it as their
|
|
180
|
+
* own reference, ADR-0057). What a scope leaves out is every target, or every case.
|
|
181
|
+
*/
|
|
182
|
+
export interface ProjectScope {
|
|
183
|
+
targets?: ReadonlySet<string>;
|
|
184
|
+
cases?: ReadonlySet<string>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A partial matrix without some projects' records (a newer run has them), or none if empty. A
|
|
188
|
+
* project with a scope loses only the cells inside it, and goes once it has none left. A matrix
|
|
189
|
+
* that loses nothing is returned as it is, and a project that loses nothing keeps its records.
|
|
190
|
+
*/
|
|
191
|
+
export declare function withoutProjects(matrix: PartialMatrix, projects: ReadonlySet<string>, scopes?: ReadonlyMap<string, ProjectScope>): PartialMatrix | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Merges partial matrices (CI's jobs, local runs of a subset) into one. For each project the
|
|
194
|
+
* newest record of each cell wins, so a re-run replaces what an earlier run recorded; then the
|
|
195
|
+
* projects merge cell by cell (fail beats pass). Scenarios add up, as cells another run did not
|
|
196
|
+
* record are kept: a run of a project replaces its older records of the targets and cases it
|
|
197
|
+
* re-judged (the reporter's `supersede`). The quarantine and the reference are the newest run's:
|
|
198
|
+
* an entry removed since an older run must neither hide that run's failures nor go stale.
|
|
199
|
+
*/
|
|
200
|
+
export declare function mergeMatrices(partials: readonly PartialMatrix[]): {
|
|
201
|
+
matrix: MergedMatrix;
|
|
202
|
+
quarantine: QuarantineEntry[];
|
|
203
|
+
reference: string | null;
|
|
204
|
+
references: Record<string, string>;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Judges cells by a quarantine, which may be newer than the runs that recorded them (see
|
|
208
|
+
* `mergeMatrices`): a failure under an entry is quarantined, and a cell an older run recorded as
|
|
209
|
+
* quarantined, under an entry since removed, fails (its message is not recorded: rerun its
|
|
210
|
+
* project to see it). With `stale`, for cells every record has reached (a complete run, or a
|
|
211
|
+
* merge of complete runs), a cell under an entry that passes, or is skipped, becomes a
|
|
212
|
+
* stale-entry failure (plan §7.7). Returns the failures it made.
|
|
213
|
+
*/
|
|
214
|
+
export declare function settleQuarantine(cells: MatrixCells, quarantine: readonly QuarantineEntry[], options: {
|
|
215
|
+
stale: boolean;
|
|
216
|
+
}): string[];
|
|
217
|
+
/** Serialises a matrix with a trailing newline; equal matrices are equal bytes. */
|
|
218
|
+
export declare function stringifyMatrix(matrix: ParityMatrix): string;
|
|
219
|
+
//#endregion
|