@recursica/adapter-tester 4.0.0 → 5.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/dist/testing.js CHANGED
@@ -1,327 +1,353 @@
1
- import { expect as K } from "@playwright/test";
2
- import { existsSync as g, unlinkSync as J, readFileSync as $, mkdirSync as x, writeFileSync as P, closeSync as V, openSync as W, renameSync as X, rmSync as q } from "node:fs";
3
- import H from "pixelmatch";
4
- import { PNG as S } from "pngjs";
5
- import { join as E } from "node:path";
6
- import { a as z, i as Y } from "./index-DqQzFSAH.js";
7
- function N(e, t) {
8
- const n = S.sync.read(e), r = S.sync.read(t);
9
- if (n.width !== r.width || n.height !== r.height)
1
+ import { expect as J } from "@playwright/test";
2
+ import { existsSync as v, unlinkSync as Y, readFileSync as x, mkdirSync as b, writeFileSync as E, closeSync as Q, openSync as Z, renameSync as ee, rmSync as te } from "node:fs";
3
+ import re from "pixelmatch";
4
+ import { PNG as P } from "pngjs";
5
+ import { join as G } from "node:path";
6
+ import { a as oe, i as ne } from "./index-DqQzFSAH.js";
7
+ function R(e, t) {
8
+ const o = P.sync.read(e), r = P.sync.read(t);
9
+ if (o.width !== r.width || o.height !== r.height)
10
10
  return { diffPixels: 1 / 0, diffImage: null };
11
- const o = new S({ width: n.width, height: n.height });
12
- return { diffPixels: H(
13
- n.data,
14
- r.data,
11
+ const s = new P({ width: o.width, height: o.height });
12
+ return { diffPixels: re(
15
13
  o.data,
16
- n.width,
17
- n.height,
14
+ r.data,
15
+ s.data,
16
+ o.width,
17
+ o.height,
18
18
  { threshold: 0.1 }
19
- ), diffImage: S.sync.write(o) };
19
+ ), diffImage: P.sync.write(s) };
20
20
  }
21
- const Q = "http://json-schema.org/draft-07/schema#", Z = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json", ee = "test/golden/manifest.json", te = "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.", re = "object", ne = { 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." } } }, oe = {
22
- $schema: Q,
23
- $id: Z,
24
- title: ee,
25
- description: te,
26
- type: re,
27
- additionalProperties: ne
28
- }, se = Y, B = new z.Ajv({ allErrors: !0, strict: !0 });
29
- se(B);
30
- const L = B.compile(oe);
31
- function M(e, t) {
32
- if (L(e)) return;
33
- const n = (L.errors ?? []).map((r) => {
34
- var a;
35
- const o = (a = r.params) != null && a.additionalProperty ? ` '${r.params.additionalProperty}'` : "";
36
- return ` - ${r.instancePath || "root"} ${r.message}${o}`;
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
+ }, le = ne, V = new oe.Ajv({ allErrors: !0, strict: !0 });
29
+ le(V);
30
+ const U = V.compile(ue);
31
+ function F(e, t) {
32
+ if (U(e)) return;
33
+ const o = (U.errors ?? []).map((r) => {
34
+ var i;
35
+ const s = (i = r.params) != null && i.additionalProperty ? ` '${r.params.additionalProperty}'` : "";
36
+ return ` - ${r.instancePath || "root"} ${r.message}${s}`;
37
37
  }).join(`
38
38
  `);
39
39
  throw new Error(`Invalid ${t}:
40
- ${n}`);
40
+ ${o}`);
41
41
  }
42
- function j(e) {
43
- return E(e, "manifest.json");
42
+ function A(e) {
43
+ return G(e, "manifest.json");
44
44
  }
45
- function F(e) {
46
- return E(e, "manifest.json.lock");
45
+ function W(e) {
46
+ return G(e, "manifest.json.lock");
47
47
  }
48
- function O(e, t) {
49
- return E(e, `${t}.png`);
48
+ function S(e, t) {
49
+ return G(e, `${t}.png`);
50
50
  }
51
- function b(e) {
52
- const t = j(e);
53
- if (!g(t)) return {};
54
- const n = JSON.parse($(t, "utf8"));
55
- return M(n, t), n;
51
+ function j(e) {
52
+ const t = A(e);
53
+ if (!v(t)) return {};
54
+ const o = JSON.parse(x(t, "utf8"));
55
+ return F(o, t), o;
56
56
  }
57
- function ie(e, t) {
58
- const n = j(e);
59
- M(t, n);
57
+ function fe(e, t) {
58
+ const o = A(e);
59
+ F(t, o);
60
60
  const r = {};
61
- for (const a of Object.keys(t).sort())
62
- r[a] = t[a];
63
- x(e, { recursive: !0 });
64
- const o = `${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
65
- P(o, JSON.stringify(r, null, 2) + `
66
- `), X(o, n);
61
+ for (const i of Object.keys(t).sort())
62
+ r[i] = t[i];
63
+ b(e, { recursive: !0 });
64
+ const s = `${o}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
65
+ E(s, JSON.stringify(r, null, 2) + `
66
+ `), ee(s, o);
67
67
  }
68
- const ae = 25, ce = 15e3;
69
- function de(e) {
68
+ const pe = 25, ge = 15e3;
69
+ function me(e) {
70
70
  return new Promise((t) => setTimeout(t, e));
71
71
  }
72
- async function ue(e) {
73
- x(e, { recursive: !0 });
74
- const t = F(e), n = Date.now() + ce;
72
+ async function we(e) {
73
+ b(e, { recursive: !0 });
74
+ const t = W(e), o = Date.now() + ge;
75
75
  for (; ; )
76
76
  try {
77
- V(W(t, "wx"));
77
+ Q(Z(t, "wx"));
78
78
  return;
79
79
  } catch (r) {
80
80
  if (r.code !== "EEXIST") throw r;
81
- if (Date.now() >= n)
81
+ if (Date.now() >= o)
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 de(ae);
85
+ await me(pe);
86
86
  }
87
87
  }
88
- function fe(e) {
89
- q(F(e), { force: !0 });
88
+ function ye(e) {
89
+ te(W(e), { force: !0 });
90
90
  }
91
- async function _(e, t, n) {
92
- await ue(e);
91
+ async function X(e, t, o) {
92
+ await we(e);
93
93
  try {
94
- const r = b(e), o = n(r[t]);
95
- return o === void 0 ? delete r[t] : r[t] = o, ie(e, r), o;
94
+ const r = j(e), s = o(r[t]);
95
+ return s === void 0 ? delete r[t] : r[t] = s, fe(e, r), s;
96
96
  } finally {
97
- fe(e);
97
+ ye(e);
98
98
  }
99
99
  }
100
- function he(e, t, n) {
101
- x(e, { recursive: !0 }), P(O(e, t), n);
100
+ function ve(e, t, o) {
101
+ b(e, { recursive: !0 }), E(S(e, t), o);
102
102
  }
103
- async function le(e, t) {
104
- const n = b(e), r = Object.keys(n).filter(
105
- (o) => !t.has(o)
103
+ async function Te(e, t) {
104
+ const o = j(e), r = Object.keys(o).filter(
105
+ (s) => !t.has(s)
106
106
  );
107
- for (const o of r) {
108
- const a = O(e, o);
109
- g(a) && J(a), await _(e, o, () => {
107
+ for (const s of r) {
108
+ const i = S(e, s);
109
+ v(i) && Y(i), await X(e, s, () => {
110
110
  });
111
111
  }
112
112
  return r;
113
113
  }
114
- const pe = "borderux/recursica";
115
- async function me(e, t) {
116
- var a, d;
117
- const n = await fetch(`https://registry.npmjs.org/${e}`);
118
- if (!n.ok)
114
+ const $e = "borderux/recursica";
115
+ async function Oe(e, t) {
116
+ var i, d;
117
+ const o = await fetch(`https://registry.npmjs.org/${e}`);
118
+ if (!o.ok)
119
119
  throw new Error(
120
- `Could not reach npm registry for ${e}: ${n.statusText}`
120
+ `Could not reach npm registry for ${e}: ${o.statusText}`
121
121
  );
122
- const r = await n.json(), o = ((a = r["dist-tags"]) == null ? void 0 : a[t]) ?? ((d = r.versions) != null && d[t] ? t : void 0);
123
- if (!o)
122
+ const r = await o.json(), s = ((i = r["dist-tags"]) == null ? void 0 : i[t]) ?? ((d = r.versions) != null && d[t] ? t : void 0);
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
- return o;
127
+ return s;
128
128
  }
129
- function ge(e) {
129
+ function ke(e) {
130
130
  return `packages/${e.split("/").pop()}`;
131
131
  }
132
- async function we(e) {
132
+ async function xe(e) {
133
133
  if (e.type === "local")
134
- return g(j(e.dir)) ? {
135
- manifest: b(e.dir),
136
- async readImage(c) {
137
- const u = O(e.dir, c);
138
- return g(u) ? $(u) : null;
134
+ return v(A(e.dir)) ? {
135
+ manifest: j(e.dir),
136
+ async readImage(h) {
137
+ const c = S(e.dir, h);
138
+ return v(c) ? x(c) : null;
139
139
  }
140
140
  } : (console.warn(
141
141
  `No golden baseline found yet at ${e.dir} — source-of-truth divergence check skipped for this run.`
142
142
  ), null);
143
143
  let t;
144
144
  try {
145
- t = await me(
145
+ t = await Oe(
146
146
  e.packageName,
147
147
  e.versionSpec
148
148
  );
149
- } catch (i) {
149
+ } catch (a) {
150
150
  return console.warn(
151
151
  `Could not resolve ${e.packageName}@${e.versionSpec} — source-of-truth divergence check skipped for this run.`,
152
- i
152
+ a
153
153
  ), null;
154
154
  }
155
- const n = E(e.cacheDir, t), r = `${e.packageName}@${t}`, o = `https://raw.githubusercontent.com/${pe}/${r}/${ge(e.packageName)}/test/golden`;
156
- let a;
157
- const d = j(n);
158
- if (g(d))
159
- a = b(n);
155
+ const o = G(e.cacheDir, t), r = `${e.packageName}@${t}`, s = `https://raw.githubusercontent.com/${$e}/${r}/${ke(e.packageName)}/test/golden`;
156
+ let i;
157
+ const d = A(o);
158
+ if (v(d))
159
+ i = j(o);
160
160
  else {
161
- let i;
161
+ let a;
162
162
  try {
163
- i = await fetch(`${o}/manifest.json`);
163
+ a = await fetch(`${s}/manifest.json`);
164
164
  } catch (f) {
165
165
  return console.warn(
166
166
  `Could not reach GitHub to fetch ${r}'s golden baseline — source-of-truth divergence check skipped for this run.`,
167
167
  f
168
168
  ), null;
169
169
  }
170
- if (!i.ok)
170
+ if (!a.ok)
171
171
  return console.warn(
172
172
  `No golden baseline published for ${r} — source-of-truth divergence check skipped for this run.`
173
173
  ), null;
174
- const c = await i.text(), u = JSON.parse(c);
175
- M(u, `${o}/manifest.json`), x(n, { recursive: !0 }), P(d, c), a = u;
174
+ const h = await a.text(), c = JSON.parse(h);
175
+ F(c, `${s}/manifest.json`), b(o, { recursive: !0 }), E(d, h), i = c;
176
176
  }
177
177
  return {
178
- manifest: a,
179
- async readImage(i) {
180
- const c = O(n, i);
181
- if (g(c)) return $(c);
182
- const u = await fetch(`${o}/${i}.png`);
183
- if (!u.ok) return null;
184
- const f = Buffer.from(await u.arrayBuffer());
185
- return x(n, { recursive: !0 }), P(c, f), f;
178
+ manifest: i,
179
+ async readImage(a) {
180
+ const h = S(o, a);
181
+ if (v(h)) return x(h);
182
+ const c = await fetch(`${s}/${a}.png`);
183
+ if (!c.ok) return null;
184
+ const f = Buffer.from(await c.arrayBuffer());
185
+ return b(o, { recursive: !0 }), E(h, f), f;
186
186
  }
187
187
  };
188
188
  }
189
- const ye = ["Theme", "Tokens", "Introduction"];
190
- function D(e, t) {
189
+ const be = ["Theme", "Tokens", "Introduction"];
190
+ function B(e, t) {
191
191
  return e === t || e.startsWith(t);
192
192
  }
193
- async function ve(e, t, n) {
194
- let r;
193
+ async function Se(e, t) {
194
+ let o;
195
195
  try {
196
- const o = await fetch(`${e.url}/index.json`);
197
- if (!o.ok)
196
+ const r = await fetch(`${e.url}/index.json`);
197
+ if (!r.ok)
198
198
  throw new Error(
199
- `Failed to fetch Storybook index: ${o.statusText}`
199
+ `Failed to fetch Storybook index: ${r.statusText}`
200
200
  );
201
- const d = (await o.json()).entries || {};
202
- r = Object.values(d).filter(
203
- (i) => i.type === "story" && !t.some(
204
- (c) => i.title === c || i.title.startsWith(`${c}/`)
205
- ) && !n.some((c) => D(i.id, c))
206
- ), r.sort((i, c) => i.id.localeCompare(c.id));
207
- } catch (o) {
201
+ const i = (await r.json()).entries || {};
202
+ o = Object.values(i).filter(
203
+ (d) => d.type === "story" && !t.some(
204
+ (a) => d.title === a || d.title.startsWith(`${a}/`)
205
+ )
206
+ ), o.sort((d, a) => d.id.localeCompare(a.id));
207
+ } catch (r) {
208
208
  throw console.error(
209
209
  "Failed to load Storybook index from",
210
210
  `${e.url}/index.json`,
211
- o
211
+ r
212
212
  ), new Error(
213
213
  `Storybook target "${e.name}" is not responsive or index.json is missing. Please ensure its Storybook is running.`
214
214
  );
215
215
  }
216
- return r;
216
+ return o;
217
217
  }
218
- function ke(e, t, n) {
218
+ function K(e, t, o) {
219
219
  let r;
220
- for (const o of Object.keys(t))
221
- D(e, o) && (!r || o.length > r.length) && (r = o);
222
- return r !== void 0 ? t[r] : n;
220
+ for (const s of Object.keys(t))
221
+ B(e, s) && (!r || s.length > r.length) && (r = s);
222
+ return r !== void 0 ? t[r] : o;
223
223
  }
224
- async function je(e) {
225
- const t = e.isSourceOfTruthAdapter ? e.targets[0] : e.targets.find((s) => !s.sourceOfTruth);
224
+ async function Ie(e) {
225
+ const t = e.isSourceOfTruthAdapter ? e.targets[0] : e.targets.find((n) => !n.sourceOfTruth);
226
226
  if (!t)
227
227
  throw new Error(
228
228
  "adapter-tester config has no non-sourceOfTruth target to run the golden check against."
229
229
  );
230
- const n = e.excludeTitlePrefixes ?? ye, r = e.stories ?? {}, o = Object.keys(r).filter(
231
- (s) => r[s].exclude
232
- ), a = Object.fromEntries(
233
- Object.entries(r).filter(([, s]) => s.threshold !== void 0).map(([s, y]) => [s, y.threshold])
234
- ), d = e.goldenDir, i = e.goldenMode, c = e.checkMode, u = await ve(
235
- t,
236
- n,
237
- o
230
+ const o = e.excludeTitlePrefixes ?? be, r = e.stories ?? {}, s = Object.keys(r).filter(
231
+ (n) => r[n].exclude
232
+ ), i = Object.fromEntries(
233
+ Object.entries(r).filter(([, n]) => n.goldenThreshold !== void 0).map(([n, u]) => [n, u.goldenThreshold])
234
+ ), d = Object.fromEntries(
235
+ Object.entries(r).filter(([, n]) => n.sourceOfTruthThreshold !== void 0).map(([n, u]) => [n, u.sourceOfTruthThreshold])
236
+ ), a = e.goldenDir, h = e.goldenMode, c = e.checkMode, f = await Se(t, o), M = f.filter(
237
+ (n) => !s.some((u) => B(n.id, u))
238
238
  );
239
- if (i === "update-golden") {
240
- const s = await le(
241
- d,
242
- new Set(u.map((y) => y.id))
239
+ if (h === "update-golden") {
240
+ const n = await Te(
241
+ a,
242
+ new Set(M.map((u) => u.id))
243
243
  );
244
- s.length > 0 && console.warn(
245
- `Pruned ${s.length} orphaned golden(s) no longer in Storybook: ${s.join(", ")}`
244
+ n.length > 0 && console.warn(
245
+ `Pruned ${n.length} orphaned golden(s) no longer in Storybook: ${n.join(", ")}`
246
246
  );
247
247
  }
248
- const f = c !== "divergence" || e.isSourceOfTruthAdapter || !e.sourceOfTruthGolden ? null : await we(e.sourceOfTruthGolden), R = c === "divergence" ? "Source-of-Truth Divergence Check" : "Own-Drift Golden Image Check";
248
+ const p = c !== "divergence" || e.isSourceOfTruthAdapter || !e.sourceOfTruthGolden ? null : await xe(e.sourceOfTruthGolden), q = new Set(f.map((n) => n.id)), T = p ? Object.keys(p.manifest).filter(
249
+ (n) => !q.has(n) && !s.some((u) => B(n, u))
250
+ ).sort() : [];
251
+ T.length > 0 && console.error(
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.`
253
+ ), console.log(
254
+ [
255
+ `[adapter-tester] target: "${t.name}" (${t.url})`,
256
+ `[adapter-tester] checkMode: "${c}" (${c === "divergence" ? "this project's golden vs source-of-truth's golden" : "live render vs this project's own golden"})`,
257
+ `[adapter-tester] goldenMode: "${h}"`,
258
+ `[adapter-tester] goldenThresholdPixels: ${e.goldenThresholdPixels}`,
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 ? p ? `[adapter-tester] sourceOfTruthGolden: resolved, ${Object.keys(p.manifest).length} golden(s) available (config: ${JSON.stringify(e.sourceOfTruthGolden)})` : `[adapter-tester] sourceOfTruthGolden: unavailable — no baseline found or unreachable (config: ${JSON.stringify(e.sourceOfTruthGolden)}); divergence check will skip every story` : "[adapter-tester] sourceOfTruthGolden: skipped — no sourceOfTruthGolden configured" : '[adapter-tester] sourceOfTruthGolden: not used in "own" checkMode',
261
+ `[adapter-tester] stories: ${M.length} to check (excluded: ${s.length}, title prefixes excluded: ${o.join(", ") || "none"})`,
262
+ `[adapter-tester] story parity with source of truth: ${T.length === 0 ? "OK" : `${T.length} missing (see error above)`}`
263
+ ].join(`
264
+ `)
265
+ );
266
+ const H = c === "divergence" ? "Source-of-Truth Divergence Check" : "Own-Drift Golden Image Check";
249
267
  return {
250
268
  ownTargetName: t.name,
251
- suiteLabel: R,
252
- stories: u,
253
- checkStory: async (s, y, h) => {
254
- const v = await y.newPage();
255
- await v.setViewportSize({ width: 800, height: 600 }), await v.goto(
256
- `${t.url}/iframe.html?id=${s.id}&viewMode=story`,
269
+ suiteLabel: H,
270
+ stories: M,
271
+ missingFromSourceOfTruth: T,
272
+ checkStory: async (n, u, l) => {
273
+ const O = await u.newPage();
274
+ await O.setViewportSize({ width: 800, height: 600 }), await O.goto(
275
+ `${t.url}/iframe.html?id=${n.id}&viewMode=story`,
257
276
  { waitUntil: "networkidle" }
258
- ), await v.waitForSelector("#storybook-root"), await v.waitForTimeout(300);
259
- const A = await v.screenshot(), I = O(d, s.id), l = b(d)[s.id], U = i !== "check" || !l || !g(I);
260
- let w;
261
- if (U)
262
- he(d, s.id, A), w = l != null && l.sourceOfTruthCreatedAt ? {
277
+ ), await O.waitForSelector("#storybook-root"), await O.waitForTimeout(300);
278
+ const I = await O.screenshot(), C = S(a, n.id), g = j(a)[n.id], z = h !== "check" || !g || !v(C);
279
+ let $;
280
+ if (z)
281
+ ve(a, n.id, I), $ = g != null && g.sourceOfTruthCreatedAt ? {
263
282
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
264
- sourceOfTruthCreatedAt: l.sourceOfTruthCreatedAt
265
- } : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }, l || h.annotations.push({
283
+ sourceOfTruthCreatedAt: g.sourceOfTruthCreatedAt
284
+ } : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }, g || l.annotations.push({
266
285
  type: "golden-created",
267
- description: `No golden existed yet for "${s.id}" — captured one from this run.`
286
+ description: `No golden existed yet for "${n.id}" — captured one from this run.`
268
287
  });
269
- else if (w = l, c === "own") {
270
- const p = $(I), { diffPixels: m, diffImage: k } = N(
271
- A,
272
- p
273
- ), T = ke(
274
- s.id,
275
- a,
276
- e.diffThresholdPixels
288
+ else if ($ = g, c === "own") {
289
+ const m = x(C), { diffPixels: w, diffImage: k } = R(
290
+ I,
291
+ m
292
+ ), y = K(
293
+ n.id,
294
+ i,
295
+ e.goldenThresholdPixels
277
296
  );
278
- m >= T && (await h.attach("expected", {
279
- body: p,
297
+ w >= y && (await l.attach("expected", {
298
+ body: m,
280
299
  contentType: "image/png"
281
- }), await h.attach("actual", {
282
- body: A,
300
+ }), await l.attach("actual", {
301
+ body: I,
283
302
  contentType: "image/png"
284
- }), k && await h.attach("diff", {
303
+ }), k && await l.attach("diff", {
285
304
  body: k,
286
305
  contentType: "image/png"
287
- })), K.soft(
288
- m,
289
- `"${s.id}" has drifted from its own golden image (${m} mismatched pixels, threshold ${T})`
290
- ).toBeLessThan(T);
306
+ })), J.soft(
307
+ w,
308
+ `"${n.id}" has drifted from its own golden image (${w} mismatched pixels, threshold ${y})`
309
+ ).toBeLessThan(y);
291
310
  }
292
- if (f) {
293
- const p = f.manifest[s.id], m = p ? await f.readImage(s.id) : null;
294
- if (p && m)
295
- if (i === "approve-divergence")
296
- w = {
297
- ...w,
298
- sourceOfTruthCreatedAt: p.createdAt
311
+ if (p) {
312
+ const m = p.manifest[n.id], w = m ? await p.readImage(n.id) : null;
313
+ if (m && w)
314
+ if (h === "approve-divergence")
315
+ $ = {
316
+ ...$,
317
+ sourceOfTruthCreatedAt: m.createdAt
299
318
  };
300
319
  else {
301
- const k = $(I), { diffPixels: T, diffImage: C } = N(
320
+ const k = x(C), { diffPixels: y, diffImage: L } = R(
302
321
  k,
303
- m
304
- ), G = w.sourceOfTruthCreatedAt;
305
- T === 0 || G !== void 0 && G >= p.createdAt || (await h.attach("expected", {
306
- body: m,
322
+ w
323
+ ), N = K(
324
+ n.id,
325
+ d,
326
+ e.sourceOfTruthThresholdPixels
327
+ ), _ = $.sourceOfTruthCreatedAt, D = y < N || _ !== void 0 && _ >= m.createdAt;
328
+ D || (await l.attach("expected", {
329
+ body: w,
307
330
  contentType: "image/png"
308
- }), await h.attach("actual", {
331
+ }), await l.attach("actual", {
309
332
  body: k,
310
333
  contentType: "image/png"
311
- }), C && await h.attach("diff", {
312
- body: C,
334
+ }), L && await l.attach("diff", {
335
+ body: L,
313
336
  contentType: "image/png"
314
- }), h.annotations.push({
337
+ }), l.annotations.push({
315
338
  type: "source-of-truth-divergence",
316
- description: `"${s.id}" differs from the source of truth's golden and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`
317
- }));
339
+ description: `"${n.id}" differs from the source of truth's golden by ${y} mismatched pixels (threshold ${N}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`
340
+ })), J.soft(
341
+ D,
342
+ `"${n.id}" differs from the source of truth's golden by ${y} mismatched pixels (threshold ${N}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`
343
+ ).toBe(!0);
318
344
  }
319
345
  }
320
- await _(d, s.id, () => w);
346
+ await X(a, n.id, () => $);
321
347
  }
322
348
  };
323
349
  }
324
350
  export {
325
- je as resolveVisualRegressionPlan
351
+ Ie as resolveVisualRegressionPlan
326
352
  };
327
353
  //# sourceMappingURL=testing.js.map