jacquardSnapshot

← snapshot

1502 bytes
import { chromium } from "@playwright/test";
const [from, into, paths] = process.argv.slice(2);
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()); });
await p.goto(`http://localhost:3000/lab/diff?from=${from}&into=${into}&paths=${encodeURIComponent(paths)}`, { waitUntil: "networkidle" });
await p.waitForSelector(".jac-diffm", { timeout: 20000 });
await p.waitForFunction(() => !document.body.innerText.includes("reading ") && !document.body.innerText.includes("judging"), { timeout: 40000 });
await p.waitForTimeout(600);
const info = await p.evaluate(() => ({
  rail: document.querySelector(".jac-diffm-rail-label")?.textContent?.trim(),
  folds: [...document.querySelectorAll(".jac-diffm-fold")].map(f => ({
    badge: f.querySelector(".jac-diffm-fold-badge")?.textContent,
    label: f.querySelector(".jac-diffm-file-name")?.textContent,
    sub: f.querySelector(".jac-diffm-file-dir")?.textContent,
    judged: f.dataset.judged,
  })),
  singles: [...document.querySelectorAll(".jac-diffm-file:not(.jac-diffm-fold)")]
    .map(f => f.querySelector(".jac-diffm-file-name")?.textContent),
}));
console.log(JSON.stringify(info, null, 2));
await p.screenshot({ path: "tour/lab/diff-judge.png" });
console.log("errors:", errs.length ? [...new Set(errs)].slice(0,3) : "none");
await b.close();