@decocms/parity 0.26.14 → 0.26.15

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 +59 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41723,8 +41723,13 @@ var ParityRc = z.object({
41723
41723
  addToCartConfirmMs: z.number().optional(),
41724
41724
  cartRevealTimeoutMs: z.number().optional()
41725
41725
  });
41726
+ var ExpectedDivergence = z.object({
41727
+ match: z.string(),
41728
+ note: z.string()
41729
+ });
41726
41730
  var ParityIgnore = z.object({
41727
41731
  ignoreSelectorsVisual: z.array(z.string()).default([]),
41732
+ expectedDivergences: z.array(ExpectedDivergence).optional(),
41728
41733
  ignoreRequestPatterns: z.array(z.string()).default([]),
41729
41734
  ignoreConsolePatterns: z.array(z.string()).default([]),
41730
41735
  ignoreMetaKeys: z.array(z.string()).default([]),
@@ -53253,6 +53258,35 @@ async function visualSemanticDiff(input) {
53253
53258
  }));
53254
53259
  }
53255
53260
 
53261
+ // src/diff/expected-divergence.ts
53262
+ function matchExpectedDivergence(haystacks, expected) {
53263
+ if (expected.length === 0)
53264
+ return null;
53265
+ const text3 = haystacks.filter((h) => Boolean(h)).join(" ").toLowerCase();
53266
+ if (!text3)
53267
+ return null;
53268
+ for (const e of expected) {
53269
+ const needle = e.match.trim().toLowerCase();
53270
+ if (!needle)
53271
+ continue;
53272
+ if (text3.includes(needle))
53273
+ return e;
53274
+ }
53275
+ return null;
53276
+ }
53277
+ function partitionExpectedSections(sections, expected) {
53278
+ const reportable = [];
53279
+ const accepted = [];
53280
+ for (const section of sections) {
53281
+ const hit = matchExpectedDivergence([section], expected);
53282
+ if (hit)
53283
+ accepted.push({ section, note: hit.note });
53284
+ else
53285
+ reportable.push(section);
53286
+ }
53287
+ return { reportable, accepted };
53288
+ }
53289
+
53256
53290
  // src/checks/lib/parity-cache.ts
53257
53291
  import { createHash as createHash2 } from "node:crypto";
53258
53292
  import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
@@ -53401,6 +53435,7 @@ async function visualRegressionKeyframes(ctx) {
53401
53435
  const diffDir = join12(ctx.outDir, "screenshots");
53402
53436
  if (!existsSync8(diffDir))
53403
53437
  mkdirSync8(diffDir, { recursive: true });
53438
+ const expectedDivergences = ctx.ignore.expectedDivergences ?? [];
53404
53439
  const useLlm = isLlmAvailable();
53405
53440
  const maxLlmCalls = getMaxLlmCalls();
53406
53441
  let llmCallsUsed = 0;
@@ -53573,16 +53608,30 @@ async function visualRegressionKeyframes(ctx) {
53573
53608
  llmError,
53574
53609
  cachedAt
53575
53610
  });
53576
- if (p.sectionsOnlyInProd.length > 0) {
53611
+ const sectionSplit = partitionExpectedSections(p.sectionsOnlyInProd, expectedDivergences);
53612
+ if (sectionSplit.accepted.length > 0) {
53613
+ issues.push({
53614
+ id: `visual:sections-expected:${p.pair.key}`,
53615
+ severity: "low",
53616
+ category: "visual",
53617
+ page: p.pair.key,
53618
+ check: "visual-regression-keyframes",
53619
+ inconclusive: true,
53620
+ summary: `${sectionSplit.accepted.length} section(s) ausente(s) em cand por decisão: ${sectionSplit.accepted.map((a) => a.section).join(", ")}`,
53621
+ details: sectionSplit.accepted.map((a) => `- ${a.section}: ${a.note}`).join(`
53622
+ `)
53623
+ });
53624
+ }
53625
+ if (sectionSplit.reportable.length > 0) {
53577
53626
  issues.push({
53578
53627
  id: `visual:sections:${p.pair.key}`,
53579
53628
  severity: "high",
53580
53629
  category: "visual",
53581
53630
  page: p.pair.key,
53582
53631
  check: "visual-regression-keyframes",
53583
- summary: `${p.sectionsOnlyInProd.length} section(s) ausente(s) em cand: ${p.sectionsOnlyInProd.join(", ")}`,
53632
+ summary: `${sectionSplit.reportable.length} section(s) ausente(s) em cand: ${sectionSplit.reportable.join(", ")}`,
53584
53633
  details: `Sections detectadas no DOM de prod via data-section, mas ausentes em cand:
53585
- ${p.sectionsOnlyInProd.map((s) => `- ${s}`).join(`
53634
+ ${sectionSplit.reportable.map((s) => `- ${s}`).join(`
53586
53635
  `)}
53587
53636
 
53588
53637
  Provavelmente faltam em registerSections() em src/setup.ts, ou o CMS não está resolvendo essas keys em cand.`,
@@ -53594,16 +53643,20 @@ Provavelmente faltam em registerSections() em src/setup.ts, ou o CMS não está
53594
53643
  });
53595
53644
  }
53596
53645
  for (const [i, d] of differences.entries()) {
53646
+ const accepted = matchExpectedDivergence([d.description, d.region], expectedDivergences);
53597
53647
  issues.push({
53598
53648
  id: `visual:semantic:${p.pair.key}:${i}`,
53599
- severity: severityForDiff(d),
53649
+ severity: accepted ? "low" : severityForDiff(d),
53600
53650
  category: "visual",
53601
53651
  page: p.pair.key,
53602
53652
  check: "visual-regression-keyframes",
53603
- summary: `[${d.region}] ${d.description}`,
53653
+ ...accepted ? { inconclusive: true } : {},
53654
+ summary: `[${d.region}] ${d.description}${accepted ? " (divergência esperada)" : ""}`,
53604
53655
  details: `Tipo: ${d.type}
53605
53656
  Região: ${d.region}
53606
- Severidade: ${d.severity}`,
53657
+ Severidade: ${d.severity}${accepted ? `
53658
+
53659
+ Decisão registrada: ${accepted.note}` : ""}`,
53607
53660
  evidence: [
53608
53661
  { kind: "screenshot", path: p.pair.prod.screenshotPath, label: "prod" },
53609
53662
  { kind: "screenshot", path: p.pair.cand.screenshotPath, label: "cand" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.26.14",
3
+ "version": "0.26.15",
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",