From 860bef7e82e834f2e8ae8a0fe9b240bd36b245d5 Mon Sep 17 00:00:00 2001 From: Timur Mashara <62305878+tmashara@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:30:28 +0100 Subject: [PATCH] report: captions say which side is the change and which the reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit left and right didn't say which build was which, while --markdown says before and after. Captions and both meta lines now read left · change and right · reference, and the slider's label says the same. Left is the change and right the reference in every mode, so nothing is configured. Co-Authored-By: Claude Opus 5.5 --- src/report.ts | 12 +++++++----- tests/unit/report.test.ts | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) 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 })]);