viewev 0.0.0-stage → 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +131 -2
- package/assets/logo/Logo-horizontal.png +0 -0
- package/dist/adapters/storybook/index.d.ts +5 -0
- package/dist/adapters/storybook/index.js +4 -0
- package/dist/adapters/storybook/index.js.map +1 -0
- package/dist/adapters/storybook/provider.d.ts +24 -0
- package/dist/adapters/storybook/provider.js +114 -0
- package/dist/adapters/storybook/provider.js.map +1 -0
- package/dist/adapters/storybook/scenarios.d.ts +30 -0
- package/dist/adapters/storybook/scenarios.js +64 -0
- package/dist/adapters/storybook/scenarios.js.map +1 -0
- package/dist/adapters/storybook/static-server.d.ts +10 -0
- package/dist/adapters/storybook/static-server.js +105 -0
- package/dist/adapters/storybook/static-server.js.map +1 -0
- package/dist/adapters/storybook/storybook-index.d.ts +32 -0
- package/dist/adapters/storybook/storybook-index.js +35 -0
- package/dist/adapters/storybook/storybook-index.js.map +1 -0
- package/dist/baselines/environment-check.d.ts +7 -0
- package/dist/baselines/environment-check.js +24 -0
- package/dist/baselines/environment-check.js.map +1 -0
- package/dist/baselines/environment-key.d.ts +8 -0
- package/dist/baselines/environment-key.js +12 -0
- package/dist/baselines/environment-key.js.map +1 -0
- package/dist/baselines/file-store.d.ts +12 -0
- package/dist/baselines/file-store.js +81 -0
- package/dist/baselines/file-store.js.map +1 -0
- package/dist/baselines/git-store.d.ts +16 -0
- package/dist/baselines/git-store.js +150 -0
- package/dist/baselines/git-store.js.map +1 -0
- package/dist/baselines/metadata.d.ts +16 -0
- package/dist/baselines/metadata.js +84 -0
- package/dist/baselines/metadata.js.map +1 -0
- package/dist/baselines/types.d.ts +33 -0
- package/dist/baselines/types.js +2 -0
- package/dist/baselines/types.js.map +1 -0
- package/dist/browser/playwright/capturer.d.ts +2 -0
- package/dist/browser/playwright/capturer.js +142 -0
- package/dist/browser/playwright/capturer.js.map +1 -0
- package/dist/browser/playwright/environment.d.ts +4 -0
- package/dist/browser/playwright/environment.js +36 -0
- package/dist/browser/playwright/environment.js.map +1 -0
- package/dist/browser/playwright/index.d.ts +1 -0
- package/dist/browser/playwright/index.js +2 -0
- package/dist/browser/playwright/index.js.map +1 -0
- package/dist/browser/types.d.ts +43 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/ci/github-summary.d.ts +5 -0
- package/dist/ci/github-summary.js +95 -0
- package/dist/ci/github-summary.js.map +1 -0
- package/dist/cli/baseline-ref.d.ts +6 -0
- package/dist/cli/baseline-ref.js +11 -0
- package/dist/cli/baseline-ref.js.map +1 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +13 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/baseline.d.ts +3 -0
- package/dist/cli/commands/baseline.js +90 -0
- package/dist/cli/commands/baseline.js.map +1 -0
- package/dist/cli/commands/capture.d.ts +3 -0
- package/dist/cli/commands/capture.js +42 -0
- package/dist/cli/commands/capture.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.js +25 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +19 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.js +16 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scenarios.d.ts +3 -0
- package/dist/cli/commands/scenarios.js +30 -0
- package/dist/cli/commands/scenarios.js.map +1 -0
- package/dist/cli/commands/test.d.ts +3 -0
- package/dist/cli/commands/test.js +123 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/context.d.ts +21 -0
- package/dist/cli/context.js +22 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +104 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/format.d.ts +17 -0
- package/dist/cli/format.js +106 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/impact.d.ts +13 -0
- package/dist/cli/impact.js +57 -0
- package/dist/cli/impact.js.map +1 -0
- package/dist/cli/program.d.ts +11 -0
- package/dist/cli/program.js +70 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/session.d.ts +27 -0
- package/dist/cli/session.js +53 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/comparison/compare.d.ts +11 -0
- package/dist/comparison/compare.js +41 -0
- package/dist/comparison/compare.js.map +1 -0
- package/dist/comparison/types.d.ts +34 -0
- package/dist/comparison/types.js +2 -0
- package/dist/comparison/types.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.js +93 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/schema.d.ts +299 -0
- package/dist/config/schema.js +134 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/artifacts.d.ts +6 -0
- package/dist/core/artifacts.js +2 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/baseline-run.d.ts +37 -0
- package/dist/core/baseline-run.js +85 -0
- package/dist/core/baseline-run.js.map +1 -0
- package/dist/core/capture-settings.d.ts +6 -0
- package/dist/core/capture-settings.js +21 -0
- package/dist/core/capture-settings.js.map +1 -0
- package/dist/core/discovery.d.ts +3 -0
- package/dist/core/discovery.js +17 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/impact.d.ts +19 -0
- package/dist/core/impact.js +28 -0
- package/dist/core/impact.js.map +1 -0
- package/dist/core/pool.d.ts +5 -0
- package/dist/core/pool.js +21 -0
- package/dist/core/pool.js.map +1 -0
- package/dist/core/result.d.ts +111 -0
- package/dist/core/result.js +53 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/selection.d.ts +8 -0
- package/dist/core/selection.js +8 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/test-run.d.ts +38 -0
- package/dist/core/test-run.js +140 -0
- package/dist/core/test-run.js.map +1 -0
- package/dist/impact/git.d.ts +17 -0
- package/dist/impact/git.js +55 -0
- package/dist/impact/git.js.map +1 -0
- package/dist/impact/types.d.ts +24 -0
- package/dist/impact/types.js +23 -0
- package/dist/impact/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/reporting/artifacts.d.ts +8 -0
- package/dist/reporting/artifacts.js +23 -0
- package/dist/reporting/artifacts.js.map +1 -0
- package/dist/reporting/html.d.ts +4 -0
- package/dist/reporting/html.js +244 -0
- package/dist/reporting/html.js.map +1 -0
- package/dist/reporting/report.d.ts +12 -0
- package/dist/reporting/report.js +55 -0
- package/dist/reporting/report.js.map +1 -0
- package/dist/reporting/results-json.d.ts +35 -0
- package/dist/reporting/results-json.js +37 -0
- package/dist/reporting/results-json.js.map +1 -0
- package/dist/scenarios/glob.d.ts +7 -0
- package/dist/scenarios/glob.js +21 -0
- package/dist/scenarios/glob.js.map +1 -0
- package/dist/scenarios/model.d.ts +61 -0
- package/dist/scenarios/model.js +31 -0
- package/dist/scenarios/model.js.map +1 -0
- package/dist/scenarios/schema.d.ts +8 -0
- package/dist/scenarios/schema.js +70 -0
- package/dist/scenarios/schema.js.map +1 -0
- package/dist/shared/environment.d.ts +23 -0
- package/dist/shared/environment.js +2 -0
- package/dist/shared/environment.js.map +1 -0
- package/dist/shared/errors.d.ts +23 -0
- package/dist/shared/errors.js +29 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/png.d.ts +3 -0
- package/dist/shared/png.js +14 -0
- package/dist/shared/png.js.map +1 -0
- package/dist/shared/size.d.ts +4 -0
- package/dist/shared/size.js +2 -0
- package/dist/shared/size.js.map +1 -0
- package/docs/architecture.md +180 -0
- package/docs/ci.md +212 -0
- package/docs/impact.md +46 -0
- package/package.json +58 -4
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const dimension = z.number().int().min(1).max(10_000);
|
|
3
|
+
const viewportSchema = z.object({ width: dimension, height: dimension }).strict();
|
|
4
|
+
const storybookProviderSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
type: z.literal('storybook'),
|
|
7
|
+
/** URL of a running Storybook (for example http://localhost:6006). */
|
|
8
|
+
url: z.string().url().optional(),
|
|
9
|
+
/** Directory of a built Storybook (storybook build output), relative to the config file. */
|
|
10
|
+
staticDir: z.string().min(1).optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict()
|
|
13
|
+
.refine((provider) => (provider.url === undefined) !== (provider.staticDir === undefined), {
|
|
14
|
+
message: 'Specify exactly one of "url" (running Storybook) or "staticDir" (built Storybook).',
|
|
15
|
+
});
|
|
16
|
+
const browserSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
engine: z.literal('chromium').default('chromium'),
|
|
19
|
+
})
|
|
20
|
+
.strict()
|
|
21
|
+
.default({});
|
|
22
|
+
const captureSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
deviceScaleFactor: z.number().positive().max(4).default(1),
|
|
25
|
+
locale: z.string().min(2).default('en-US'),
|
|
26
|
+
timezoneId: z.string().min(1).default('UTC'),
|
|
27
|
+
colorScheme: z.enum(['light', 'dark']).default('light'),
|
|
28
|
+
reducedMotion: z.boolean().default(true),
|
|
29
|
+
disableAnimations: z.boolean().default(true),
|
|
30
|
+
timeoutMs: z.number().int().positive().default(30_000),
|
|
31
|
+
})
|
|
32
|
+
.strict()
|
|
33
|
+
.default({});
|
|
34
|
+
const comparisonSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
colorThreshold: z.number().min(0).max(1).default(0.1),
|
|
37
|
+
maxDiffPixels: z.number().int().min(0).default(0),
|
|
38
|
+
maxDiffRatio: z.number().min(0).max(1).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.default({});
|
|
42
|
+
const baselinesSchema = z
|
|
43
|
+
.object({
|
|
44
|
+
dir: z.string().min(1).default('.viewev/baselines'),
|
|
45
|
+
/** Approved baselines to compare with when no CLI or CI target ref is provided. */
|
|
46
|
+
baseRef: z.string().min(1).optional(),
|
|
47
|
+
failOnObsolete: z.boolean().default(true),
|
|
48
|
+
strictEnvironment: z.boolean().default(false),
|
|
49
|
+
})
|
|
50
|
+
.strict()
|
|
51
|
+
.default({});
|
|
52
|
+
const reportSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
dir: z.string().min(1).default('.viewev/report'),
|
|
55
|
+
})
|
|
56
|
+
.strict()
|
|
57
|
+
.default({});
|
|
58
|
+
const variantSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
/** Becomes part of the scenario id after "@", so it must be file-name safe. */
|
|
61
|
+
name: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, 'must use lowercase letters, digits and "-"'),
|
|
62
|
+
/**
|
|
63
|
+
* Storybook globals to set for this variant, for example { 'backgrounds.value': 'g100' }.
|
|
64
|
+
* Written into the story URL as `globals=key:value;key:value`.
|
|
65
|
+
*/
|
|
66
|
+
globals: z
|
|
67
|
+
.record(z
|
|
68
|
+
.string()
|
|
69
|
+
.regex(/^[A-Za-z0-9_.]+$/, 'global names may only use letters, digits, "." and "_"'), z
|
|
70
|
+
.string()
|
|
71
|
+
.regex(/^[A-Za-z0-9_.-]+$/, 'global values may only use letters, digits, ".", "_" and "-"'))
|
|
72
|
+
.optional(),
|
|
73
|
+
/** Overrides the default viewport for this variant. */
|
|
74
|
+
viewport: viewportSchema.optional(),
|
|
75
|
+
})
|
|
76
|
+
.strict()
|
|
77
|
+
.refine((variant) => variant.globals !== undefined || variant.viewport !== undefined, {
|
|
78
|
+
message: 'A variant needs "globals", "viewport", or both.',
|
|
79
|
+
});
|
|
80
|
+
const variantsSchema = z
|
|
81
|
+
.array(variantSchema)
|
|
82
|
+
.superRefine((variants, context) => {
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
variants.forEach((variant, index) => {
|
|
85
|
+
if (seen.has(variant.name)) {
|
|
86
|
+
context.addIssue({
|
|
87
|
+
code: z.ZodIssueCode.custom,
|
|
88
|
+
path: [index, 'name'],
|
|
89
|
+
message: `Duplicate variant name "${variant.name}".`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
seen.add(variant.name);
|
|
93
|
+
});
|
|
94
|
+
})
|
|
95
|
+
.default([]);
|
|
96
|
+
const impactSchema = z
|
|
97
|
+
.object({
|
|
98
|
+
/**
|
|
99
|
+
* A module (relative to the config file) whose default export maps changed files to
|
|
100
|
+
* scenarios. Viewev has no knowledge of how a repository relates files to UI.
|
|
101
|
+
*/
|
|
102
|
+
module: z.string().min(1),
|
|
103
|
+
/** The branch or commit the change is compared with. */
|
|
104
|
+
baseRef: z.string().min(1).default('origin/main'),
|
|
105
|
+
})
|
|
106
|
+
.strict()
|
|
107
|
+
.optional();
|
|
108
|
+
export const configSchema = z
|
|
109
|
+
.object({
|
|
110
|
+
provider: storybookProviderSchema,
|
|
111
|
+
/** Glob patterns matched against scenario ids. Empty means every scenario. */
|
|
112
|
+
include: z.array(z.string().min(1)).default([]),
|
|
113
|
+
exclude: z.array(z.string().min(1)).default([]),
|
|
114
|
+
browser: browserSchema,
|
|
115
|
+
viewport: viewportSchema.default({ width: 1280, height: 720 }),
|
|
116
|
+
capture: captureSchema,
|
|
117
|
+
comparison: comparisonSchema,
|
|
118
|
+
baselines: baselinesSchema,
|
|
119
|
+
report: reportSchema,
|
|
120
|
+
concurrency: z.number().int().min(1).max(32).default(4),
|
|
121
|
+
/**
|
|
122
|
+
* Every story is captured once per variant, with ids like "button--primary@g100".
|
|
123
|
+
* Without variants, every story is captured once, with the default viewport.
|
|
124
|
+
*/
|
|
125
|
+
variants: variantsSchema,
|
|
126
|
+
/** Optional: lets "viewev test --changed" run only the scenarios a change affects. */
|
|
127
|
+
impact: impactSchema,
|
|
128
|
+
})
|
|
129
|
+
.strict();
|
|
130
|
+
/** Identity helper that gives config files type checking and editor completion. */
|
|
131
|
+
export function defineConfig(config) {
|
|
132
|
+
return config;
|
|
133
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C,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/C,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC9D,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,eAAe;IAC1B,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD;;;OAGG;IACH,QAAQ,EAAE,cAAc;IACxB,sFAAsF;IACtF,MAAM,EAAE,YAAY;CACrB,CAAC;KACD,MAAM,EAAE,CAAC;AAQZ,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ScenarioId } from '../scenarios/model.js';
|
|
2
|
+
export type ArtifactKind = 'expected' | 'actual' | 'diff';
|
|
3
|
+
/** Stores the images a report needs. Returns a path relative to the report directory. */
|
|
4
|
+
export interface ArtifactWriter {
|
|
5
|
+
write(id: ScenarioId, kind: ArtifactKind, png: Uint8Array): Promise<string>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/core/artifacts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BaselineStore } from '../baselines/types.js';
|
|
2
|
+
import type { CaptureSession } from '../browser/types.js';
|
|
3
|
+
import type { ViewevConfig } from '../config/schema.js';
|
|
4
|
+
import type { VisualScenario } from '../scenarios/model.js';
|
|
5
|
+
export type BaselineMode = 'create' | 'update';
|
|
6
|
+
export type BaselineAction =
|
|
7
|
+
/** A new baseline was written. */
|
|
8
|
+
'created'
|
|
9
|
+
/** An existing baseline was replaced because the screenshot changed. */
|
|
10
|
+
| 'updated'
|
|
11
|
+
/** The screenshot is identical to the existing baseline; nothing was written. */
|
|
12
|
+
| 'unchanged'
|
|
13
|
+
/** `create` left an existing baseline alone. */
|
|
14
|
+
| 'kept' | 'error';
|
|
15
|
+
export interface BaselineResult {
|
|
16
|
+
readonly scenario: VisualScenario;
|
|
17
|
+
readonly action: BaselineAction;
|
|
18
|
+
readonly message?: string;
|
|
19
|
+
readonly clipped?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface BaselineRunDeps {
|
|
22
|
+
readonly session: CaptureSession;
|
|
23
|
+
readonly store: BaselineStore;
|
|
24
|
+
}
|
|
25
|
+
export interface BaselineRunOptions {
|
|
26
|
+
readonly mode: BaselineMode;
|
|
27
|
+
readonly config: ViewevConfig;
|
|
28
|
+
readonly scenarios: readonly VisualScenario[];
|
|
29
|
+
/** Allow replacing baselines that were captured with another Chromium or Playwright version. */
|
|
30
|
+
readonly allowEnvironmentChange: boolean;
|
|
31
|
+
readonly onResult?: (result: BaselineResult) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Writes baselines for the given scenarios. This is the only code path that changes
|
|
35
|
+
* baselines, and it only runs when the user explicitly asks for it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runBaselineWrite(deps: BaselineRunDeps, options: BaselineRunOptions): Promise<BaselineResult[]>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { environmentDifferences } from '../baselines/environment-check.js';
|
|
2
|
+
import { createMetadata, sha256Hex } from '../baselines/metadata.js';
|
|
3
|
+
import { captureRequestFor } from './capture-settings.js';
|
|
4
|
+
import { mapWithConcurrency } from './pool.js';
|
|
5
|
+
function describe(error) {
|
|
6
|
+
return error instanceof Error ? error.message : String(error);
|
|
7
|
+
}
|
|
8
|
+
async function processScenario(deps, options, scenario) {
|
|
9
|
+
const { session, store } = deps;
|
|
10
|
+
let existing;
|
|
11
|
+
let replacedUnreadable;
|
|
12
|
+
try {
|
|
13
|
+
existing = await store.read(scenario.id);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
// An unreadable baseline cannot be trusted. `create` must not touch it; `update` is how
|
|
17
|
+
// it gets replaced.
|
|
18
|
+
if (options.mode === 'create') {
|
|
19
|
+
return { scenario, action: 'error', message: describe(error) };
|
|
20
|
+
}
|
|
21
|
+
replacedUnreadable = describe(error);
|
|
22
|
+
}
|
|
23
|
+
if (options.mode === 'create' && existing !== undefined) {
|
|
24
|
+
return { scenario, action: 'kept' };
|
|
25
|
+
}
|
|
26
|
+
const captured = await session.capture(captureRequestFor(scenario, options.config));
|
|
27
|
+
if (!captured.ok) {
|
|
28
|
+
return {
|
|
29
|
+
scenario,
|
|
30
|
+
action: 'error',
|
|
31
|
+
message: `[${captured.error.phase}] ${captured.error.message}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const clipped = captured.clipped ? { clipped: true } : {};
|
|
35
|
+
if (existing !== undefined) {
|
|
36
|
+
const differences = environmentDifferences(existing.metadata.environment, session.environment);
|
|
37
|
+
if (differences.length > 0 && !options.allowEnvironmentChange) {
|
|
38
|
+
return {
|
|
39
|
+
scenario,
|
|
40
|
+
action: 'error',
|
|
41
|
+
message: `The existing baseline was captured in a different environment (${differences.join('; ')}). ` +
|
|
42
|
+
'Updating only some baselines would mix environments. Use --all to rebaseline everything, ' +
|
|
43
|
+
'or --allow-environment-change to override.',
|
|
44
|
+
...clipped,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (sha256Hex(captured.png) === existing.metadata.sha256) {
|
|
48
|
+
return { scenario, action: 'unchanged', ...clipped };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await store.write(scenario.id, {
|
|
53
|
+
png: captured.png,
|
|
54
|
+
metadata: createMetadata({
|
|
55
|
+
scenario,
|
|
56
|
+
environment: session.environment,
|
|
57
|
+
deviceScaleFactor: options.config.capture.deviceScaleFactor,
|
|
58
|
+
png: captured.png,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return { scenario, action: 'error', message: describe(error) };
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
scenario,
|
|
67
|
+
action: existing === undefined && replacedUnreadable === undefined ? 'created' : 'updated',
|
|
68
|
+
...(replacedUnreadable !== undefined
|
|
69
|
+
? { message: `replaced an unreadable baseline (${replacedUnreadable})` }
|
|
70
|
+
: {}),
|
|
71
|
+
...clipped,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Writes baselines for the given scenarios. This is the only code path that changes
|
|
76
|
+
* baselines, and it only runs when the user explicitly asks for it.
|
|
77
|
+
*/
|
|
78
|
+
export async function runBaselineWrite(deps, options) {
|
|
79
|
+
return mapWithConcurrency(options.scenarios, options.config.concurrency, async (scenario) => {
|
|
80
|
+
const result = await processScenario(deps, options, scenario);
|
|
81
|
+
options.onResult?.(result);
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=baseline-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline-run.js","sourceRoot":"","sources":["../../src/core/baseline-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW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AAE,CAAC;IACjE,CAAC;IAED,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,QAAQ,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC1F,GAAG,CAAC,kBAAkB,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE,OAAO,EAAE,oCAAoC,kBAAkB,GAAG,EAAE;YACxE,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,OAAO;KACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAqB,EACrB,OAA2B;IAE3B,OAAO,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC1F,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9D,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CaptureEnvironment, CaptureRequest } from '../browser/types.js';
|
|
2
|
+
import type { ViewevConfig } from '../config/schema.js';
|
|
3
|
+
import type { VisualScenario } from '../scenarios/model.js';
|
|
4
|
+
export declare function captureEnvironmentFrom(config: ViewevConfig): CaptureEnvironment;
|
|
5
|
+
/** Scenario-level options override the global capture settings. */
|
|
6
|
+
export declare function captureRequestFor(scenario: VisualScenario, config: ViewevConfig): CaptureRequest;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function captureEnvironmentFrom(config) {
|
|
2
|
+
return {
|
|
3
|
+
browser: config.browser.engine,
|
|
4
|
+
deviceScaleFactor: config.capture.deviceScaleFactor,
|
|
5
|
+
locale: config.capture.locale,
|
|
6
|
+
timezoneId: config.capture.timezoneId,
|
|
7
|
+
colorScheme: config.capture.colorScheme,
|
|
8
|
+
reducedMotion: config.capture.reducedMotion,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** Scenario-level options override the global capture settings. */
|
|
12
|
+
export function captureRequestFor(scenario, config) {
|
|
13
|
+
return {
|
|
14
|
+
url: scenario.target.url,
|
|
15
|
+
viewport: scenario.viewport,
|
|
16
|
+
waitForSelector: scenario.capture?.waitForSelector,
|
|
17
|
+
disableAnimations: scenario.capture?.disableAnimations ?? config.capture.disableAnimations,
|
|
18
|
+
timeoutMs: config.capture.timeoutMs,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=capture-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-settings.js","sourceRoot":"","sources":["../../src/core/capture-settings.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IACzD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;QAC9B,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB;QACnD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;QAC7B,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;QACrC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;QACvC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;KAC5C,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,iBAAiB,CAAC,QAAwB,EAAE,MAAoB;IAC9E,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG;QACxB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,eAAe,EAAE,QAAQ,CAAC,OAAO,EAAE,eAAe;QAClD,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,iBAAiB,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB;QAC1F,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ScenarioProvider, ScenarioProviderContext, VisualScenario } from '../scenarios/model.js';
|
|
2
|
+
/** Runs a provider and validates what it returns. */
|
|
3
|
+
export declare function discoverScenarios(provider: ScenarioProvider, context: ScenarioProviderContext): Promise<VisualScenario[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { validateScenarios } from '../scenarios/schema.js';
|
|
2
|
+
import { ExitCode, ViewevError } from '../shared/errors.js';
|
|
3
|
+
/** Runs a provider and validates what it returns. */
|
|
4
|
+
export async function discoverScenarios(provider, context) {
|
|
5
|
+
let found;
|
|
6
|
+
try {
|
|
7
|
+
found = await provider.discover(context);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof ViewevError)
|
|
11
|
+
throw error;
|
|
12
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
13
|
+
throw new ViewevError(`Scenario provider "${provider.name}" failed: ${reason}`, ExitCode.ExecutionError, { cause: error });
|
|
14
|
+
}
|
|
15
|
+
return validateScenarios(found, provider.name);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/core/discovery.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5D,qDAAqD;AACrD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAA0B,EAC1B,OAAgC;IAEhC,IAAI,KAAgC,CAAC;IACrC,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW;YAAE,MAAM,KAAK,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,WAAW,CACnB,sBAAsB,QAAQ,CAAC,IAAI,aAAa,MAAM,EAAE,EACxD,QAAQ,CAAC,cAAc,EACvB,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ImpactSelection } from '../impact/types.js';
|
|
2
|
+
import type { VisualScenario } from '../scenarios/model.js';
|
|
3
|
+
import type { SelectionInfo } from './result.js';
|
|
4
|
+
export interface ImpactContext {
|
|
5
|
+
readonly baseRef: string;
|
|
6
|
+
readonly changedFileCount: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ImpactPlan {
|
|
9
|
+
readonly selected: VisualScenario[];
|
|
10
|
+
readonly info: SelectionInfo;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Narrows `scenarios` (already filtered by include, exclude and --filter) to the ones the
|
|
14
|
+
* analysis selected. Ids the analysis names that are not in `scenarios` are ignored: the user
|
|
15
|
+
* may have filtered them out.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyImpact(scenarios: readonly VisualScenario[], selection: ImpactSelection, context: ImpactContext): ImpactPlan;
|
|
18
|
+
/** A selection that runs everything, used when the analysis cannot be trusted. */
|
|
19
|
+
export declare function fallbackToAll(reason: string): ImpactSelection;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrows `scenarios` (already filtered by include, exclude and --filter) to the ones the
|
|
3
|
+
* analysis selected. Ids the analysis names that are not in `scenarios` are ignored: the user
|
|
4
|
+
* may have filtered them out.
|
|
5
|
+
*/
|
|
6
|
+
export function applyImpact(scenarios, selection, context) {
|
|
7
|
+
const base = {
|
|
8
|
+
total: scenarios.length,
|
|
9
|
+
baseRef: context.baseRef,
|
|
10
|
+
changedFileCount: context.changedFileCount,
|
|
11
|
+
};
|
|
12
|
+
if (selection.mode === 'all') {
|
|
13
|
+
return {
|
|
14
|
+
selected: [...scenarios],
|
|
15
|
+
info: { mode: 'all', selected: scenarios.length, reason: selection.reason, ...base },
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const selected = scenarios.filter((scenario) => Object.hasOwn(selection.scenarios, scenario.id));
|
|
19
|
+
const reasons = {};
|
|
20
|
+
for (const scenario of selected)
|
|
21
|
+
reasons[scenario.id] = selection.scenarios[scenario.id] ?? [];
|
|
22
|
+
return { selected, info: { mode: 'impact', selected: selected.length, reasons, ...base } };
|
|
23
|
+
}
|
|
24
|
+
/** A selection that runs everything, used when the analysis cannot be trusted. */
|
|
25
|
+
export function fallbackToAll(reason) {
|
|
26
|
+
return { mode: 'all', reason };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=impact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact.js","sourceRoot":"","sources":["../../src/core/impact.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,SAAoC,EACpC,SAA0B,EAC1B,OAAsB;IAEtB,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,SAAS,CAAC,MAAM;QACvB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;KAC3C,CAAC;IAEF,IAAI,SAAS,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO;YACL,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE;SACrF,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACjG,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,KAAK,MAAM,QAAQ,IAAI,QAAQ;QAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IAE/F,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;AAC7F,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `task` for every item with at most `limit` tasks in flight and returns the results in
|
|
3
|
+
* the order of `items`. `task` must handle its own errors; a thrown error rejects the whole call.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, task: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `task` for every item with at most `limit` tasks in flight and returns the results in
|
|
3
|
+
* the order of `items`. `task` must handle its own errors; a thrown error rejects the whole call.
|
|
4
|
+
*/
|
|
5
|
+
export async function mapWithConcurrency(items, limit, task) {
|
|
6
|
+
const results = new Array(items.length);
|
|
7
|
+
let next = 0;
|
|
8
|
+
async function worker() {
|
|
9
|
+
for (;;) {
|
|
10
|
+
const index = next;
|
|
11
|
+
next += 1;
|
|
12
|
+
if (index >= items.length)
|
|
13
|
+
return;
|
|
14
|
+
results[index] = await task(items[index], index);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const workers = Math.max(1, Math.min(limit, items.length));
|
|
18
|
+
await Promise.all(Array.from({ length: workers }, () => worker()));
|
|
19
|
+
return results;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/core/pool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAmB,EACnB,KAAa,EACb,IAA4C;IAE5C,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,KAAK,UAAU,MAAM;QACnB,SAAS,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC;YACnB,IAAI,IAAI,CAAC,CAAC;YACV,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM;gBAAE,OAAO;YAClC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { DiffStats } from '../comparison/types.js';
|
|
2
|
+
import type { ScenarioId, VisualScenario } from '../scenarios/model.js';
|
|
3
|
+
import { ExitCode } from '../shared/errors.js';
|
|
4
|
+
import type { EnvironmentInfo } from '../shared/environment.js';
|
|
5
|
+
import type { Size } from '../shared/size.js';
|
|
6
|
+
/** Paths are relative to the report directory so a report can be moved as a unit. */
|
|
7
|
+
export interface ArtifactPaths {
|
|
8
|
+
readonly expected?: string;
|
|
9
|
+
readonly actual?: string;
|
|
10
|
+
readonly diff?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ScenarioError {
|
|
13
|
+
readonly phase: 'discover' | 'navigate' | 'ready' | 'stabilize' | 'screenshot' | 'compare' | 'baseline';
|
|
14
|
+
readonly message: string;
|
|
15
|
+
}
|
|
16
|
+
export type ScenarioOutcome = {
|
|
17
|
+
readonly status: 'passed';
|
|
18
|
+
readonly stats: DiffStats;
|
|
19
|
+
} | {
|
|
20
|
+
readonly status: 'regression';
|
|
21
|
+
readonly cause: 'pixels';
|
|
22
|
+
readonly stats: DiffStats;
|
|
23
|
+
readonly artifacts: ArtifactPaths;
|
|
24
|
+
} | {
|
|
25
|
+
readonly status: 'regression';
|
|
26
|
+
readonly cause: 'dimensions';
|
|
27
|
+
readonly expected: Size;
|
|
28
|
+
readonly actual: Size;
|
|
29
|
+
readonly artifacts: ArtifactPaths;
|
|
30
|
+
} | {
|
|
31
|
+
readonly status: 'changed';
|
|
32
|
+
readonly change: 'added';
|
|
33
|
+
readonly artifacts: ArtifactPaths;
|
|
34
|
+
} | {
|
|
35
|
+
readonly status: 'changed';
|
|
36
|
+
readonly change: 'modified';
|
|
37
|
+
readonly cause: 'pixels';
|
|
38
|
+
readonly stats: DiffStats;
|
|
39
|
+
readonly artifacts: ArtifactPaths;
|
|
40
|
+
} | {
|
|
41
|
+
readonly status: 'changed';
|
|
42
|
+
readonly change: 'modified';
|
|
43
|
+
readonly cause: 'dimensions';
|
|
44
|
+
readonly expected: Size;
|
|
45
|
+
readonly actual: Size;
|
|
46
|
+
readonly artifacts: ArtifactPaths;
|
|
47
|
+
} | {
|
|
48
|
+
readonly status: 'missing-baseline';
|
|
49
|
+
readonly artifacts: ArtifactPaths;
|
|
50
|
+
} | {
|
|
51
|
+
readonly status: 'error';
|
|
52
|
+
readonly error: ScenarioError;
|
|
53
|
+
};
|
|
54
|
+
export interface ScenarioResult {
|
|
55
|
+
readonly scenario: VisualScenario;
|
|
56
|
+
readonly outcome: ScenarioOutcome;
|
|
57
|
+
readonly durationMs: number;
|
|
58
|
+
/** True when the page was larger than the viewport, so the screenshot shows only part of it. */
|
|
59
|
+
readonly clipped?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** How the scenarios of a run were chosen, when impact analysis took part. */
|
|
62
|
+
export interface SelectionInfo {
|
|
63
|
+
/** "all": every scenario runs (possibly as a fallback). "impact": only affected ones run. */
|
|
64
|
+
readonly mode: 'all' | 'impact';
|
|
65
|
+
/** Scenarios that passed the filters, before impact analysis. */
|
|
66
|
+
readonly total: number;
|
|
67
|
+
readonly selected: number;
|
|
68
|
+
readonly baseRef?: string;
|
|
69
|
+
readonly changedFileCount?: number;
|
|
70
|
+
/** Why every scenario runs, when it is a fallback or a decision of the analysis. */
|
|
71
|
+
readonly reason?: string;
|
|
72
|
+
/** For each selected scenario, why it was selected. */
|
|
73
|
+
readonly reasons?: Readonly<Record<string, readonly string[]>>;
|
|
74
|
+
}
|
|
75
|
+
export interface RunResult {
|
|
76
|
+
readonly startedAt: string;
|
|
77
|
+
readonly durationMs: number;
|
|
78
|
+
readonly environment?: EnvironmentInfo;
|
|
79
|
+
readonly scenarios: readonly ScenarioResult[];
|
|
80
|
+
/** Baselines that exist on disk but no longer have a scenario. */
|
|
81
|
+
readonly obsolete: readonly ScenarioId[];
|
|
82
|
+
/** Obsolete baselines that the change itself removes, so they do not fail the run. */
|
|
83
|
+
readonly removed?: readonly ScenarioId[];
|
|
84
|
+
/** Problems that did not fail the run, for example baselines from another Chromium version. */
|
|
85
|
+
readonly warnings?: readonly string[];
|
|
86
|
+
/** Present when the scenarios were chosen by impact analysis ("viewev test --changed"). */
|
|
87
|
+
readonly selection?: SelectionInfo;
|
|
88
|
+
}
|
|
89
|
+
export interface RunSummary {
|
|
90
|
+
readonly total: number;
|
|
91
|
+
readonly passed: number;
|
|
92
|
+
readonly regressions: number;
|
|
93
|
+
/** Visual changes that the change proposes baselines for. They do not fail the run. */
|
|
94
|
+
readonly changed: number;
|
|
95
|
+
readonly missingBaselines: number;
|
|
96
|
+
readonly errors: number;
|
|
97
|
+
readonly obsolete: number;
|
|
98
|
+
readonly removed: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ExitPolicy {
|
|
101
|
+
readonly failOnObsolete: boolean;
|
|
102
|
+
}
|
|
103
|
+
export declare function summarize(result: RunResult): RunSummary;
|
|
104
|
+
/**
|
|
105
|
+
* Execution errors win over visual failures: an incomplete run cannot be trusted to have
|
|
106
|
+
* found every regression, so it is surfaced as the more serious condition.
|
|
107
|
+
*
|
|
108
|
+
* "changed" scenarios never fail the run. They are approved by reviewing and merging the
|
|
109
|
+
* baseline changes in the pull request, not by this process.
|
|
110
|
+
*/
|
|
111
|
+
export declare function exitCodeFor(summary: RunSummary, policy: ExitPolicy): ExitCode;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ExitCode } from '../shared/errors.js';
|
|
2
|
+
export function summarize(result) {
|
|
3
|
+
let passed = 0;
|
|
4
|
+
let regressions = 0;
|
|
5
|
+
let changed = 0;
|
|
6
|
+
let missingBaselines = 0;
|
|
7
|
+
let errors = 0;
|
|
8
|
+
for (const { outcome } of result.scenarios) {
|
|
9
|
+
switch (outcome.status) {
|
|
10
|
+
case 'passed':
|
|
11
|
+
passed += 1;
|
|
12
|
+
break;
|
|
13
|
+
case 'regression':
|
|
14
|
+
regressions += 1;
|
|
15
|
+
break;
|
|
16
|
+
case 'changed':
|
|
17
|
+
changed += 1;
|
|
18
|
+
break;
|
|
19
|
+
case 'missing-baseline':
|
|
20
|
+
missingBaselines += 1;
|
|
21
|
+
break;
|
|
22
|
+
case 'error':
|
|
23
|
+
errors += 1;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
total: result.scenarios.length,
|
|
29
|
+
passed,
|
|
30
|
+
regressions,
|
|
31
|
+
changed,
|
|
32
|
+
missingBaselines,
|
|
33
|
+
errors,
|
|
34
|
+
obsolete: result.obsolete.length,
|
|
35
|
+
removed: result.removed?.length ?? 0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Execution errors win over visual failures: an incomplete run cannot be trusted to have
|
|
40
|
+
* found every regression, so it is surfaced as the more serious condition.
|
|
41
|
+
*
|
|
42
|
+
* "changed" scenarios never fail the run. They are approved by reviewing and merging the
|
|
43
|
+
* baseline changes in the pull request, not by this process.
|
|
44
|
+
*/
|
|
45
|
+
export function exitCodeFor(summary, policy) {
|
|
46
|
+
if (summary.errors > 0)
|
|
47
|
+
return ExitCode.ExecutionError;
|
|
48
|
+
const visualFailures = summary.regressions + summary.missingBaselines + (policy.failOnObsolete ? summary.obsolete : 0);
|
|
49
|
+
if (visualFailures > 0)
|
|
50
|
+
return ExitCode.VisualFailure;
|
|
51
|
+
return ExitCode.Ok;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAiH/C,MAAM,UAAU,SAAS,CAAC,MAAiB;IACzC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,gBAAgB,GAAG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ualScenario } from '../scenarios/model.js';
|
|
2
|
+
export interface SelectionFilters {
|
|
3
|
+
/** Glob patterns matched against scenario ids. Empty means every scenario. */
|
|
4
|
+
readonly include: readonly string[];
|
|
5
|
+
/** Exclusion wins over inclusion. */
|
|
6
|
+
readonly exclude: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function selectScenarios(scenarios: readonly VisualScenario[], filters: SelectionFilters): VisualScenario[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { matchesAnyGlob } from '../scenarios/glob.js';
|
|
2
|
+
export function selectScenarios(scenarios, filters) {
|
|
3
|
+
return scenarios.filter((scenario) => {
|
|
4
|
+
const included = filters.include.length === 0 || matchesAnyGlob(scenario.id, filters.include);
|
|
5
|
+
return included && !matchesAnyGlob(scenario.id, filters.exclude);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/core/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAUtD,MAAM,UAAU,eAAe,CAC7B,SAAoC,EACpC,OAAyB;IAEzB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9F,OAAO,QAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC"}
|