jacquardSnapshot

← snapshot

2793 bytes
/**
 * Opens the bulk-rename branch in the diff modal and checks that the fold is
 * both correct and honest: seven identical files collapse into one entry, and
 * the file that also changed its policy is NOT folded in with them.
 */
import { chromium } from "@playwright/test";

const API = "http://localhost:8787";
const repo = "meridian-systems";
const head = async (ref) =>
  (await (await fetch(`${API}/api/repos/${repo}/log?ref=${encodeURIComponent(ref)}&limit=1`)).json()).head;

const from = await head("feature/retry-jitter");
const into = await head("main");
const changed = (await (await fetch(`${API}/api/repos/${repo}/diff?from=${into}&to=${from}`)).json()).changed;

const b = await chromium.launch();
const p = await b.newPage({ viewport: { width: 1500, height: 1000 }, colorScheme: "dark" });
const errs = [];
p.on("pageerror", e => errs.push(e.message));
p.on("console", m => { if (m.type()==="error") errs.push(m.text()); });

// Mount the modal directly against the bulk branch via the harness page.
await p.goto(`http://localhost:3000/lab/diff?from=${from}&into=${into}&paths=${encodeURIComponent(changed.join(","))}`, { waitUntil: "networkidle" });
await p.waitForSelector(".jac-diffm", { timeout: 20000 });
await p.waitForFunction(() => !document.body.innerText.includes("reading "), { timeout: 30000 });
await p.waitForTimeout(800);

const info = await p.evaluate(() => {
  const folds = [...document.querySelectorAll(".jac-diffm-fold")].map(f => ({
    badge: f.querySelector(".jac-diffm-fold-badge")?.textContent,
    label: f.querySelector(".jac-diffm-file-name")?.textContent,
  }));
  const singles = [...document.querySelectorAll(".jac-diffm-file:not(.jac-diffm-fold)")]
    .map(f => f.querySelector(".jac-diffm-file-name")?.textContent);
  return {
    folds, singles,
    railLabel: document.querySelector(".jac-diffm-rail-label")?.textContent,
    sub: document.querySelector(".jac-diffm-sub")?.textContent?.replace(/\s+/g," ").trim(),
    members: document.querySelectorAll(".jac-diffm-members li").length,
    honesty: document.body.innerText.includes("never folded in"),
  };
});
console.log(JSON.stringify(info, null, 2));
await p.screenshot({ path: "tour/lab/diff-group.png" });

// The odd file must be reachable on its own and show BOTH its changes.
const odd = p.locator(".jac-diffm-file", { hasText: "upload.rs" }).first();
if (await odd.count()) {
  await odd.click();
  await p.waitForTimeout(600);
  const t = await p.evaluate(() => document.body.innerText);
  console.log("upload.rs shows timeout change:", t.includes("timeout"));
  await p.screenshot({ path: "tour/lab/diff-odd.png" });
} else {
  console.log("!! upload.rs not separately listed");
}
console.log("errors:", errs.length ? [...new Set(errs)].slice(0,3) : "none");
await b.close();