diff --git a/src/report.ts b/src/report.ts index f464b3c..b842f52 100644 --- a/src/report.ts +++ b/src/report.ts @@ -492,20 +492,22 @@ const head = (r: ComparedResult) => ` ${r.diffPixels.toLocaleString()} / ${r.totalPixels.toLocaleString()} px differ `; +const ROLE = { left: "left · change", right: "right · reference" }; + function card(r: ComparedResult): string { const imgs = r.images; return `
${head(r)} ${findings(r)}
-
left
-
right
+
${ROLE.left}
+
${ROLE.right}
diff
${imgs.diff ? `` : `

no differing pixels

`}
- +
`; } @@ -658,7 +660,7 @@ ${sidebar(results, meta.threshold)}

Visual diff

- left ${esc(meta.left)} vs right ${esc(meta.right)}
+ ${ROLE.left} ${esc(meta.left)} vs ${ROLE.right} ${esc(meta.right)}
${esc(meta.generatedAt)} · ${esc(meta.browser.name)} ${esc(meta.browser.version)}${( ["left", "right"] as const ) @@ -780,7 +782,7 @@ ${STYLE}

${esc(title)}

- left ${esc(meta.left)} vs right ${esc(meta.right)}
+ ${ROLE.left} ${esc(meta.left)} vs ${ROLE.right} ${esc(meta.right)}
${esc(meta.generatedAt)} · renderdiff ${esc(meta.version)} · widths ${meta.widths.join(", ")} · threshold ${meta.threshold === null ? "none" : pct(meta.threshold)} · diff --git a/tests/unit/report.test.ts b/tests/unit/report.test.ts index ee94072..fe90015 100644 --- a/tests/unit/report.test.ts +++ b/tests/unit/report.test.ts @@ -313,6 +313,19 @@ describe("writeReport", () => { ); }); + test("the report and evidence name left as the change and right as the reference", async () => { + const html = await report([at("/a", 1440)]); + const sides = + /left · change http:\/\/localhost:3000<\/code> vs right · reference https:\/\/example\.com<\/code>/; + assert.match(html, sides); + assert.match(await evidence([at("/a", 1440)]), sides); + assert.deepEqual( + [...html.matchAll(/

([^<]+)/g)].map((m) => m[1]), + ["left · change", "right · reference", "diff"], + ); + assert.match(html, /aria-label="Divider: your change on the left, the reference on the right"/); + }); + test("a packed zero-diff card says so in place of the diff image", async () => { const images = { left: "a.1440.left.webp", right: "a.1440.left.webp" }; const html = await report([at("/a", 1440, { images })]);