@decocms/parity 0.34.2 → 0.34.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +74 -11
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -76820,7 +76820,14 @@ function snapshotDom(html) {
76820
76820
  total: imgs.length,
76821
76821
  withSrcset: imgs.filter((_, el) => Boolean($(el).attr("srcset"))).length,
76822
76822
  withAlt: imgs.filter((_, el) => Boolean($(el).attr("alt"))).length,
76823
- withoutAlt: imgs.filter((_, el) => !$(el).attr("alt")).length,
76823
+ withoutAlt: imgs.filter((_, el) => {
76824
+ const $el = $(el);
76825
+ if ($el.attr("alt") !== undefined)
76826
+ return false;
76827
+ if ($el.attr("aria-hidden") === "true")
76828
+ return false;
76829
+ return !/^(presentation|none)$/.test($el.attr("role") ?? "");
76830
+ }).length,
76824
76831
  src: imgs.map((_, el) => $(el).attr("src") ?? "").get().filter(Boolean),
76825
76832
  banners
76826
76833
  };
@@ -119271,6 +119278,7 @@ function summaryCardBody(run, filed, belowThreshold) {
119271
119278
  function issueKey(issue) {
119272
119279
  const page = pageOf(issue);
119273
119280
  let summary = issue.summary.replace(/^\[(mobile|desktop|tablet)\]\s*/, "").replace(/\s*\(×\d+\)$/, "");
119281
+ summary = summary.replace(/\b(mobile|desktop|tablet):(?=https?:\/\/)/g, "");
119274
119282
  if (page)
119275
119283
  summary = summary.split(page).join("");
119276
119284
  summary = summary.replace(/::(mobile|desktop|tablet)/g, "").replace(/\d+(\.\d+)?\s*(MB|KB|ms|%)/gi, "#").replace(/\b\d+\.\d+\b/g, "#");
@@ -119345,7 +119353,10 @@ async function fileSweepCards(issues, runIn, cfg, opts = {}) {
119345
119353
  const selected = selectIssues(issues, opts.minSeverity, opts.hold);
119346
119354
  const entries = planCards(selected, board.items, runIn);
119347
119355
  const withSpecs = { ...runIn, specSources: readSpecs(entries) };
119348
- const run = opts.dryRun ? withSpecs : { ...withSpecs, evidenceUrls: await uploadEvidence(entries, runIn, cfg, call, opts) };
119356
+ const run = {
119357
+ ...withSpecs,
119358
+ evidenceUrls: opts.dryRun ? plannedEvidenceUrls(entries, runIn, cfg) : await uploadEvidence(entries, runIn, cfg, call, opts)
119359
+ };
119349
119360
  const result = { created: 0, updated: 0, regressions: 0, skipped: 0, entries };
119350
119361
  const filed = [];
119351
119362
  const month = monthOf(run.timestamp);
@@ -119424,8 +119435,12 @@ function readSpecs(entries) {
119424
119435
  out[ev.path] = readFileSync43(ev.path, "utf8");
119425
119436
  return out;
119426
119437
  }
119427
- async function uploadEvidence(entries, run, cfg, call, opts) {
119428
- const upload = opts.upload ?? ((local, lib) => uploadToLibrary(cfg, local, lib, call));
119438
+ function evidenceLibraryPath(p, run) {
119439
+ const idx = Math.max(p.indexOf("/screenshots/"), p.indexOf("/videos/"));
119440
+ const rel = idx >= 0 ? p.slice(idx + 1) : p.split("/").pop() ?? p;
119441
+ return `parity-sweep/${hostOf5(run.url)}/${run.runId}/${rel}`;
119442
+ }
119443
+ function cardEvidencePaths(entries) {
119429
119444
  const paths = new Set;
119430
119445
  for (const e of entries) {
119431
119446
  if (e.action === "skip" || !e.issue)
@@ -119433,13 +119448,25 @@ async function uploadEvidence(entries, run, cfg, call, opts) {
119433
119448
  for (const m of (e.issue.evidence ?? []).filter((x) => (x.kind === "screenshot" || x.kind === "video") && x.path).slice(0, 4))
119434
119449
  paths.add(m.path);
119435
119450
  }
119451
+ return paths;
119452
+ }
119453
+ function plannedEvidenceUrls(entries, run, cfg) {
119454
+ const base = cfg.url.match(/^(https?:\/\/[^/]+\/api\/[^/]+)\/mcp(\/|$)/)?.[1];
119455
+ if (!base)
119456
+ return {};
119436
119457
  const out = {};
119437
- for (const p of paths) {
119458
+ for (const p of cardEvidencePaths(entries))
119459
+ if (existsSync35(p))
119460
+ out[p] = `${base}/fs/org/read?path=${encodeURIComponent(evidenceLibraryPath(p, run))}`;
119461
+ return out;
119462
+ }
119463
+ async function uploadEvidence(entries, run, cfg, call, opts) {
119464
+ const upload = opts.upload ?? ((local, lib) => uploadToLibrary(cfg, local, lib, call));
119465
+ const out = {};
119466
+ for (const p of cardEvidencePaths(entries)) {
119438
119467
  if (!existsSync35(p))
119439
119468
  continue;
119440
- const idx = Math.max(p.indexOf("/screenshots/"), p.indexOf("/videos/"));
119441
- const rel = idx >= 0 ? p.slice(idx + 1) : p.split("/").pop() ?? p;
119442
- const url = await upload(p, `parity-sweep/${hostOf5(run.url)}/${run.runId}/${rel}`);
119469
+ const url = await upload(p, evidenceLibraryPath(p, run));
119443
119470
  if (url)
119444
119471
  out[p] = url;
119445
119472
  }
@@ -120019,6 +120046,11 @@ function runRegressionSpecs(repoDir, baseUrl) {
120019
120046
  const dir = join49(repoDir, "tests", "qa");
120020
120047
  if (!existsSync36(dir))
120021
120048
  return null;
120049
+ spawnSync2("npx", ["playwright", "install", "chromium"], {
120050
+ cwd: repoDir,
120051
+ encoding: "utf8",
120052
+ timeout: 10 * 60000
120053
+ });
120022
120054
  const config = join49(dir, "playwright.config.ts");
120023
120055
  const args = existsSync36(config) ? ["playwright", "test", "-c", config, "--reporter=json"] : ["playwright", "test", "tests/qa", "--reporter=json"];
120024
120056
  const res = spawnSync2("npx", args, {
@@ -120034,6 +120066,7 @@ function runRegressionSpecs(repoDir, baseUrl) {
120034
120066
  return { errors: [{ message: (res.stderr || res.stdout || "no output").slice(0, 500) }] };
120035
120067
  }
120036
120068
  }
120069
+ 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;
120037
120070
  function* specsOf(suite) {
120038
120071
  for (const s of suite.specs ?? [])
120039
120072
  yield { ...s, file: s.file ?? suite.file };
@@ -120059,12 +120092,18 @@ function regressionIssues(report) {
120059
120092
  ];
120060
120093
  }
120061
120094
  const issues = [];
120095
+ const setupFailures = [];
120062
120096
  for (const s of ran) {
120063
120097
  const results = (s.tests ?? []).flatMap((t) => t.results ?? []);
120064
120098
  const last = results[results.length - 1];
120065
120099
  if (!last || last.status === "passed" || last.status === "skipped")
120066
120100
  continue;
120067
120101
  const file = (s.file ?? "").split("/").pop() ?? "";
120102
+ if (SETUP_FAILURE.test(last.error?.message ?? "")) {
120103
+ setupFailures.push(`${file}: ${stripVTControlCharacters(last.error?.message ?? "").split(`
120104
+ `)[0]?.slice(0, 120)}`);
120105
+ continue;
120106
+ }
120068
120107
  issues.push({
120069
120108
  id: `sweep:regression:${file}:${s.title}`,
120070
120109
  severity: "high",
@@ -120079,6 +120118,17 @@ function regressionIssues(report) {
120079
120118
  reproduction: `1. No repositório da loja: \`BASE_URL=<site> npx playwright test -c tests/qa/playwright.config.ts ${file}\`.`
120080
120119
  });
120081
120120
  }
120121
+ if (setupFailures.length)
120122
+ issues.push({
120123
+ id: "sweep:regression:setup-failed",
120124
+ severity: "high",
120125
+ category: "functional",
120126
+ check: "regression-spec",
120127
+ summary: `Suíte de regressão: ${setupFailures.length} teste(s) não chegaram ao site (falha de setup, não do site)`,
120128
+ details: setupFailures.slice(0, 10).join(`
120129
+ `),
120130
+ inconclusive: true
120131
+ });
120082
120132
  return issues;
120083
120133
  }
120084
120134
 
@@ -120346,7 +120396,15 @@ function applyCardReview(issues, review) {
120346
120396
  return { issues: mergeIssues(issues, review.issues, new Set), held };
120347
120397
  }
120348
120398
  function mergeIssues(report, agent, dropped) {
120349
- const byId = new Map(report.filter((i) => !dropped.has(i.id)).map((i) => [i.id, i]));
120399
+ const rank = { critical: 0, high: 1, medium: 2, low: 3 };
120400
+ const byId = new Map;
120401
+ for (const i of report) {
120402
+ if (dropped.has(i.id))
120403
+ continue;
120404
+ const prev = byId.get(i.id);
120405
+ if (!prev || rank[i.severity] < rank[prev.severity])
120406
+ byId.set(i.id, i);
120407
+ }
120350
120408
  for (const i of agent)
120351
120409
  if (!dropped.has(i.id))
120352
120410
  byId.set(i.id, { ...byId.get(i.id), ...i });
@@ -120384,6 +120442,10 @@ async function sweepFileCommand(opts) {
120384
120442
  if (!e.path.startsWith("/"))
120385
120443
  e.path = join50(paths.runDir, e.path);
120386
120444
  const review = readCardReview(paths.runDir);
120445
+ for (const i of review.issues)
120446
+ for (const e of i.evidence ?? [])
120447
+ if (!e.path.startsWith("/"))
120448
+ e.path = join50(paths.runDir, e.path);
120387
120449
  const { issues, held } = applyCardReview(mergeIssues(report.allIssues ?? [], agent.issues, agent.dropped), review);
120388
120450
  const info = {
120389
120451
  runId,
@@ -121249,7 +121311,8 @@ var sweep = program.command("sweep").description("Monthly QA sweep of ONE site:
121249
121311
  });
121250
121312
  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) => {
121251
121313
  const issues = regressionIssues(runRegressionSpecs(opts.specs, opts.url));
121252
- const noneRan = issues.some((i) => i.inconclusive);
121314
+ const regressed = issues.some((i) => !i.inconclusive);
121315
+ const unverified = issues.some((i) => i.inconclusive);
121253
121316
  if (opts.json)
121254
121317
  console.log(JSON.stringify({ url: opts.url, issues }));
121255
121318
  else if (!issues.length)
@@ -121257,7 +121320,7 @@ sweep.addCommand(new Command("regress").description("Run only the store's tests/
121257
121320
  else
121258
121321
  for (const i of issues)
121259
121322
  console.log((i.inconclusive ? chalk45.yellow : chalk45.red)(` ${i.summary}`));
121260
- process.exit(noneRan ? 2 : issues.length ? 1 : 0);
121323
+ process.exit(regressed ? 1 : unverified ? 2 : 0);
121261
121324
  }));
121262
121325
  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) => {
121263
121326
  process.exit(await sweepFileCommand(opts));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.34.2",
3
+ "version": "0.34.4",
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",