@decocms/parity 0.34.3 → 0.34.5
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/cli.js +379 -94
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -75778,7 +75778,7 @@ See: https://github.com/dequelabs/axe-core/blob/master/doc/context.md`));
|
|
|
75778
75778
|
|
|
75779
75779
|
// src/cli.ts
|
|
75780
75780
|
import { DESCRIPTION, registerCommands } from "@decocms/vtex-cms";
|
|
75781
|
-
import
|
|
75781
|
+
import chalk46 from "chalk";
|
|
75782
75782
|
import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
75783
75783
|
|
|
75784
75784
|
// src/commands/ab-detect.ts
|
|
@@ -118253,8 +118253,258 @@ async function reportCommand(runId, opts) {
|
|
|
118253
118253
|
return 0;
|
|
118254
118254
|
}
|
|
118255
118255
|
|
|
118256
|
-
// src/commands/
|
|
118256
|
+
// src/commands/rerender.ts
|
|
118257
|
+
import { writeFileSync as writeFileSync36 } from "node:fs";
|
|
118257
118258
|
import chalk39 from "chalk";
|
|
118259
|
+
function analyzeFrames(before, frames, opts = {}) {
|
|
118260
|
+
const threshold = opts.flashWhite ?? Math.min(97, before.white + 20);
|
|
118261
|
+
const flashes = [];
|
|
118262
|
+
let open = null;
|
|
118263
|
+
for (const f of frames) {
|
|
118264
|
+
if (f.white >= threshold) {
|
|
118265
|
+
if (!open)
|
|
118266
|
+
open = { from: f.t, to: f.t, peakWhite: f.white };
|
|
118267
|
+
open.to = f.t;
|
|
118268
|
+
open.peakWhite = Math.max(open.peakWhite, f.white);
|
|
118269
|
+
} else if (open) {
|
|
118270
|
+
flashes.push(open);
|
|
118271
|
+
open = null;
|
|
118272
|
+
}
|
|
118273
|
+
}
|
|
118274
|
+
if (open)
|
|
118275
|
+
flashes.push(open);
|
|
118276
|
+
const delta = opts.settleDelta ?? 0.5;
|
|
118277
|
+
let settledAt = frames.length ? 0 : null;
|
|
118278
|
+
for (let i = 1;i < frames.length; i++)
|
|
118279
|
+
if (Math.abs(frames[i].changed - frames[i - 1].changed) > delta)
|
|
118280
|
+
settledAt = frames[i].t;
|
|
118281
|
+
return { flashes, settledAt };
|
|
118282
|
+
}
|
|
118283
|
+
async function scoreFrames(page, base, frames) {
|
|
118284
|
+
return page.evaluate(async ({ base, frames }) => {
|
|
118285
|
+
const load = (b64) => new Promise((resolve, reject) => {
|
|
118286
|
+
const img = new Image;
|
|
118287
|
+
img.onload = () => {
|
|
118288
|
+
const c = document.createElement("canvas");
|
|
118289
|
+
c.width = 320;
|
|
118290
|
+
c.height = Math.round(img.height / img.width * 320);
|
|
118291
|
+
const ctx = c.getContext("2d");
|
|
118292
|
+
ctx.drawImage(img, 0, 0, c.width, c.height);
|
|
118293
|
+
resolve(ctx.getImageData(0, 0, c.width, c.height));
|
|
118294
|
+
};
|
|
118295
|
+
img.onerror = reject;
|
|
118296
|
+
img.src = `data:image/jpeg;base64,${b64}`;
|
|
118297
|
+
});
|
|
118298
|
+
const lum = (d, i) => 0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2];
|
|
118299
|
+
const b = await load(base);
|
|
118300
|
+
const out = [];
|
|
118301
|
+
for (const f of frames) {
|
|
118302
|
+
const im = await load(f);
|
|
118303
|
+
let white = 0;
|
|
118304
|
+
let changed = 0;
|
|
118305
|
+
const n = im.data.length / 4;
|
|
118306
|
+
for (let i = 0;i < im.data.length; i += 4) {
|
|
118307
|
+
const l = lum(im.data, i);
|
|
118308
|
+
if (l > 245)
|
|
118309
|
+
white++;
|
|
118310
|
+
if (i < b.data.length && Math.abs(l - lum(b.data, i)) > 30)
|
|
118311
|
+
changed++;
|
|
118312
|
+
}
|
|
118313
|
+
out.push({ white: white / n * 100, changed: changed / n * 100 });
|
|
118314
|
+
}
|
|
118315
|
+
return out;
|
|
118316
|
+
}, { base, frames });
|
|
118317
|
+
}
|
|
118318
|
+
var SKELETON = "[class*='skeleton' i], .animate-pulse, [aria-busy='true'], .loading";
|
|
118319
|
+
async function rerenderCommand(opts) {
|
|
118320
|
+
if (!opts.selector && !opts.text) {
|
|
118321
|
+
console.error(chalk39.red("pass --selector or --text"));
|
|
118322
|
+
return 2;
|
|
118323
|
+
}
|
|
118324
|
+
const browser = await launchBrowser({ headless: true });
|
|
118325
|
+
try {
|
|
118326
|
+
const ctx = await newContext(browser, { viewport: opts.viewport });
|
|
118327
|
+
const page = await ctx.newPage();
|
|
118328
|
+
await page.goto(opts.url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
118329
|
+
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
118330
|
+
return;
|
|
118331
|
+
});
|
|
118332
|
+
await page.waitForTimeout(2000);
|
|
118333
|
+
const urlBefore = page.url();
|
|
118334
|
+
await page.evaluate((skeletonSel) => {
|
|
118335
|
+
const w = window;
|
|
118336
|
+
const regionOf = (n) => {
|
|
118337
|
+
let el = n && (n.nodeType === 1 ? n : n.parentElement);
|
|
118338
|
+
while (el && el !== document.body) {
|
|
118339
|
+
if (el.matches("header, footer, section, [data-manifest-key], [data-section]"))
|
|
118340
|
+
return el;
|
|
118341
|
+
el = el.parentElement;
|
|
118342
|
+
}
|
|
118343
|
+
return null;
|
|
118344
|
+
};
|
|
118345
|
+
const nameOf = (el) => !el ? "page" : el.getAttribute("data-manifest-key") || el.getAttribute("data-section") || el.tagName.toLowerCase() + (el.id ? `#${el.id}` : "");
|
|
118346
|
+
const tops = Array.from(document.querySelectorAll("header, footer, section, [data-manifest-key], [data-section]")).filter((el) => !el.parentElement?.closest("header, footer, section, [data-manifest-key], [data-section]"));
|
|
118347
|
+
w.__before = new Map(tops.map((el) => [nameOf(el), new WeakRef(el)]));
|
|
118348
|
+
const changes = {};
|
|
118349
|
+
const skeletons = {};
|
|
118350
|
+
w.__changes = changes;
|
|
118351
|
+
w.__skeletons = skeletons;
|
|
118352
|
+
new MutationObserver((ms) => {
|
|
118353
|
+
for (const m of ms) {
|
|
118354
|
+
const r = nameOf(regionOf(m.target));
|
|
118355
|
+
changes[r] ??= { added: 0, removed: 0, attrs: 0, text: 0 };
|
|
118356
|
+
const c = changes[r];
|
|
118357
|
+
if (m.type === "childList") {
|
|
118358
|
+
c.added += m.addedNodes.length;
|
|
118359
|
+
c.removed += m.removedNodes.length;
|
|
118360
|
+
for (const n of m.addedNodes)
|
|
118361
|
+
if (n.nodeType === 1) {
|
|
118362
|
+
const el = n;
|
|
118363
|
+
const k = (el.matches(skeletonSel) ? 1 : 0) + el.querySelectorAll(skeletonSel).length;
|
|
118364
|
+
if (k)
|
|
118365
|
+
skeletons[r] = (skeletons[r] ?? 0) + k;
|
|
118366
|
+
}
|
|
118367
|
+
} else if (m.type === "attributes")
|
|
118368
|
+
c.attrs++;
|
|
118369
|
+
else
|
|
118370
|
+
c.text++;
|
|
118371
|
+
}
|
|
118372
|
+
}).observe(document.body, {
|
|
118373
|
+
subtree: true,
|
|
118374
|
+
childList: true,
|
|
118375
|
+
attributes: true,
|
|
118376
|
+
characterData: true
|
|
118377
|
+
});
|
|
118378
|
+
w.__nameOf = nameOf;
|
|
118379
|
+
}, SKELETON);
|
|
118380
|
+
const requests = [];
|
|
118381
|
+
const onReq = (r) => {
|
|
118382
|
+
if (["xhr", "fetch", "document"].includes(r.resourceType()))
|
|
118383
|
+
requests.push(`${r.method()} ${r.url().replace(/^https?:\/\/[^/]+/, "").slice(0, 100)}`);
|
|
118384
|
+
};
|
|
118385
|
+
page.on("request", onReq);
|
|
118386
|
+
const cdp = await ctx.newCDPSession(page);
|
|
118387
|
+
const frames = [];
|
|
118388
|
+
let t0 = 0;
|
|
118389
|
+
cdp.on("Page.screencastFrame", async (f) => {
|
|
118390
|
+
frames.push({ t: t0 ? Date.now() - t0 : -1, data: f.data });
|
|
118391
|
+
await cdp.send("Page.screencastFrameAck", { sessionId: f.sessionId }).catch(() => {
|
|
118392
|
+
return;
|
|
118393
|
+
});
|
|
118394
|
+
});
|
|
118395
|
+
await cdp.send("Page.startScreencast", { format: "jpeg", quality: 50, everyNthFrame: 1 });
|
|
118396
|
+
await page.waitForTimeout(400);
|
|
118397
|
+
const target = (opts.selector ? page.locator(opts.selector) : page.getByText(opts.text, { exact: true })).filter({ visible: true }).first();
|
|
118398
|
+
t0 = Date.now();
|
|
118399
|
+
const clicked = await target.click({ timeout: 5000 }).then(() => true).catch(() => false);
|
|
118400
|
+
if (!clicked) {
|
|
118401
|
+
console.error(chalk39.yellow("target not clickable — nothing measured"));
|
|
118402
|
+
return 2;
|
|
118403
|
+
}
|
|
118404
|
+
await page.waitForTimeout(opts.settleMs);
|
|
118405
|
+
await cdp.send("Page.stopScreencast").catch(() => {
|
|
118406
|
+
return;
|
|
118407
|
+
});
|
|
118408
|
+
page.off("request", onReq);
|
|
118409
|
+
const dom = await page.evaluate(() => {
|
|
118410
|
+
const w = window;
|
|
118411
|
+
const before = w.__before;
|
|
118412
|
+
const changes = w.__changes;
|
|
118413
|
+
const remounted = [];
|
|
118414
|
+
for (const [name, ref] of before) {
|
|
118415
|
+
const el = ref.deref();
|
|
118416
|
+
if (!el || !el.isConnected)
|
|
118417
|
+
remounted.push(name);
|
|
118418
|
+
}
|
|
118419
|
+
return { remounted, changes, skeletons: w.__skeletons };
|
|
118420
|
+
});
|
|
118421
|
+
const pre = frames.filter((f) => f.t < 0);
|
|
118422
|
+
const post = frames.filter((f) => f.t >= 0);
|
|
118423
|
+
const base = pre[pre.length - 1] ?? post[0];
|
|
118424
|
+
const scorer = await ctx.newPage();
|
|
118425
|
+
const scores = base ? await scoreFrames(scorer, base.data, post.map((f) => f.data)) : [];
|
|
118426
|
+
const baseScore = base ? (await scoreFrames(scorer, base.data, [base.data]))[0] : { white: 0, changed: 0 };
|
|
118427
|
+
const stats = post.map((f, i) => ({ t: f.t, ...scores[i] }));
|
|
118428
|
+
const { flashes, settledAt } = analyzeFrames(baseScore, stats);
|
|
118429
|
+
const names = new Set([...Object.keys(dom.changes), ...dom.remounted]);
|
|
118430
|
+
const regions = [...names].map((region) => ({
|
|
118431
|
+
region,
|
|
118432
|
+
remounted: dom.remounted.includes(region),
|
|
118433
|
+
...dom.changes[region] ?? { added: 0, removed: 0, attrs: 0, text: 0 }
|
|
118434
|
+
})).sort((a, b) => Number(b.remounted) - Number(a.remounted) || b.added + b.removed - (a.added + a.removed));
|
|
118435
|
+
const report = {
|
|
118436
|
+
urlBefore,
|
|
118437
|
+
urlAfter: page.url(),
|
|
118438
|
+
requests,
|
|
118439
|
+
regions,
|
|
118440
|
+
skeletons: Object.entries(dom.skeletons).map(([region, count]) => ({ region, count })),
|
|
118441
|
+
flashes,
|
|
118442
|
+
settledAt,
|
|
118443
|
+
frames: post.length
|
|
118444
|
+
};
|
|
118445
|
+
if (opts.sheet && base) {
|
|
118446
|
+
const pick = new Set([0]);
|
|
118447
|
+
for (const fl of flashes) {
|
|
118448
|
+
const i = stats.findIndex((s) => s.t === fl.from);
|
|
118449
|
+
if (i >= 0)
|
|
118450
|
+
pick.add(i);
|
|
118451
|
+
const j = stats.findIndex((s) => s.t > fl.to);
|
|
118452
|
+
if (j >= 0)
|
|
118453
|
+
pick.add(j);
|
|
118454
|
+
}
|
|
118455
|
+
pick.add(stats.length - 1);
|
|
118456
|
+
const chosen = [...pick].sort((a, b) => a - b).map((i) => post[i]);
|
|
118457
|
+
const png = await scorer.evaluate(async (imgs) => {
|
|
118458
|
+
const load = (b64) => new Promise((res) => {
|
|
118459
|
+
const im = new Image;
|
|
118460
|
+
im.onload = () => res(im);
|
|
118461
|
+
im.src = `data:image/jpeg;base64,${b64}`;
|
|
118462
|
+
});
|
|
118463
|
+
const els = await Promise.all(imgs.map((x) => load(x.data)));
|
|
118464
|
+
const w = 480;
|
|
118465
|
+
const h = Math.round(els[0].height / els[0].width * w);
|
|
118466
|
+
const c = document.createElement("canvas");
|
|
118467
|
+
c.width = w * els.length;
|
|
118468
|
+
c.height = h + 24;
|
|
118469
|
+
const g = c.getContext("2d");
|
|
118470
|
+
g.fillStyle = "#111";
|
|
118471
|
+
g.fillRect(0, 0, c.width, c.height);
|
|
118472
|
+
els.forEach((im, i) => {
|
|
118473
|
+
g.drawImage(im, i * w, 24, w, h);
|
|
118474
|
+
g.fillStyle = "#fff";
|
|
118475
|
+
g.font = "14px sans-serif";
|
|
118476
|
+
g.fillText(`+${imgs[i].t}ms`, i * w + 8, 17);
|
|
118477
|
+
});
|
|
118478
|
+
return c.toDataURL("image/png").split(",")[1];
|
|
118479
|
+
}, chosen.map((f) => ({ data: f.data, t: Math.max(0, f.t) })));
|
|
118480
|
+
writeFileSync36(opts.sheet, Buffer.from(png, "base64"));
|
|
118481
|
+
}
|
|
118482
|
+
if (opts.json) {
|
|
118483
|
+
console.log(JSON.stringify({ url: opts.url, action: opts.selector ?? opts.text, ...report }));
|
|
118484
|
+
return 0;
|
|
118485
|
+
}
|
|
118486
|
+
console.log(chalk39.bold(`
|
|
118487
|
+
click ${opts.selector ?? `"${opts.text}"`} on ${urlBefore}`));
|
|
118488
|
+
if (report.urlAfter !== urlBefore)
|
|
118489
|
+
console.log(` url → ${report.urlAfter}`);
|
|
118490
|
+
console.log(` ${requests.length} request(s): ${requests.slice(0, 6).join(" · ")}`);
|
|
118491
|
+
for (const r of regions.slice(0, 10))
|
|
118492
|
+
console.log(` ${r.remounted ? chalk39.red("REMOUNTED") : "changed "} ${r.region.padEnd(48)} +${r.added}/-${r.removed} attrs ${r.attrs} text ${r.text}`);
|
|
118493
|
+
for (const s of report.skeletons)
|
|
118494
|
+
console.log(chalk39.yellow(` skeletons ×${s.count} in ${s.region}`));
|
|
118495
|
+
for (const f of flashes)
|
|
118496
|
+
console.log(chalk39.red(` white flash +${f.from}–${f.to}ms (peak ${f.peakWhite.toFixed(0)}% white)`));
|
|
118497
|
+
console.log(chalk39.dim(` settled at +${settledAt ?? "?"}ms · ${post.length} frames${opts.sheet ? ` · sheet ${opts.sheet}` : ""}`));
|
|
118498
|
+
return 0;
|
|
118499
|
+
} finally {
|
|
118500
|
+
await browser.close().catch(() => {
|
|
118501
|
+
return;
|
|
118502
|
+
});
|
|
118503
|
+
}
|
|
118504
|
+
}
|
|
118505
|
+
|
|
118506
|
+
// src/commands/states.ts
|
|
118507
|
+
import chalk40 from "chalk";
|
|
118258
118508
|
var ROOT_ATTR = "data-parity-states";
|
|
118259
118509
|
var rootSelector = (i) => `[${ROOT_ATTR}="${i}"]`;
|
|
118260
118510
|
function resolveStateRoots(args) {
|
|
@@ -118563,7 +118813,7 @@ function statesVerdict(counts) {
|
|
|
118563
118813
|
async function statesCommand(opts) {
|
|
118564
118814
|
const viewport = parseViewport2(opts.viewport);
|
|
118565
118815
|
if (!viewport) {
|
|
118566
|
-
console.error(
|
|
118816
|
+
console.error(chalk40.red(`--viewport inválido: ${opts.viewport}`));
|
|
118567
118817
|
return 2;
|
|
118568
118818
|
}
|
|
118569
118819
|
const waitMs = Number.parseInt(opts.wait, 10) || 0;
|
|
@@ -118573,12 +118823,12 @@ async function statesCommand(opts) {
|
|
|
118573
118823
|
const prodSelector = opts.prodSelector?.trim() || opts.selector?.trim();
|
|
118574
118824
|
const candSelector = opts.candSelector?.trim() || opts.selector?.trim();
|
|
118575
118825
|
if (!prodSelector || !candSelector) {
|
|
118576
|
-
console.error(
|
|
118826
|
+
console.error(chalk40.red(" informe --selector (ambos os lados) ou --prod-selector e --cand-selector"));
|
|
118577
118827
|
return 2;
|
|
118578
118828
|
}
|
|
118579
118829
|
const { aliases, note: aliasNote } = resolveAliases(opts.planDir);
|
|
118580
118830
|
if (aliasNote)
|
|
118581
|
-
console.log(
|
|
118831
|
+
console.log(chalk40.dim(` ${aliasNote}`));
|
|
118582
118832
|
const browser = await launchBrowser({ headless: true });
|
|
118583
118833
|
try {
|
|
118584
118834
|
const [prodSide, candSide] = await Promise.all([
|
|
@@ -118603,7 +118853,7 @@ async function statesCommand(opts) {
|
|
|
118603
118853
|
]);
|
|
118604
118854
|
if (prodSide.baseError || candSide.baseError) {
|
|
118605
118855
|
const which = prodSide.baseError ? `prod: ${prodSide.baseError}` : `cand: ${candSide.baseError}`;
|
|
118606
|
-
console.error(
|
|
118856
|
+
console.error(chalk40.red(` não foi possível ler o componente — ${which}`));
|
|
118607
118857
|
return 2;
|
|
118608
118858
|
}
|
|
118609
118859
|
for (const [name, side, sel] of [
|
|
@@ -118612,13 +118862,13 @@ async function statesCommand(opts) {
|
|
|
118612
118862
|
]) {
|
|
118613
118863
|
const r = side.resolution;
|
|
118614
118864
|
if (r?.kind === "ambiguous") {
|
|
118615
|
-
console.error(
|
|
118865
|
+
console.error(chalk40.red(` ${name}: ${sel} matches ${r.total} visible elements and none looks like a product card (image + link + price). Narrow it to one:`));
|
|
118616
118866
|
for (const sample of r.samples)
|
|
118617
|
-
console.error(
|
|
118867
|
+
console.error(chalk40.dim(` ${sample}`));
|
|
118618
118868
|
return 2;
|
|
118619
118869
|
}
|
|
118620
118870
|
if (!r || r.kind === "none") {
|
|
118621
|
-
console.error(
|
|
118871
|
+
console.error(chalk40.red(` ${name}: ${sel} matches no visible element${r?.error ? ` — ${r.error}` : ""}`));
|
|
118622
118872
|
return 2;
|
|
118623
118873
|
}
|
|
118624
118874
|
}
|
|
@@ -118700,21 +118950,21 @@ async function statesCommand(opts) {
|
|
|
118700
118950
|
]) {
|
|
118701
118951
|
const caveat = data.settle && formatSettleCaveat(name, data.settle);
|
|
118702
118952
|
if (caveat)
|
|
118703
|
-
console.log(
|
|
118953
|
+
console.log(chalk40.yellow(` ${caveat}`));
|
|
118704
118954
|
}
|
|
118705
118955
|
if (cardMode) {
|
|
118706
118956
|
console.log("");
|
|
118707
|
-
console.log(
|
|
118957
|
+
console.log(chalk40.bold(` Product cards: ${pairing.pairs.length} pair(s) — ${pairing.pairs.map(([p, c]) => `prod #${p + 1} ↔ cand #${c + 1}`).join(", ") || "none"}`));
|
|
118708
118958
|
for (const [name, side] of [
|
|
118709
118959
|
["prod", prodSide],
|
|
118710
118960
|
["cand", candSide]
|
|
118711
118961
|
]) {
|
|
118712
118962
|
const r = side.resolution;
|
|
118713
118963
|
if (r?.kind === "cards" && r.ignored > 0) {
|
|
118714
|
-
console.log(
|
|
118964
|
+
console.log(chalk40.dim(` ${name}: ${r.ignored} matched element(s) are not product cards and were ignored`));
|
|
118715
118965
|
}
|
|
118716
118966
|
if (r?.kind === "single" && !r.isCard) {
|
|
118717
|
-
console.log(
|
|
118967
|
+
console.log(chalk40.yellow(` ${name}: the selector names one element that is not a product card; it is never paired with a card`));
|
|
118718
118968
|
}
|
|
118719
118969
|
}
|
|
118720
118970
|
const unpaired = [
|
|
@@ -118722,65 +118972,65 @@ async function statesCommand(opts) {
|
|
|
118722
118972
|
...pairing.unpairedCand.map((i) => `cand #${i + 1}`)
|
|
118723
118973
|
];
|
|
118724
118974
|
if (unpaired.length)
|
|
118725
|
-
console.log(
|
|
118975
|
+
console.log(chalk40.dim(` UNPAIRED cards: ${unpaired.join(", ")} — not compared`));
|
|
118726
118976
|
if (pairing.pairs.length === 0) {
|
|
118727
|
-
console.log(
|
|
118977
|
+
console.log(chalk40.yellow(" INCONCLUSIVE — no card paired, so nothing was compared."));
|
|
118728
118978
|
}
|
|
118729
118979
|
}
|
|
118730
118980
|
console.log("");
|
|
118731
|
-
console.log(
|
|
118981
|
+
console.log(chalk40.bold(" Declared motion"));
|
|
118732
118982
|
if (!motion) {
|
|
118733
118983
|
const err = prodFlat.motionError ?? candFlat.motionError ?? "nothing paired";
|
|
118734
|
-
console.log(
|
|
118984
|
+
console.log(chalk40.yellow(` não foi possível comparar — ${err}`));
|
|
118735
118985
|
} else {
|
|
118736
118986
|
for (const line of formatMotionDiff(motion).split(`
|
|
118737
118987
|
`))
|
|
118738
118988
|
console.log(` ${line}`);
|
|
118739
118989
|
}
|
|
118740
118990
|
console.log("");
|
|
118741
|
-
console.log(
|
|
118991
|
+
console.log(chalk40.bold(` Hover effects (${prodFlat.effects.length} prod / ${candFlat.effects.length} cand)`));
|
|
118742
118992
|
const nothing = effects.lost.length === 0 && effects.changed.length === 0 && effects.added.length === 0 && effects.unpaired.length === 0;
|
|
118743
118993
|
if (nothing && !exercised) {
|
|
118744
|
-
console.log(
|
|
118994
|
+
console.log(chalk40.yellow(" INCONCLUSIVE — no hover changed anything on either side, so nothing was exercised. Check the selector holds an interactive element."));
|
|
118745
118995
|
} else if (nothing) {
|
|
118746
118996
|
console.log(" clean — every hover that changes something in prod changes the same in cand");
|
|
118747
118997
|
}
|
|
118748
118998
|
for (const e of effects.lost) {
|
|
118749
|
-
console.log(
|
|
118999
|
+
console.log(chalk40.red(` LOST ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; cand's element was hovered and moved nothing`));
|
|
118750
119000
|
}
|
|
118751
119001
|
for (const { prod, extra, notComparable, onElement } of effects.changed) {
|
|
118752
119002
|
console.log(` DIFFERS ${prod.target}${prod.label ? ` (${prod.label})` : ""}`);
|
|
118753
119003
|
if (onElement.length) {
|
|
118754
|
-
console.log(
|
|
119004
|
+
console.log(chalk40.yellow(` prod also moves [${onElement.join(", ")}] on the element itself`));
|
|
118755
119005
|
}
|
|
118756
119006
|
if (extra.length)
|
|
118757
119007
|
console.log(` cand also moves [${extra.join(", ")}]`);
|
|
118758
119008
|
if (notComparable.length) {
|
|
118759
|
-
console.log(
|
|
119009
|
+
console.log(chalk40.dim(` not comparable: [${notComparable.join(", ")}] — prod's hover renumbered ${prod.renumberedNodes} of the changed paths, so these were read on elements that are not the same ones before and after. Bench the component, or pick a selector whose subtree the hover does not restructure.`));
|
|
118760
119010
|
}
|
|
118761
119011
|
if (onElement.length === 0 && extra.length === 0) {
|
|
118762
|
-
console.log(
|
|
119012
|
+
console.log(chalk40.dim(" nothing comparable differs."));
|
|
118763
119013
|
}
|
|
118764
119014
|
}
|
|
118765
119015
|
for (const e of effects.unpaired) {
|
|
118766
|
-
console.log(
|
|
119016
|
+
console.log(chalk40.dim(` UNPAIRED ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; no matching element found on the cand side (not a defect — the port may have changed the element, or it is outside --selector)`));
|
|
118767
119017
|
}
|
|
118768
119018
|
for (const e of effects.added) {
|
|
118769
119019
|
console.log(` ADDED ${e.target} — cand moves [${e.properties.join(", ")}]; prod does not`);
|
|
118770
119020
|
}
|
|
118771
119021
|
if (effects.unpaired.length > 0 && effects.lost.length === 0 && effects.changed.length === 0) {
|
|
118772
119022
|
console.log("");
|
|
118773
|
-
console.log(
|
|
119023
|
+
console.log(chalk40.yellow(` ${effects.unpaired.length} prod effect(s) had no counterpart and NOTHING paired. That is a pairing failure, not a set of defects — check --selector contains the same component on both sides, and that ported roots carry data-section.`));
|
|
118774
119024
|
}
|
|
118775
119025
|
const prodAmbient = prodSide.roots.reduce((n, r) => n + r.ambient, 0);
|
|
118776
119026
|
const candAmbient = candSide.roots.reduce((n, r) => n + r.ambient, 0);
|
|
118777
119027
|
if (prodAmbient > 0 || candAmbient > 0) {
|
|
118778
|
-
console.log(
|
|
119028
|
+
console.log(chalk40.dim(` ${prodAmbient} prod / ${candAmbient} cand node+property pair(s) were moving with no interaction (carousel, autoplaying video, anything on a timer) and were subtracted. A large count means --selector contains something animating on its own; narrow it.`));
|
|
118779
119029
|
}
|
|
118780
119030
|
for (const cap of caps)
|
|
118781
|
-
console.log(
|
|
119031
|
+
console.log(chalk40.yellow(` CAPPED — ${cap}; absence of a finding is not proof`));
|
|
118782
119032
|
if (truncated) {
|
|
118783
|
-
console.log(
|
|
119033
|
+
console.log(chalk40.dim(" TRUNCATED — box-tree or motion node cap hit; absence of a finding is not proof"));
|
|
118784
119034
|
}
|
|
118785
119035
|
return inconclusive || effects.lost.length > 0 || (motion?.findings.length ?? 0) > 0 ? 1 : 0;
|
|
118786
119036
|
} finally {
|
|
@@ -118792,7 +119042,7 @@ async function statesCommand(opts) {
|
|
|
118792
119042
|
|
|
118793
119043
|
// src/commands/stress.ts
|
|
118794
119044
|
import { createHash as createHash4 } from "node:crypto";
|
|
118795
|
-
import
|
|
119045
|
+
import chalk41 from "chalk";
|
|
118796
119046
|
var STATIC = /\.(png|jpe?g|webp|avif|gif|svg|woff2?|ttf|css|js|map|ico)(\?|$)/i;
|
|
118797
119047
|
function analyzeStress(requests, extra) {
|
|
118798
119048
|
const groups = new Map;
|
|
@@ -118822,7 +119072,7 @@ function analyzeStress(requests, extra) {
|
|
|
118822
119072
|
}
|
|
118823
119073
|
async function stressCommand(opts) {
|
|
118824
119074
|
if (!opts.selector && !opts.text) {
|
|
118825
|
-
console.error(
|
|
119075
|
+
console.error(chalk41.red("pass --selector or --text"));
|
|
118826
119076
|
return 2;
|
|
118827
119077
|
}
|
|
118828
119078
|
const browser = await launchBrowser({ headless: true });
|
|
@@ -118849,7 +119099,7 @@ async function stressCommand(opts) {
|
|
|
118849
119099
|
const target = (opts.selector ? page.locator(opts.selector) : page.getByText(opts.text, { exact: true })).filter({ visible: true }).first();
|
|
118850
119100
|
const box = await target.boundingBox().catch(() => null);
|
|
118851
119101
|
if (!box) {
|
|
118852
|
-
console.error(
|
|
119102
|
+
console.error(chalk41.yellow("target matched no visible element — nothing was stressed"));
|
|
118853
119103
|
return 2;
|
|
118854
119104
|
}
|
|
118855
119105
|
const handle = await target.elementHandle().catch(() => null);
|
|
@@ -118900,17 +119150,17 @@ async function stressCommand(opts) {
|
|
|
118900
119150
|
console.log(JSON.stringify({ url: opts.url, target: opts.selector ?? opts.text, ...report }));
|
|
118901
119151
|
return 0;
|
|
118902
119152
|
}
|
|
118903
|
-
console.log(
|
|
119153
|
+
console.log(chalk41.bold(`
|
|
118904
119154
|
${opts.times} clicks on ${opts.selector ?? `"${opts.text}"`}`));
|
|
118905
119155
|
console.log(` ${report.requests} request(s), ${report.mutations} mutating · disabled after 1st click: ${report.disabledAfterFirstClick ?? "?"}`);
|
|
118906
119156
|
for (const d of report.duplicates)
|
|
118907
|
-
console.log(
|
|
119157
|
+
console.log(chalk41.yellow(` ×${d.count} ${d.method} ${d.url.slice(0, 110)} [${d.statuses.join(",")}]`));
|
|
118908
119158
|
for (const f of report.failed.filter((f) => !report.duplicates.includes(f)))
|
|
118909
|
-
console.log(
|
|
119159
|
+
console.log(chalk41.red(` failed ${f.method} ${f.url.slice(0, 110)} [${f.statuses.join(",")}]`));
|
|
118910
119160
|
for (const e of report.consoleErrors.slice(0, 5))
|
|
118911
|
-
console.log(
|
|
119161
|
+
console.log(chalk41.red(` console: ${e}`));
|
|
118912
119162
|
if (opts.screenshot)
|
|
118913
|
-
console.log(
|
|
119163
|
+
console.log(chalk41.dim(` final state: ${opts.screenshot}`));
|
|
118914
119164
|
return 0;
|
|
118915
119165
|
} finally {
|
|
118916
119166
|
await browser.close().catch(() => {
|
|
@@ -118921,18 +119171,18 @@ async function stressCommand(opts) {
|
|
|
118921
119171
|
|
|
118922
119172
|
// src/commands/studio.ts
|
|
118923
119173
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
118924
|
-
import
|
|
119174
|
+
import chalk42 from "chalk";
|
|
118925
119175
|
var CLOSED = new Set(["done", "archived", "merged"]);
|
|
118926
119176
|
var PRIORITY_RANK = { urgent: 0, high: 1, medium: 2, low: 3, none: 4 };
|
|
118927
119177
|
function config() {
|
|
118928
119178
|
const cfg = studioConfigFromEnv();
|
|
118929
119179
|
if (!cfg) {
|
|
118930
|
-
console.error(
|
|
119180
|
+
console.error(chalk42.red(`Studio not configured — ${STUDIO_LOGIN_HINT}. The org comes from PARITY_STUDIO_URL (…/api/<org>/mcp/self) or PARITY_STUDIO_ORG.`));
|
|
118931
119181
|
}
|
|
118932
119182
|
return cfg;
|
|
118933
119183
|
}
|
|
118934
119184
|
function fail2(err) {
|
|
118935
|
-
console.error(
|
|
119185
|
+
console.error(chalk42.red(err instanceof Error ? err.message : String(err)));
|
|
118936
119186
|
return 1;
|
|
118937
119187
|
}
|
|
118938
119188
|
function seq(t) {
|
|
@@ -118940,7 +119190,7 @@ function seq(t) {
|
|
|
118940
119190
|
}
|
|
118941
119191
|
function line(t) {
|
|
118942
119192
|
const tags = [t.type, t.priority && t.priority !== "none" ? t.priority : null].filter(Boolean).join("·");
|
|
118943
|
-
return `${
|
|
119193
|
+
return `${chalk42.bold(seq(t).padEnd(6))} ${t.status.padEnd(12)} ${chalk42.dim(`[${tags}]`.padEnd(16))} ${t.title}${t.repo ? chalk42.dim(` ${t.repo}`) : ""}`;
|
|
118944
119194
|
}
|
|
118945
119195
|
async function resolveTask(cfg, ref, call) {
|
|
118946
119196
|
const board = await listTasks2(cfg, call);
|
|
@@ -118964,13 +119214,13 @@ async function studioTasksCommand(opts, call = callTool2) {
|
|
|
118964
119214
|
return 0;
|
|
118965
119215
|
}
|
|
118966
119216
|
if (board.items.length === 0) {
|
|
118967
|
-
console.log(
|
|
119217
|
+
console.log(chalk42.yellow("The board is empty."));
|
|
118968
119218
|
return 0;
|
|
118969
119219
|
}
|
|
118970
119220
|
for (const t of limited)
|
|
118971
119221
|
console.log(line(t));
|
|
118972
119222
|
const hidden = board.items.length - shown.length;
|
|
118973
|
-
console.log(
|
|
119223
|
+
console.log(chalk42.dim(` ${shown.length} of ${board.items.length} task(s)${limited.length < shown.length ? `, first ${limited.length} shown` : ""}${hidden > 0 && !statuses && !opts.all ? ` · ${hidden} done/archived/merged or filtered out (--all shows them)` : ""}`));
|
|
118974
119224
|
return 0;
|
|
118975
119225
|
} catch (err) {
|
|
118976
119226
|
return fail2(err);
|
|
@@ -118994,23 +119244,23 @@ async function studioShowCommand(opts, call = callTool2) {
|
|
|
118994
119244
|
return 0;
|
|
118995
119245
|
}
|
|
118996
119246
|
console.log(line(task));
|
|
118997
|
-
console.log(
|
|
119247
|
+
console.log(chalk42.dim(` id ${task.id}${task.statusSince ? ` · in ${task.status} since ${task.statusSince}` : ""}`));
|
|
118998
119248
|
if (task.description)
|
|
118999
119249
|
console.log(`
|
|
119000
119250
|
${task.description}
|
|
119001
119251
|
`);
|
|
119002
119252
|
if (prs === null)
|
|
119003
|
-
console.log(
|
|
119253
|
+
console.log(chalk42.dim(" (could not read linked PRs)"));
|
|
119004
119254
|
for (const pr of prs ?? []) {
|
|
119005
119255
|
const state = pr.merged ? "merged" : pr.draft ? "draft" : pr.state ?? "?";
|
|
119006
|
-
console.log(` PR ${state.padEnd(7)} ${pr.url}${pr.title ?
|
|
119256
|
+
console.log(` PR ${state.padEnd(7)} ${pr.url}${pr.title ? chalk42.dim(` ${pr.title}`) : ""}`);
|
|
119007
119257
|
}
|
|
119008
119258
|
const open = comments.filter((c) => !c.resolved);
|
|
119009
119259
|
if (open.length)
|
|
119010
|
-
console.log(
|
|
119260
|
+
console.log(chalk42.bold(`
|
|
119011
119261
|
Comments (${open.length} open)`));
|
|
119012
119262
|
for (const c of open)
|
|
119013
|
-
console.log(` ${
|
|
119263
|
+
console.log(` ${chalk42.dim(c.createdAt)} ${c.body.replace(/\n/g, `
|
|
119014
119264
|
`)}`);
|
|
119015
119265
|
return 0;
|
|
119016
119266
|
} catch (err) {
|
|
@@ -119029,7 +119279,7 @@ async function guardedMove(cfg, task, columns, to, opts, call) {
|
|
|
119029
119279
|
if (!valid.includes(to))
|
|
119030
119280
|
return fail2(new Error(`"${to}" is not a column of this board: ${valid.join(", ")}.`));
|
|
119031
119281
|
if (task.status === to) {
|
|
119032
|
-
console.log(
|
|
119282
|
+
console.log(chalk42.dim(`${seq(task)} is already in ${to}.`));
|
|
119033
119283
|
return 0;
|
|
119034
119284
|
}
|
|
119035
119285
|
const automated = await automatedColumns(cfg, call);
|
|
@@ -119037,16 +119287,16 @@ async function guardedMove(cfg, task, columns, to, opts, call) {
|
|
|
119037
119287
|
return fail2(new Error(`The "${to}" column has an automation: landing ${seq(task)} there starts the board's agent on it. Pass --allow-automation if that is the point.`));
|
|
119038
119288
|
}
|
|
119039
119289
|
if (!opts.yes) {
|
|
119040
|
-
console.log(
|
|
119290
|
+
console.log(chalk42.yellow("dry run — nothing changed. Pass --yes."));
|
|
119041
119291
|
console.log(` ${seq(task)} ${task.status} → ${to} ${task.title}`);
|
|
119042
119292
|
if (opts.comment)
|
|
119043
|
-
console.log(
|
|
119293
|
+
console.log(chalk42.dim(` and comment: ${PARITY_COMMENT_PREFIX} ${opts.comment}`));
|
|
119044
119294
|
return 0;
|
|
119045
119295
|
}
|
|
119046
119296
|
await moveTask(cfg, task.id, to, call);
|
|
119047
119297
|
if (opts.comment)
|
|
119048
119298
|
await postParityComment(task.id, opts.comment, cfg, call);
|
|
119049
|
-
console.log(`${
|
|
119299
|
+
console.log(`${chalk42.green("✓")} ${seq(task)} ${task.status} → ${to} ${task.title}`);
|
|
119050
119300
|
return 0;
|
|
119051
119301
|
}
|
|
119052
119302
|
async function studioTakeCommand(opts, call = callTool2) {
|
|
@@ -119095,12 +119345,12 @@ async function studioCommentCommand(opts, call = callTool2) {
|
|
|
119095
119345
|
if (found instanceof Error)
|
|
119096
119346
|
return fail2(found);
|
|
119097
119347
|
if (!opts.yes) {
|
|
119098
|
-
console.log(
|
|
119348
|
+
console.log(chalk42.yellow("dry run — nothing posted. Pass --yes."));
|
|
119099
119349
|
console.log(` on ${seq(found.task)}: ${PARITY_COMMENT_PREFIX} ${body}`);
|
|
119100
119350
|
return 0;
|
|
119101
119351
|
}
|
|
119102
119352
|
await postParityComment(found.task.id, body, cfg, call);
|
|
119103
|
-
console.log(`${
|
|
119353
|
+
console.log(`${chalk42.green("✓")} commented on ${seq(found.task)}`);
|
|
119104
119354
|
return 0;
|
|
119105
119355
|
} catch (err) {
|
|
119106
119356
|
return fail2(err);
|
|
@@ -119108,9 +119358,9 @@ async function studioCommentCommand(opts, call = callTool2) {
|
|
|
119108
119358
|
}
|
|
119109
119359
|
|
|
119110
119360
|
// src/commands/sweep.ts
|
|
119111
|
-
import { existsSync as existsSync37, readFileSync as readFileSync44, writeFileSync as
|
|
119361
|
+
import { existsSync as existsSync37, readFileSync as readFileSync44, writeFileSync as writeFileSync37 } from "node:fs";
|
|
119112
119362
|
import { join as join50 } from "node:path";
|
|
119113
|
-
import
|
|
119363
|
+
import chalk43 from "chalk";
|
|
119114
119364
|
import { z as z4 } from "zod";
|
|
119115
119365
|
|
|
119116
119366
|
// src/board/sweep-cards.ts
|
|
@@ -120046,6 +120296,11 @@ function runRegressionSpecs(repoDir, baseUrl) {
|
|
|
120046
120296
|
const dir = join49(repoDir, "tests", "qa");
|
|
120047
120297
|
if (!existsSync36(dir))
|
|
120048
120298
|
return null;
|
|
120299
|
+
spawnSync2("npx", ["playwright", "install", "chromium"], {
|
|
120300
|
+
cwd: repoDir,
|
|
120301
|
+
encoding: "utf8",
|
|
120302
|
+
timeout: 10 * 60000
|
|
120303
|
+
});
|
|
120049
120304
|
const config = join49(dir, "playwright.config.ts");
|
|
120050
120305
|
const args = existsSync36(config) ? ["playwright", "test", "-c", config, "--reporter=json"] : ["playwright", "test", "tests/qa", "--reporter=json"];
|
|
120051
120306
|
const res = spawnSync2("npx", args, {
|
|
@@ -120061,6 +120316,7 @@ function runRegressionSpecs(repoDir, baseUrl) {
|
|
|
120061
120316
|
return { errors: [{ message: (res.stderr || res.stdout || "no output").slice(0, 500) }] };
|
|
120062
120317
|
}
|
|
120063
120318
|
}
|
|
120319
|
+
var SETUP_FAILURE = /Executable doesn't exist|browserType\.launch|Cannot find module|ERR_MODULE_NOT_FOUND|Please run the following command to download new browsers/i;
|
|
120064
120320
|
function* specsOf(suite) {
|
|
120065
120321
|
for (const s of suite.specs ?? [])
|
|
120066
120322
|
yield { ...s, file: s.file ?? suite.file };
|
|
@@ -120086,12 +120342,18 @@ function regressionIssues(report) {
|
|
|
120086
120342
|
];
|
|
120087
120343
|
}
|
|
120088
120344
|
const issues = [];
|
|
120345
|
+
const setupFailures = [];
|
|
120089
120346
|
for (const s of ran) {
|
|
120090
120347
|
const results = (s.tests ?? []).flatMap((t) => t.results ?? []);
|
|
120091
120348
|
const last = results[results.length - 1];
|
|
120092
120349
|
if (!last || last.status === "passed" || last.status === "skipped")
|
|
120093
120350
|
continue;
|
|
120094
120351
|
const file = (s.file ?? "").split("/").pop() ?? "";
|
|
120352
|
+
if (SETUP_FAILURE.test(last.error?.message ?? "")) {
|
|
120353
|
+
setupFailures.push(`${file}: ${stripVTControlCharacters(last.error?.message ?? "").split(`
|
|
120354
|
+
`)[0]?.slice(0, 120)}`);
|
|
120355
|
+
continue;
|
|
120356
|
+
}
|
|
120095
120357
|
issues.push({
|
|
120096
120358
|
id: `sweep:regression:${file}:${s.title}`,
|
|
120097
120359
|
severity: "high",
|
|
@@ -120106,6 +120368,17 @@ function regressionIssues(report) {
|
|
|
120106
120368
|
reproduction: `1. No repositório da loja: \`BASE_URL=<site> npx playwright test -c tests/qa/playwright.config.ts ${file}\`.`
|
|
120107
120369
|
});
|
|
120108
120370
|
}
|
|
120371
|
+
if (setupFailures.length)
|
|
120372
|
+
issues.push({
|
|
120373
|
+
id: "sweep:regression:setup-failed",
|
|
120374
|
+
severity: "high",
|
|
120375
|
+
category: "functional",
|
|
120376
|
+
check: "regression-spec",
|
|
120377
|
+
summary: `Suíte de regressão: ${setupFailures.length} teste(s) não chegaram ao site (falha de setup, não do site)`,
|
|
120378
|
+
details: setupFailures.slice(0, 10).join(`
|
|
120379
|
+
`),
|
|
120380
|
+
inconclusive: true
|
|
120381
|
+
});
|
|
120109
120382
|
return issues;
|
|
120110
120383
|
}
|
|
120111
120384
|
|
|
@@ -120171,16 +120444,16 @@ async function sweepCommand(opts) {
|
|
|
120171
120444
|
const trend = annotateTrend(opts.output, done.runId);
|
|
120172
120445
|
if (!opts.json) {
|
|
120173
120446
|
if (trend) {
|
|
120174
|
-
console.log(
|
|
120447
|
+
console.log(chalk43.dim(` trend vs ${trend.previousRunId}: ${trend.new} new · ${trend.recurring} recurring · ${trend.resolved} resolved`));
|
|
120175
120448
|
} else {
|
|
120176
|
-
console.log(
|
|
120449
|
+
console.log(chalk43.dim(" trend: first sweep of this host"));
|
|
120177
120450
|
}
|
|
120178
120451
|
const missed = missedFloors(readReport(done.reportJson) ?? { flowCaptures: [] });
|
|
120179
120452
|
if (missed.length)
|
|
120180
|
-
console.log(
|
|
120453
|
+
console.log(chalk43.yellow(` não alcançado (${missed.length}): ${missed.join(", ")}`));
|
|
120181
120454
|
const unverified = readUnverified(done.reportJson);
|
|
120182
120455
|
if (unverified.length) {
|
|
120183
|
-
console.log(
|
|
120456
|
+
console.log(chalk43.yellow(` não verificado (${unverified.length}): ${unverified.slice(0, 8).join(", ")}${unverified.length > 8 ? "…" : ""}`));
|
|
120184
120457
|
}
|
|
120185
120458
|
}
|
|
120186
120459
|
if (opts.board) {
|
|
@@ -120242,7 +120515,7 @@ function annotateTrend(outputDir, runId) {
|
|
|
120242
120515
|
const prev = findPreviousSweep(outputDir, hostOf5(report.url), runId);
|
|
120243
120516
|
if (!prev) {
|
|
120244
120517
|
report.trend = null;
|
|
120245
|
-
|
|
120518
|
+
writeFileSync37(paths.reportJson, `${JSON.stringify(report, null, 2)}
|
|
120246
120519
|
`, "utf8");
|
|
120247
120520
|
return null;
|
|
120248
120521
|
}
|
|
@@ -120257,7 +120530,7 @@ function annotateTrend(outputDir, runId) {
|
|
|
120257
120530
|
resolved: d.resolved,
|
|
120258
120531
|
new: d.new
|
|
120259
120532
|
};
|
|
120260
|
-
|
|
120533
|
+
writeFileSync37(paths.reportJson, `${JSON.stringify(report, null, 2)}
|
|
120261
120534
|
`, "utf8");
|
|
120262
120535
|
return report.trend;
|
|
120263
120536
|
}
|
|
@@ -120268,7 +120541,7 @@ async function addProbeFindings(url, runDir, reportJson, rc, json, specsRepo) {
|
|
|
120268
120541
|
{ label: "menu", selectors: HAMBURGER_SELECTORS }
|
|
120269
120542
|
]).catch(() => []);
|
|
120270
120543
|
const menu = await probeMenuLinks(url, { screenshotsDir: join50(runDir, "screenshots") }).catch(() => []);
|
|
120271
|
-
|
|
120544
|
+
writeFileSync37(join50(runDir, "menu-links.json"), `${JSON.stringify(menu, null, 2)}
|
|
120272
120545
|
`, "utf8");
|
|
120273
120546
|
const listing = menu.find((v) => v.listingUi && v.products > 0);
|
|
120274
120547
|
const a11y = await probeA11y(url, listing ? new URL(listing.link.href).pathname : undefined).catch(() => []);
|
|
@@ -120290,11 +120563,11 @@ async function addProbeFindings(url, runDir, reportJson, rc, json, specsRepo) {
|
|
|
120290
120563
|
t[i.severity] = (t[i.severity] ?? 0) + 1;
|
|
120291
120564
|
}
|
|
120292
120565
|
}
|
|
120293
|
-
|
|
120566
|
+
writeFileSync37(reportJson, `${JSON.stringify(report, null, 2)}
|
|
120294
120567
|
`, "utf8");
|
|
120295
120568
|
if (!json) {
|
|
120296
120569
|
for (const i of issues)
|
|
120297
|
-
console.log(
|
|
120570
|
+
console.log(chalk43[i.inconclusive ? "yellow" : "red"](` ${i.summary}`));
|
|
120298
120571
|
}
|
|
120299
120572
|
}
|
|
120300
120573
|
function missedFloors(report) {
|
|
@@ -120389,28 +120662,28 @@ function mergeIssues(report, agent, dropped) {
|
|
|
120389
120662
|
}
|
|
120390
120663
|
async function sweepFileCommand(opts) {
|
|
120391
120664
|
if ((opts.board ?? "studio") !== "studio") {
|
|
120392
|
-
console.error(
|
|
120665
|
+
console.error(chalk43.red(`--board ${opts.board}: only "studio" is supported`));
|
|
120393
120666
|
return 2;
|
|
120394
120667
|
}
|
|
120395
120668
|
const minSeverity = opts.minSeverity ?? "medium";
|
|
120396
120669
|
if (!SEVERITIES.includes(minSeverity)) {
|
|
120397
|
-
console.error(
|
|
120670
|
+
console.error(chalk43.red(`--min-severity ${opts.minSeverity}: use ${SEVERITIES.join("|")}`));
|
|
120398
120671
|
return 2;
|
|
120399
120672
|
}
|
|
120400
120673
|
const runId = opts.run ?? listRuns(opts.output).find((r) => readReport(r.reportPath)?.mode === "sweep")?.id;
|
|
120401
120674
|
if (!runId) {
|
|
120402
|
-
console.error(
|
|
120675
|
+
console.error(chalk43.red(`no sweep run in ${opts.output} — run \`parity sweep --url …\` first`));
|
|
120403
120676
|
return 2;
|
|
120404
120677
|
}
|
|
120405
120678
|
const paths = getRunPaths(opts.output, runId);
|
|
120406
120679
|
const report = readReport(paths.reportJson);
|
|
120407
120680
|
if (!report || report.mode !== "sweep") {
|
|
120408
|
-
console.error(
|
|
120681
|
+
console.error(chalk43.red(`${runId} is not a sweep run`));
|
|
120409
120682
|
return 2;
|
|
120410
120683
|
}
|
|
120411
120684
|
const cfg = studioConfigFromEnv();
|
|
120412
120685
|
if (!cfg) {
|
|
120413
|
-
console.error(
|
|
120686
|
+
console.error(chalk43.red(`Studio not configured — ${STUDIO_LOGIN_HINT}; org via PARITY_STUDIO_ORG or PARITY_STUDIO_URL.`));
|
|
120414
120687
|
return 2;
|
|
120415
120688
|
}
|
|
120416
120689
|
const agent = readSweeperIssues(paths.runDir);
|
|
@@ -120456,7 +120729,7 @@ async function sweepFileCommand(opts) {
|
|
|
120456
120729
|
allowAutomation: opts.allowAutomation
|
|
120457
120730
|
});
|
|
120458
120731
|
} catch (err) {
|
|
120459
|
-
console.error(
|
|
120732
|
+
console.error(chalk43.red(err instanceof Error ? err.message : String(err)));
|
|
120460
120733
|
return 1;
|
|
120461
120734
|
}
|
|
120462
120735
|
if (opts.json) {
|
|
@@ -120473,14 +120746,14 @@ async function sweepFileCommand(opts) {
|
|
|
120473
120746
|
}));
|
|
120474
120747
|
return 0;
|
|
120475
120748
|
}
|
|
120476
|
-
const head = opts.yes ?
|
|
120749
|
+
const head = opts.yes ? chalk43.bold(" filed on the Studio board") : chalk43.bold(" dry run — add --yes to file");
|
|
120477
120750
|
console.log(`
|
|
120478
120751
|
${head} (run ${runId}, ≥ ${minSeverity}${agent.issues.length ? `, +${agent.issues.length} from sweeper` : ""})`);
|
|
120479
120752
|
for (const e of result.entries) {
|
|
120480
|
-
const tag = e.action === "create" ?
|
|
120753
|
+
const tag = e.action === "create" ? chalk43.green("create ") : e.action === "update" ? chalk43.yellow("update ") : e.action === "regression" ? chalk43.red("regress") : chalk43.dim("skip ");
|
|
120481
120754
|
console.log(` ${tag} ${e.title}`);
|
|
120482
120755
|
}
|
|
120483
|
-
console.log(
|
|
120756
|
+
console.log(chalk43.dim(` ${result.created} created · ${result.updated} updated · ${result.regressions} regressions · ${result.skipped} skipped${result.summaryRef ? ` · summary ${result.summaryRef}` : ""}`));
|
|
120484
120757
|
return 0;
|
|
120485
120758
|
}
|
|
120486
120759
|
function countTotals(issues) {
|
|
@@ -120530,11 +120803,11 @@ async function sweepScheduleCommand(opts) {
|
|
|
120530
120803
|
console.log(JSON.stringify(job));
|
|
120531
120804
|
return 0;
|
|
120532
120805
|
}
|
|
120533
|
-
console.log(
|
|
120806
|
+
console.log(chalk43.bold(`
|
|
120534
120807
|
control-plane JOB_CREATE payload (monthly sweep)
|
|
120535
120808
|
`));
|
|
120536
120809
|
console.log(JSON.stringify(job, null, 2));
|
|
120537
|
-
console.log(
|
|
120810
|
+
console.log(chalk43.dim([
|
|
120538
120811
|
"",
|
|
120539
120812
|
" How to create it:",
|
|
120540
120813
|
" • from Claude Code with the parity plugin: /parity:sweep schedule … (calls the deco-control-plane MCP `JOB_CREATE` with this payload)",
|
|
@@ -120550,7 +120823,7 @@ async function sweepScheduleCommand(opts) {
|
|
|
120550
120823
|
}
|
|
120551
120824
|
|
|
120552
120825
|
// src/commands/variance.ts
|
|
120553
|
-
import
|
|
120826
|
+
import chalk44 from "chalk";
|
|
120554
120827
|
|
|
120555
120828
|
// src/diff/variance.ts
|
|
120556
120829
|
var uniq2 = (xs) => [...new Set(xs)];
|
|
@@ -120654,7 +120927,7 @@ function formatVariance(report, opts = {}) {
|
|
|
120654
120927
|
// src/commands/variance.ts
|
|
120655
120928
|
function varianceCommand(opts) {
|
|
120656
120929
|
if (opts.runIds.length < 2) {
|
|
120657
|
-
console.error(
|
|
120930
|
+
console.error(chalk44.red(" informe pelo menos 2 runs: parity variance <runIdA> <runIdB> [...]"));
|
|
120658
120931
|
return 2;
|
|
120659
120932
|
}
|
|
120660
120933
|
const budget = Number.parseFloat(opts.scoreBudget ?? "1");
|
|
@@ -120663,7 +120936,7 @@ function varianceCommand(opts) {
|
|
|
120663
120936
|
try {
|
|
120664
120937
|
runs.push(loadRun(opts.output, id));
|
|
120665
120938
|
} catch (err) {
|
|
120666
|
-
console.error(
|
|
120939
|
+
console.error(chalk44.red(` ✖ ${err.message}`));
|
|
120667
120940
|
return 2;
|
|
120668
120941
|
}
|
|
120669
120942
|
}
|
|
@@ -120672,7 +120945,7 @@ function varianceCommand(opts) {
|
|
|
120672
120945
|
console.log(JSON.stringify({ ...report, stable: isStable(report, budget), scoreBudget: budget }));
|
|
120673
120946
|
} else {
|
|
120674
120947
|
console.log("");
|
|
120675
|
-
console.log(
|
|
120948
|
+
console.log(chalk44.bold(" Score variance"));
|
|
120676
120949
|
for (const line of formatVariance(report, { scoreBudget: budget }).split(`
|
|
120677
120950
|
`)) {
|
|
120678
120951
|
console.log(` ${line}`);
|
|
@@ -120684,10 +120957,10 @@ function varianceCommand(opts) {
|
|
|
120684
120957
|
}
|
|
120685
120958
|
|
|
120686
120959
|
// src/commands/vitals.ts
|
|
120687
|
-
import { existsSync as existsSync38, readFileSync as readFileSync45, writeFileSync as
|
|
120960
|
+
import { existsSync as existsSync38, readFileSync as readFileSync45, writeFileSync as writeFileSync38 } from "node:fs";
|
|
120688
120961
|
import { availableParallelism } from "node:os";
|
|
120689
120962
|
import { join as join51 } from "node:path";
|
|
120690
|
-
import
|
|
120963
|
+
import chalk45 from "chalk";
|
|
120691
120964
|
import ora9 from "ora";
|
|
120692
120965
|
|
|
120693
120966
|
// src/checks/agentic-nav.ts
|
|
@@ -120985,10 +121258,10 @@ async function vitalsCommand(opts) {
|
|
|
120985
121258
|
const runId = newRunId();
|
|
120986
121259
|
const paths = createRunDir(opts.output, runId);
|
|
120987
121260
|
const t0 = Date.now();
|
|
120988
|
-
console.log(
|
|
121261
|
+
console.log(chalk45.bold(`
|
|
120989
121262
|
parity vitals ${runId}`));
|
|
120990
|
-
console.log(
|
|
120991
|
-
console.log(
|
|
121263
|
+
console.log(chalk45.dim(` prod: ${opts.prod}`));
|
|
121264
|
+
console.log(chalk45.dim(` cand: ${opts.cand}`));
|
|
120992
121265
|
const discoverSpinner = ora9("Descobrindo páginas…").start();
|
|
120993
121266
|
const pagePaths = await discoverPagePaths2(opts.prod, opts);
|
|
120994
121267
|
if (pagePaths.length === 0) {
|
|
@@ -121020,7 +121293,7 @@ async function vitalsCommand(opts) {
|
|
|
121020
121293
|
completed++;
|
|
121021
121294
|
const elapsed = ((Date.now() - t0) / 1000).toFixed(0);
|
|
121022
121295
|
const etaSec = completed > 0 ? Math.round((Date.now() - t0) / completed * (total - completed) / 1000) : 0;
|
|
121023
|
-
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ?
|
|
121296
|
+
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk45.cyan("prod") : chalk45.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
121024
121297
|
}
|
|
121025
121298
|
});
|
|
121026
121299
|
progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
|
|
@@ -121049,7 +121322,7 @@ async function vitalsCommand(opts) {
|
|
|
121049
121322
|
}
|
|
121050
121323
|
lhCompleted++;
|
|
121051
121324
|
const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
|
|
121052
|
-
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ?
|
|
121325
|
+
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk45.cyan("prod") : chalk45.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
121053
121326
|
});
|
|
121054
121327
|
lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
|
|
121055
121328
|
}
|
|
@@ -121114,7 +121387,7 @@ async function vitalsCommand(opts) {
|
|
|
121114
121387
|
writeRunReportJson(paths.runDir, run);
|
|
121115
121388
|
const html = renderHtmlReport(run, paths.runDir);
|
|
121116
121389
|
writeRunReportHtml(paths.runDir, html);
|
|
121117
|
-
|
|
121390
|
+
writeFileSync38(join51(paths.runDir, "vitals.json"), `${JSON.stringify({
|
|
121118
121391
|
schemaVersion: "0.1",
|
|
121119
121392
|
prodUrl: opts.prod,
|
|
121120
121393
|
candUrl: opts.cand,
|
|
@@ -121127,8 +121400,8 @@ async function vitalsCommand(opts) {
|
|
|
121127
121400
|
`, "utf8");
|
|
121128
121401
|
printSummary9(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
|
|
121129
121402
|
console.log("");
|
|
121130
|
-
console.log(
|
|
121131
|
-
console.log(
|
|
121403
|
+
console.log(chalk45.dim(` → ${paths.reportHtml}`));
|
|
121404
|
+
console.log(chalk45.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
|
|
121132
121405
|
console.log("");
|
|
121133
121406
|
if (opts.open) {
|
|
121134
121407
|
const { default: open } = await import("open");
|
|
@@ -121228,7 +121501,7 @@ function parseUrlList(input) {
|
|
|
121228
121501
|
}
|
|
121229
121502
|
function printSummary9(vitals, cache, scores, opportunities, agentic) {
|
|
121230
121503
|
console.log("");
|
|
121231
|
-
console.log(
|
|
121504
|
+
console.log(chalk45.bold(" Summary:"));
|
|
121232
121505
|
console.log(` ${vitals.summary}`);
|
|
121233
121506
|
console.log(` ${cache.summary}`);
|
|
121234
121507
|
if (scores.status !== "skipped")
|
|
@@ -121288,15 +121561,16 @@ var sweep = program.command("sweep").description("Monthly QA sweep of ONE site:
|
|
|
121288
121561
|
});
|
|
121289
121562
|
sweep.addCommand(new Command("regress").description("Run only the store's tests/qa regression suite against --url — fast, no browser crawl, no LLM; for a daily job or every deploy. Exit 0 all passed, 1 a test failed again (regression), 2 nothing ran (missing install, all skipped). --json for the agent that audits the output.").requiredOption("--url <url>", "Site to test (production, or a PR preview)").requiredOption("--specs <repoDir>", "Store repo checkout with tests/qa installed").option("--json", "Emit one-line JSON", false).action(async (opts) => {
|
|
121290
121563
|
const issues = regressionIssues(runRegressionSpecs(opts.specs, opts.url));
|
|
121291
|
-
const
|
|
121564
|
+
const regressed = issues.some((i) => !i.inconclusive);
|
|
121565
|
+
const unverified = issues.some((i) => i.inconclusive);
|
|
121292
121566
|
if (opts.json)
|
|
121293
121567
|
console.log(JSON.stringify({ url: opts.url, issues }));
|
|
121294
121568
|
else if (!issues.length)
|
|
121295
|
-
console.log(
|
|
121569
|
+
console.log(chalk46.green(" regression suite: all passed"));
|
|
121296
121570
|
else
|
|
121297
121571
|
for (const i of issues)
|
|
121298
|
-
console.log((i.inconclusive ?
|
|
121299
|
-
process.exit(
|
|
121572
|
+
console.log((i.inconclusive ? chalk46.yellow : chalk46.red)(` ${i.summary}`));
|
|
121573
|
+
process.exit(regressed ? 1 : unverified ? 2 : 0);
|
|
121300
121574
|
}));
|
|
121301
121575
|
sweep.addCommand(new Command("file").description("File an existing sweep run's findings on the Studio board (default: the newest sweep run). Merges <run>/sweeper-issues.json written by the `sweeper` agent. Dry run unless --yes.").option("--run <runId>", "Sweep run id (default: newest sweep in --output)").option("--output <dir>", "Output directory", "./parity-output").option("--board <name>", "Board: studio", "studio").option("--yes", "Actually create/update cards", false).option("--allow-automation", "File even if the board's triage column starts an agent", false).option("--min-severity <sev>", "critical|high|medium|low", "medium").option("--repo <owner/name>", "Repository to put on the cards").option("--artifacts-url <url>", "Public base URL for this run's artifacts").option("--json", "Emit JSON", false).action(async (opts) => {
|
|
121302
121576
|
process.exit(await sweepFileCommand(opts));
|
|
@@ -121695,6 +121969,17 @@ program.command("overlay").description("Does opening an overlay move the page? F
|
|
|
121695
121969
|
json: opts.json
|
|
121696
121970
|
}));
|
|
121697
121971
|
});
|
|
121972
|
+
program.command("rerender").description("What does one interaction repaint? Click an element and report which page sections were remounted (a new element) vs only updated, skeletons that appeared, white flashes in the screencast, the requests fired, and when the screen settled. A tool for the sweeper: e.g. choosing a size should update the price, never remount the header or blank the page. --sheet writes the key frames.").requiredOption("--url <url>", "Page to open").option("--selector <sel>", "Element to click (visible match)").option("--text <text>", "Element to click, by exact visible text").option("--settle <ms>", "Wait after the click before reading", (v) => Number(v), 4000).option("--viewport <viewport>", "desktop | mobile", "desktop").option("--sheet <png>", "Write a contact sheet of the key frames").option("--json", "Emit one-line JSON", false).action(async (opts) => {
|
|
121973
|
+
process.exit(await rerenderCommand({
|
|
121974
|
+
url: opts.url,
|
|
121975
|
+
selector: opts.selector,
|
|
121976
|
+
text: opts.text,
|
|
121977
|
+
settleMs: opts.settle,
|
|
121978
|
+
viewport: opts.viewport,
|
|
121979
|
+
sheet: opts.sheet,
|
|
121980
|
+
json: opts.json
|
|
121981
|
+
}));
|
|
121982
|
+
});
|
|
121698
121983
|
program.command("stress").description("Click one element N times like an impatient shopper and measure what the site did: requests per click, duplicates (same method+URL+body = no debounce), failed requests, console errors, whether the control disabled itself, the final state. A tool for the sweeper agent: the numbers are facts, whether the outcome is a bug is its call.").requiredOption("--url <url>", "Page to open").option("--selector <sel>", "Element to click (visible match)").option("--text <text>", "Element to click, by exact visible text").option("--before <sel>", "Click this once before the burst (e.g. open the minicart)").option("--times <n>", "Clicks", (v) => Number(v), 10).option("--interval <ms>", "Pause between clicks (0 = as fast as the mouse goes)", (v) => Number(v), 0).option("--settle <ms>", "Wait after the burst before reading", (v) => Number(v), 4000).option("--viewport <viewport>", "desktop | mobile", "desktop").option("--screenshot <path>", "Save the final state").option("--json", "Emit one-line JSON", false).action(async (opts) => {
|
|
121699
121984
|
process.exit(await stressCommand({
|
|
121700
121985
|
url: opts.url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.5",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|