@recursica/adapter-tester 5.1.1 → 5.1.3
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 +6 -6
- package/dist/adapter-tester.schema.json.d.ts +2 -2
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/fileConfig.d.ts +1 -1
- package/dist/fileConfig.d.ts.map +1 -1
- package/dist/golden/resolveSourceOfTruthGolden.d.ts +5 -4
- package/dist/golden/resolveSourceOfTruthGolden.d.ts.map +1 -1
- package/dist/harness/mantineSourceOfTruth.d.ts +2 -2
- package/dist/harness/mantineSourceOfTruth.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{mantineSourceOfTruth-DE7XOgea.js → mantineSourceOfTruth-BDJ5mfpd.js} +7 -7
- package/dist/mantineSourceOfTruth-BDJ5mfpd.js.map +1 -0
- package/dist/{mantineSourceOfTruth-Dpe4mlmF.cjs → mantineSourceOfTruth-CdRlVrRC.cjs} +5 -5
- package/dist/mantineSourceOfTruth-CdRlVrRC.cjs.map +1 -0
- package/dist/testing/runVisualRegression.d.ts.map +1 -1
- package/dist/testing.cjs +4 -4
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +154 -149
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/src/adapter-tester.schema.json +2 -2
- package/dist/mantineSourceOfTruth-DE7XOgea.js.map +0 -1
- package/dist/mantineSourceOfTruth-Dpe4mlmF.cjs.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { expect as D } from "@playwright/test";
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import
|
|
2
|
+
import { existsSync as y, unlinkSync as Y, readFileSync as E, mkdirSync as b, writeFileSync as A, closeSync as Q, openSync as Z, renameSync as ee, rmSync as te } from "node:fs";
|
|
3
|
+
import re from "pixelmatch";
|
|
4
4
|
import { PNG as j } from "pngjs";
|
|
5
5
|
import { join as M } from "node:path";
|
|
6
|
-
import { a as
|
|
7
|
-
function
|
|
6
|
+
import { a as oe, i as ne } from "./index-DqQzFSAH.js";
|
|
7
|
+
function R(e, t) {
|
|
8
8
|
const o = j.sync.read(e), r = j.sync.read(t);
|
|
9
9
|
if (o.width !== r.width || o.height !== r.height)
|
|
10
10
|
return { diffPixels: 1 / 0, diffImage: null };
|
|
11
11
|
const s = new j({ width: o.width, height: o.height });
|
|
12
|
-
return { diffPixels:
|
|
12
|
+
return { diffPixels: re(
|
|
13
13
|
o.data,
|
|
14
14
|
r.data,
|
|
15
15
|
s.data,
|
|
@@ -18,21 +18,21 @@ function J(e, t) {
|
|
|
18
18
|
{ threshold: 0.1 }
|
|
19
19
|
), diffImage: j.sync.write(s) };
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
$schema:
|
|
23
|
-
$id:
|
|
24
|
-
title:
|
|
25
|
-
description:
|
|
26
|
-
type:
|
|
27
|
-
additionalProperties:
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
const
|
|
21
|
+
const se = "http://json-schema.org/draft-07/schema#", ie = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json", ae = "test/golden/manifest.json", ce = "Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.", de = "object", he = { type: "object", additionalProperties: !1, required: ["createdAt"], properties: { createdAt: { type: "string", format: "date-time", description: "When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create." }, sourceOfTruthCreatedAt: { type: "string", format: "date-time", description: "The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review." } } }, ue = {
|
|
22
|
+
$schema: se,
|
|
23
|
+
$id: ie,
|
|
24
|
+
title: ae,
|
|
25
|
+
description: ce,
|
|
26
|
+
type: de,
|
|
27
|
+
additionalProperties: he
|
|
28
|
+
}, fe = ne, q = new oe.Ajv({ allErrors: !0, strict: !0 });
|
|
29
|
+
fe(q);
|
|
30
|
+
const U = q.compile(ue);
|
|
31
31
|
function L(e, t) {
|
|
32
|
-
if (
|
|
33
|
-
const o = (
|
|
34
|
-
var
|
|
35
|
-
const s = (
|
|
32
|
+
if (U(e)) return;
|
|
33
|
+
const o = (U.errors ?? []).map((r) => {
|
|
34
|
+
var a;
|
|
35
|
+
const s = (a = r.params) != null && a.additionalProperty ? ` '${r.params.additionalProperty}'` : "";
|
|
36
36
|
return ` - ${r.instancePath || "root"} ${r.message}${s}`;
|
|
37
37
|
}).join(`
|
|
38
38
|
`);
|
|
@@ -42,7 +42,7 @@ ${o}`);
|
|
|
42
42
|
function G(e) {
|
|
43
43
|
return M(e, "manifest.json");
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function V(e) {
|
|
46
46
|
return M(e, "manifest.json.lock");
|
|
47
47
|
}
|
|
48
48
|
function S(e, t) {
|
|
@@ -50,7 +50,7 @@ function S(e, t) {
|
|
|
50
50
|
}
|
|
51
51
|
function P(e) {
|
|
52
52
|
const t = G(e);
|
|
53
|
-
if (!
|
|
53
|
+
if (!y(t)) return {};
|
|
54
54
|
const o = JSON.parse(E(t, "utf8"));
|
|
55
55
|
return L(o, t), o;
|
|
56
56
|
}
|
|
@@ -58,23 +58,23 @@ function le(e, t) {
|
|
|
58
58
|
const o = G(e);
|
|
59
59
|
L(t, o);
|
|
60
60
|
const r = {};
|
|
61
|
-
for (const
|
|
62
|
-
r[
|
|
61
|
+
for (const a of Object.keys(t).sort())
|
|
62
|
+
r[a] = t[a];
|
|
63
63
|
b(e, { recursive: !0 });
|
|
64
64
|
const s = `${o}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
|
|
65
65
|
A(s, JSON.stringify(r, null, 2) + `
|
|
66
|
-
`),
|
|
66
|
+
`), ee(s, o);
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
function
|
|
68
|
+
const pe = 25, me = 15e3;
|
|
69
|
+
function ge(e) {
|
|
70
70
|
return new Promise((t) => setTimeout(t, e));
|
|
71
71
|
}
|
|
72
|
-
async function
|
|
72
|
+
async function we(e) {
|
|
73
73
|
b(e, { recursive: !0 });
|
|
74
|
-
const t =
|
|
74
|
+
const t = V(e), o = Date.now() + me;
|
|
75
75
|
for (; ; )
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
Q(Z(t, "wx"));
|
|
78
78
|
return;
|
|
79
79
|
} catch (r) {
|
|
80
80
|
if (r.code !== "EEXIST") throw r;
|
|
@@ -82,107 +82,107 @@ async function ge(e) {
|
|
|
82
82
|
throw new Error(
|
|
83
83
|
`Timed out waiting for the manifest lock at "${t}" — delete it if a previous run crashed while holding it.`
|
|
84
84
|
);
|
|
85
|
-
await
|
|
85
|
+
await ge(pe);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
88
|
+
function ye(e) {
|
|
89
|
+
te(V(e), { force: !0 });
|
|
90
90
|
}
|
|
91
|
-
async function
|
|
92
|
-
await
|
|
91
|
+
async function W(e, t, o) {
|
|
92
|
+
await we(e);
|
|
93
93
|
try {
|
|
94
94
|
const r = P(e), s = o(r[t]);
|
|
95
95
|
return s === void 0 ? delete r[t] : r[t] = s, le(e, r), s;
|
|
96
96
|
} finally {
|
|
97
|
-
|
|
97
|
+
ye(e);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ve(e, t, o) {
|
|
101
101
|
b(e, { recursive: !0 }), A(S(e, t), o);
|
|
102
102
|
}
|
|
103
|
-
async function
|
|
103
|
+
async function Te(e, t) {
|
|
104
104
|
const o = P(e), r = Object.keys(o).filter(
|
|
105
105
|
(s) => !t.has(s)
|
|
106
106
|
);
|
|
107
107
|
for (const s of r) {
|
|
108
|
-
const
|
|
109
|
-
|
|
108
|
+
const a = S(e, s);
|
|
109
|
+
y(a) && Y(a), await W(e, s, () => {
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
return r;
|
|
113
113
|
}
|
|
114
|
-
const
|
|
114
|
+
const J = "borderux/recursica-adapter-mantine-v8";
|
|
115
115
|
async function $e(e, t) {
|
|
116
|
-
var
|
|
116
|
+
var a, d;
|
|
117
117
|
const o = await fetch(`https://registry.npmjs.org/${e}`);
|
|
118
118
|
if (!o.ok)
|
|
119
119
|
throw new Error(
|
|
120
120
|
`Could not reach npm registry for ${e}: ${o.statusText}`
|
|
121
121
|
);
|
|
122
|
-
const r = await o.json(), s = ((
|
|
122
|
+
const r = await o.json(), s = ((a = r["dist-tags"]) == null ? void 0 : a[t]) ?? ((d = r.versions) != null && d[t] ? t : void 0);
|
|
123
123
|
if (!s)
|
|
124
124
|
throw new Error(
|
|
125
125
|
`${e} has no version or dist-tag "${t}" on the npm registry.`
|
|
126
126
|
);
|
|
127
127
|
return s;
|
|
128
128
|
}
|
|
129
|
-
function Oe(e) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
async function Oe(e) {
|
|
130
|
+
if (e.type === "local") {
|
|
131
|
+
if (!y(G(e.dir)))
|
|
132
|
+
throw new Error(
|
|
133
|
+
`No golden baseline found at ${e.dir} — the source-of-truth divergence check has nothing to compare against. Capture one there first (--update-golden), or fix sourceOfTruth.dir if it's pointing at the wrong checkout.`
|
|
134
|
+
);
|
|
135
|
+
return {
|
|
135
136
|
manifest: P(e.dir),
|
|
136
|
-
async readImage(
|
|
137
|
-
const c = S(e.dir,
|
|
138
|
-
return
|
|
137
|
+
async readImage(h) {
|
|
138
|
+
const c = S(e.dir, h);
|
|
139
|
+
return y(c) ? E(c) : null;
|
|
139
140
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
), null);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
143
|
let t;
|
|
144
144
|
try {
|
|
145
145
|
t = await $e(
|
|
146
146
|
e.packageName,
|
|
147
147
|
e.versionSpec
|
|
148
148
|
);
|
|
149
|
-
} catch (
|
|
150
|
-
|
|
151
|
-
`Could not resolve ${e.packageName}@${e.versionSpec} — source-of-truth divergence check
|
|
152
|
-
|
|
153
|
-
)
|
|
149
|
+
} catch (i) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Could not resolve ${e.packageName}@${e.versionSpec} on the npm registry — the source-of-truth divergence check has nothing to compare against.`,
|
|
152
|
+
{ cause: i }
|
|
153
|
+
);
|
|
154
154
|
}
|
|
155
|
-
const o = M(e.cacheDir, t), r = `${e.packageName}@${t}`, s = `https://raw.githubusercontent.com/${
|
|
156
|
-
let
|
|
155
|
+
const o = M(e.cacheDir, t), r = `${e.packageName}@${t}`, s = `https://raw.githubusercontent.com/${J}/${r}/test/golden`;
|
|
156
|
+
let a;
|
|
157
157
|
const d = G(o);
|
|
158
|
-
if (
|
|
159
|
-
|
|
158
|
+
if (y(d))
|
|
159
|
+
a = P(o);
|
|
160
160
|
else {
|
|
161
|
-
let
|
|
161
|
+
let i;
|
|
162
162
|
try {
|
|
163
|
-
|
|
163
|
+
i = await fetch(`${s}/manifest.json`);
|
|
164
164
|
} catch (m) {
|
|
165
|
-
|
|
166
|
-
`Could not reach GitHub to fetch ${r}'s golden baseline — source-of-truth divergence check
|
|
167
|
-
m
|
|
168
|
-
)
|
|
165
|
+
throw new Error(
|
|
166
|
+
`Could not reach GitHub to fetch ${r}'s golden baseline (${s}/manifest.json) — the source-of-truth divergence check has nothing to compare against.`,
|
|
167
|
+
{ cause: m }
|
|
168
|
+
);
|
|
169
169
|
}
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
`No golden baseline published for ${r} — source-of-truth divergence check
|
|
173
|
-
)
|
|
174
|
-
const
|
|
175
|
-
L(c, `${s}/manifest.json`), b(o, { recursive: !0 }), A(d,
|
|
170
|
+
if (!i.ok)
|
|
171
|
+
throw new Error(
|
|
172
|
+
`No golden baseline published for tag "${r}" in ${J} (${s}/manifest.json returned ${i.status}) — the source-of-truth divergence check has nothing to compare against. Confirm that tag exists and its release actually published test/golden/.`
|
|
173
|
+
);
|
|
174
|
+
const h = await i.text(), c = JSON.parse(h);
|
|
175
|
+
L(c, `${s}/manifest.json`), b(o, { recursive: !0 }), A(d, h), a = c;
|
|
176
176
|
}
|
|
177
177
|
return {
|
|
178
|
-
manifest:
|
|
179
|
-
async readImage(
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
const c = await fetch(`${s}/${
|
|
178
|
+
manifest: a,
|
|
179
|
+
async readImage(i) {
|
|
180
|
+
const h = S(o, i);
|
|
181
|
+
if (y(h)) return E(h);
|
|
182
|
+
const c = await fetch(`${s}/${i}.png`);
|
|
183
183
|
if (!c.ok) return null;
|
|
184
184
|
const m = Buffer.from(await c.arrayBuffer());
|
|
185
|
-
return b(o, { recursive: !0 }), A(
|
|
185
|
+
return b(o, { recursive: !0 }), A(h, m), m;
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
}
|
|
@@ -190,7 +190,7 @@ const xe = ["Theme", "Tokens", "Introduction"];
|
|
|
190
190
|
function N(e, t) {
|
|
191
191
|
return e === t || e.startsWith(t);
|
|
192
192
|
}
|
|
193
|
-
async function
|
|
193
|
+
async function ke(e, t) {
|
|
194
194
|
let o;
|
|
195
195
|
try {
|
|
196
196
|
const r = await fetch(`${e.url}/index.json`);
|
|
@@ -198,12 +198,12 @@ async function be(e, t) {
|
|
|
198
198
|
throw new Error(
|
|
199
199
|
`Failed to fetch Storybook index: ${r.statusText}`
|
|
200
200
|
);
|
|
201
|
-
const
|
|
202
|
-
o = Object.values(
|
|
201
|
+
const a = (await r.json()).entries || {};
|
|
202
|
+
o = Object.values(a).filter(
|
|
203
203
|
(d) => d.type === "story" && !t.some(
|
|
204
|
-
(
|
|
204
|
+
(i) => d.title === i || d.title.startsWith(`${i}/`)
|
|
205
205
|
)
|
|
206
|
-
), o.sort((d,
|
|
206
|
+
), o.sort((d, i) => d.id.localeCompare(i.id));
|
|
207
207
|
} catch (r) {
|
|
208
208
|
throw console.error(
|
|
209
209
|
"Failed to load Storybook index from",
|
|
@@ -215,13 +215,13 @@ async function be(e, t) {
|
|
|
215
215
|
}
|
|
216
216
|
return o;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function K(e, t, o) {
|
|
219
219
|
let r;
|
|
220
220
|
for (const s of Object.keys(t))
|
|
221
221
|
N(e, s) && (!r || s.length > r.length) && (r = s);
|
|
222
222
|
return r !== void 0 ? t[r] : o;
|
|
223
223
|
}
|
|
224
|
-
async function
|
|
224
|
+
async function Ge(e) {
|
|
225
225
|
const t = e.isSourceOfTruthAdapter ? e.targets[0] : e.targets.find((n) => !n.sourceOfTruth);
|
|
226
226
|
if (!t)
|
|
227
227
|
throw new Error(
|
|
@@ -229,24 +229,24 @@ async function Me(e) {
|
|
|
229
229
|
);
|
|
230
230
|
const o = e.excludeTitlePrefixes ?? xe, r = e.stories ?? {}, s = Object.keys(r).filter(
|
|
231
231
|
(n) => r[n].exclude
|
|
232
|
-
),
|
|
233
|
-
Object.entries(r).filter(([, n]) => n.goldenThreshold !== void 0).map(([n,
|
|
232
|
+
), a = Object.fromEntries(
|
|
233
|
+
Object.entries(r).filter(([, n]) => n.goldenThreshold !== void 0).map(([n, u]) => [n, u.goldenThreshold])
|
|
234
234
|
), d = Object.fromEntries(
|
|
235
|
-
Object.entries(r).filter(([, n]) => n.sourceOfTruthThreshold !== void 0).map(([n,
|
|
236
|
-
),
|
|
237
|
-
(n) => !s.some((
|
|
235
|
+
Object.entries(r).filter(([, n]) => n.sourceOfTruthThreshold !== void 0).map(([n, u]) => [n, u.sourceOfTruthThreshold])
|
|
236
|
+
), i = e.goldenDir, h = e.goldenMode, c = e.checkMode, m = await ke(t, o), C = m.filter(
|
|
237
|
+
(n) => !s.some((u) => N(n.id, u))
|
|
238
238
|
);
|
|
239
|
-
if (
|
|
240
|
-
const n = await
|
|
241
|
-
|
|
242
|
-
new Set(
|
|
239
|
+
if (h === "update-golden") {
|
|
240
|
+
const n = await Te(
|
|
241
|
+
i,
|
|
242
|
+
new Set(C.map((u) => u.id))
|
|
243
243
|
);
|
|
244
244
|
n.length > 0 && console.warn(
|
|
245
245
|
`Pruned ${n.length} orphaned golden(s) no longer in Storybook: ${n.join(", ")}`
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
|
-
const
|
|
249
|
-
(n) => !
|
|
248
|
+
const v = c !== "divergence" || e.isSourceOfTruthAdapter || !e.sourceOfTruthGolden ? null : await Oe(e.sourceOfTruthGolden), X = new Set(m.map((n) => n.id)), T = v ? Object.keys(v.manifest).filter(
|
|
249
|
+
(n) => !X.has(n) && !s.some((u) => N(n, u))
|
|
250
250
|
).sort() : [];
|
|
251
251
|
T.length > 0 && console.error(
|
|
252
252
|
`[adapter-tester] ${T.length} stor(y/ies) exist in the source of truth but are missing here: ${T.join(", ")}. Add the missing story, or mark it \`exclude: true\` under \`stories\` in adapter-tester.config.json if intentional.`
|
|
@@ -254,118 +254,123 @@ async function Me(e) {
|
|
|
254
254
|
[
|
|
255
255
|
`[adapter-tester] target: "${t.name}" (${t.url})`,
|
|
256
256
|
`[adapter-tester] checkMode: "${c}" (${c === "divergence" ? "live render vs source-of-truth's golden" : "live render vs this project's own golden"})`,
|
|
257
|
-
`[adapter-tester] goldenMode: "${
|
|
257
|
+
`[adapter-tester] goldenMode: "${h}"`,
|
|
258
258
|
`[adapter-tester] goldenThresholdPixels: ${e.goldenThresholdPixels}`,
|
|
259
259
|
`[adapter-tester] sourceOfTruthThresholdPixels: ${e.sourceOfTruthThresholdPixels}`,
|
|
260
|
-
c === "divergence" ? e.isSourceOfTruthAdapter ? "[adapter-tester] sourceOfTruthGolden: skipped — this is the source-of-truth adapter, nothing to diverge from" : e.sourceOfTruthGolden ?
|
|
261
|
-
|
|
260
|
+
c === "divergence" ? e.isSourceOfTruthAdapter ? "[adapter-tester] sourceOfTruthGolden: skipped — this is the source-of-truth adapter, nothing to diverge from" : e.sourceOfTruthGolden ? (
|
|
261
|
+
// Unresolvable-baseline case never reaches here — resolveSourceOfTruthGolden
|
|
262
|
+
// throws instead of returning null, failing the whole run before this
|
|
263
|
+
// logs, rather than letting the divergence check silently no-op.
|
|
264
|
+
`[adapter-tester] sourceOfTruthGolden: resolved, ${Object.keys(v.manifest).length} golden(s) available (config: ${JSON.stringify(e.sourceOfTruthGolden)})`
|
|
265
|
+
) : "[adapter-tester] sourceOfTruthGolden: skipped — no sourceOfTruthGolden configured" : '[adapter-tester] sourceOfTruthGolden: not used in "own" checkMode',
|
|
266
|
+
`[adapter-tester] stories: ${C.length} to check (excluded: ${s.length}, title prefixes excluded: ${o.join(", ") || "none"})`,
|
|
262
267
|
`[adapter-tester] story parity with source of truth: ${T.length === 0 ? "OK" : `${T.length} missing (see error above)`}`
|
|
263
268
|
].join(`
|
|
264
269
|
`)
|
|
265
270
|
);
|
|
266
|
-
const
|
|
271
|
+
const z = c === "divergence" ? "Source-of-Truth Divergence Check" : "Own-Drift Golden Image Check";
|
|
267
272
|
return {
|
|
268
273
|
ownTargetName: t.name,
|
|
269
|
-
suiteLabel:
|
|
270
|
-
stories:
|
|
274
|
+
suiteLabel: z,
|
|
275
|
+
stories: C,
|
|
271
276
|
missingFromSourceOfTruth: T,
|
|
272
|
-
checkStory: async (n,
|
|
273
|
-
const
|
|
274
|
-
await
|
|
277
|
+
checkStory: async (n, u, p) => {
|
|
278
|
+
const g = await u.newPage();
|
|
279
|
+
await g.setViewportSize({ width: 800, height: 600 }), await g.goto(
|
|
275
280
|
`${t.url}/iframe.html?id=${n.id}&viewMode=story`,
|
|
276
281
|
{ waitUntil: "networkidle" }
|
|
277
|
-
), await
|
|
282
|
+
), await g.waitForSelector("#storybook-root"), await g.addStyleTag({
|
|
278
283
|
content: "* { -webkit-font-smoothing: antialiased !important; -moz-osx-font-smoothing: grayscale !important; }"
|
|
279
|
-
}), await
|
|
284
|
+
}), await g.evaluate(
|
|
280
285
|
() => Promise.all(
|
|
281
286
|
Array.from(
|
|
282
287
|
document.querySelectorAll(
|
|
283
288
|
'link[rel="stylesheet"]'
|
|
284
289
|
)
|
|
285
290
|
).map(
|
|
286
|
-
(
|
|
287
|
-
|
|
291
|
+
(f) => f.sheet ? Promise.resolve() : new Promise((l) => {
|
|
292
|
+
f.addEventListener("load", () => l(), {
|
|
288
293
|
once: !0
|
|
289
|
-
}),
|
|
294
|
+
}), f.addEventListener("error", () => l(), {
|
|
290
295
|
once: !0
|
|
291
296
|
});
|
|
292
297
|
})
|
|
293
298
|
)
|
|
294
299
|
).then(() => document.fonts.ready)
|
|
295
|
-
), await
|
|
296
|
-
const
|
|
300
|
+
), await g.waitForTimeout(300);
|
|
301
|
+
const k = await g.screenshot(), B = S(i, n.id), w = P(i)[n.id], H = h !== "check" || !w || !y(B);
|
|
297
302
|
let $;
|
|
298
|
-
if (
|
|
299
|
-
|
|
303
|
+
if (H)
|
|
304
|
+
ve(i, n.id, k), $ = w != null && w.sourceOfTruthCreatedAt ? {
|
|
300
305
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
301
|
-
sourceOfTruthCreatedAt:
|
|
302
|
-
} : { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
306
|
+
sourceOfTruthCreatedAt: w.sourceOfTruthCreatedAt
|
|
307
|
+
} : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }, w || p.annotations.push({
|
|
303
308
|
type: "golden-created",
|
|
304
309
|
description: `No golden existed yet for "${n.id}" — captured one from this run.`
|
|
305
310
|
});
|
|
306
|
-
else if ($ =
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
),
|
|
311
|
+
else if ($ = w, c === "own") {
|
|
312
|
+
const f = E(B), { diffPixels: l, diffImage: O } = R(
|
|
313
|
+
k,
|
|
314
|
+
f
|
|
315
|
+
), x = K(
|
|
311
316
|
n.id,
|
|
312
|
-
|
|
317
|
+
a,
|
|
313
318
|
e.goldenThresholdPixels
|
|
314
319
|
);
|
|
315
|
-
|
|
316
|
-
body:
|
|
320
|
+
l >= x && (await p.attach("expected", {
|
|
321
|
+
body: f,
|
|
317
322
|
contentType: "image/png"
|
|
318
323
|
}), await p.attach("actual", {
|
|
319
|
-
body:
|
|
324
|
+
body: k,
|
|
320
325
|
contentType: "image/png"
|
|
321
326
|
}), O && await p.attach("diff", {
|
|
322
327
|
body: O,
|
|
323
328
|
contentType: "image/png"
|
|
324
329
|
})), D.soft(
|
|
325
|
-
|
|
326
|
-
`"${n.id}" has drifted from its own golden image (${
|
|
327
|
-
).toBeLessThan(
|
|
330
|
+
l,
|
|
331
|
+
`"${n.id}" has drifted from its own golden image (${l} mismatched pixels, threshold ${x})`
|
|
332
|
+
).toBeLessThan(x);
|
|
328
333
|
}
|
|
329
|
-
if (
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
332
|
-
if (
|
|
334
|
+
if (v) {
|
|
335
|
+
const f = v.manifest[n.id], l = f ? await v.readImage(n.id) : null;
|
|
336
|
+
if (f && l)
|
|
337
|
+
if (h === "approve-divergence")
|
|
333
338
|
$ = {
|
|
334
339
|
...$,
|
|
335
|
-
sourceOfTruthCreatedAt:
|
|
340
|
+
sourceOfTruthCreatedAt: f.createdAt
|
|
336
341
|
};
|
|
337
342
|
else {
|
|
338
|
-
const { diffPixels: O, diffImage:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
),
|
|
343
|
+
const { diffPixels: O, diffImage: x } = R(
|
|
344
|
+
k,
|
|
345
|
+
l
|
|
346
|
+
), I = K(
|
|
342
347
|
n.id,
|
|
343
348
|
d,
|
|
344
349
|
e.sourceOfTruthThresholdPixels
|
|
345
|
-
), F = $.sourceOfTruthCreatedAt, _ = O <
|
|
350
|
+
), F = $.sourceOfTruthCreatedAt, _ = O < I || F !== void 0 && F >= f.createdAt;
|
|
346
351
|
_ || (await p.attach("expected", {
|
|
347
|
-
body:
|
|
352
|
+
body: l,
|
|
348
353
|
contentType: "image/png"
|
|
349
354
|
}), await p.attach("actual", {
|
|
350
|
-
body: x,
|
|
351
|
-
contentType: "image/png"
|
|
352
|
-
}), k && await p.attach("diff", {
|
|
353
355
|
body: k,
|
|
354
356
|
contentType: "image/png"
|
|
357
|
+
}), x && await p.attach("diff", {
|
|
358
|
+
body: x,
|
|
359
|
+
contentType: "image/png"
|
|
355
360
|
}), p.annotations.push({
|
|
356
361
|
type: "source-of-truth-divergence",
|
|
357
|
-
description: `"${n.id}" differs from the source of truth's golden by ${O} mismatched pixels (threshold ${
|
|
362
|
+
description: `"${n.id}" differs from the source of truth's golden by ${O} mismatched pixels (threshold ${I}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`
|
|
358
363
|
})), D.soft(
|
|
359
364
|
_,
|
|
360
|
-
`"${n.id}" differs from the source of truth's golden by ${O} mismatched pixels (threshold ${
|
|
365
|
+
`"${n.id}" differs from the source of truth's golden by ${O} mismatched pixels (threshold ${I}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`
|
|
361
366
|
).toBe(!0);
|
|
362
367
|
}
|
|
363
368
|
}
|
|
364
|
-
await
|
|
369
|
+
await W(i, n.id, () => $);
|
|
365
370
|
}
|
|
366
371
|
};
|
|
367
372
|
}
|
|
368
373
|
export {
|
|
369
|
-
|
|
374
|
+
Ge as resolveVisualRegressionPlan
|
|
370
375
|
};
|
|
371
376
|
//# sourceMappingURL=testing.js.map
|