Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Evaluation harness: browser check of the report and review pages, and fixes from a live run

Claude0cfc988e60ea
diff --git a/scripts/eval/eval.mjs b/scripts/eval/eval.mjs
index 8eeaf0ef..e9867fca 100644
--- a/scripts/eval/eval.mjs
+++ b/scripts/eval/eval.mjs
@@ -214,10 +214,10 @@ async function run(args, ctx) {
if (v.json) return ctx.print(JSON.stringify(result, null, 2)), 0;
const free = engine !== "cloud";
ctx.print(`${suite.title} on ${engine} (${result.server})`);
- ctx.print(`${result.jobs} jobs · ${result.runnable} can run · ${result.skipped} skipped · ${result.cases} cases · estimated ${free ? "Free" : money(result.estimateUsd)}${result.unknownCost ? ` (+${result.unknownCost} without a price)` : ""}${engine === "cloud" ? ` · cap ${money(result.maxUsd)}` : ""}`);
+ ctx.print(`${result.total} jobs · ${result.runnable} can run · ${result.skipped} skipped · ${result.cases} cases · estimated ${free ? "Free" : money(result.estimateUsd)}${result.unknownCost ? ` (+${result.unknownCost} without a price)` : ""}${engine === "cloud" ? ` · cap ${money(result.maxUsd)}` : ""}`);
if (result.models.length) ctx.print(`Models: ${result.models.join(", ")} · variants: ${result.variants.join(", ")}`);
for (const [why, n] of Object.entries(result.skipReasons).sort((a, b) => b[1] - a[1]).slice(0, 8)) ctx.print(` ${n} skipped: ${why}`);
- if (v.list) for (const j of result.jobs) ctx.print(` ${j.skip ? "·" : "▸"} ${j.case} · ${j.variant} · ${j.prompt} · s${j.seed} · ${j.model} · ${j.costUsd == null ? "?" : free ? "Free" : money(j.costUsd)}${j.loras?.applied ? ` · ${j.loras.applied.join(" + ") || "no LoRAs"}` : ""}${j.skip ? ` — ${j.skip}` : ""}`);
+ if (v.list) for (const j of result.jobs) ctx.print(` ${j.skip ? "·" : "▸"} ${j.case} · ${j.variant} · ${j.prompt} · s${j.seed} · ${j.model}${j.skip ? "" : ` · ${j.costUsd == null ? "price unknown" : free ? "Free" : money(j.costUsd)}`}${j.loras?.applied ? ` · ${j.loras.applied.join(" + ") || "no LoRAs"}` : ""}${j.skip ? ` — ${j.skip}` : ""}`);
return 0;
}
if (v["no-report"]) {
diff --git a/scripts/eval/lib/compare.mjs b/scripts/eval/lib/compare.mjs
index 7de273f3..b7b54a48 100644
--- a/scripts/eval/lib/compare.mjs
+++ b/scripts/eval/lib/compare.mjs
@@ -3,7 +3,8 @@
// compare A B: the jobs both runs made (same case, prompt, seed and variant; or two variants named
// with run:variant), per metric how often B is better, worse or the same as A, and the mean gain.
// With --fail-on, it exits non-zero when a chosen metric's mean gets worse by more than --threshold
-// (an absolute amount in the metric's units, or a percentage of A's mean like 5%).
+// (an absolute amount in the metric's units, a percentage of A's mean like 5%, or by default the
+// metric's noise band from metric-info.mjs).
//
// promote: a recipe becomes a look's default only when it wins (see PROMOTE_RULE). The command
// writes promote.json and says what to change; the catalog default stays a code change a person
@@ -81,7 +82,7 @@ export function compareRuns(a, b, opts = {}) {
regressions.push({ metric, reason: `no ${metric} scores in both runs`, missing: true });
continue;
}
- const limit = thresholdFor(opts.threshold, row.meanA);
+ const limit = thresholdFor(opts.threshold, row.meanA, metric);
if (row.meanGain < -limit) regressions.push({ metric, reason: `mean ${fmt(metric, row.meanA)} → ${fmt(metric, row.meanB)} (${signed(metric, row.meanGain)}), worse than the ${fmt(metric, limit)} allowed` });
if (opts.perCase) {
for (const c of perCase) {
@@ -104,9 +105,9 @@ export function compareRuns(a, b, opts = {}) {
};
}
-/** --threshold: a number in the metric's units, "5%" of A's mean, or the metric's tie band when not given. */
-function thresholdFor(t, base) {
- if (t == null || t === "") return 0;
+/** --threshold: a number in the metric's units, "5%" of A's mean, or (not given) the metric's own noise band. */
+function thresholdFor(t, base, metric) {
+ if (t == null || t === "") return METRIC_INFO[metric]?.tie ?? 0;
const s = String(t).trim();
if (s.endsWith("%")) return (Math.abs(base ?? 0) * Number(s.slice(0, -1))) / 100;
const n = Number(s);
diff --git a/scripts/eval/lib/html.mjs b/scripts/eval/lib/html.mjs
index be085641..b994fe2e 100644
--- a/scripts/eval/lib/html.mjs
+++ b/scripts/eval/lib/html.mjs
@@ -41,11 +41,12 @@ a { color: var(--accent); }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; white-space: nowrap; }
-.chip.good { color: var(--good); } .chip.bad { color: var(--bad); }
+.chip.good, .good-text { color: var(--good); } .chip.bad, .bad-text { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-width: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.media { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--chip); border-radius: 8px; display: block; }
-.facts { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin: 12px 0; }
+.facts { display: grid; gap: 8px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin: 12px 0; }
+@media (max-width: 480px) { .facts { grid-template-columns: 1fr 1fr; } }
.facts div { min-width: 0; } .facts b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.btn { appearance: none; border: 1px solid var(--border); background: var(--card); color: var(--fg); border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
diff --git a/scripts/eval/lib/media.mjs b/scripts/eval/lib/media.mjs
index baf5e6b2..f0ba7313 100644
--- a/scripts/eval/lib/media.mjs
+++ b/scripts/eval/lib/media.mjs
@@ -39,6 +39,7 @@ export function localInputs(inputs) {
export function uploader(client, runDir, { dry = false, log = () => {} } = {}) {
const cacheFile = runDir ? path.join(runDir, "uploads.json") : null;
const cache = (cacheFile && readJson(cacheFile, {})) || {};
+ const pending = new Map();
const keyOf = (abs) => {
const st = fs.statSync(abs);
return `${abs}|${st.size}|${Math.round(st.mtimeMs)}`;
@@ -51,15 +52,9 @@ export function uploader(client, runDir, { dry = false, log = () => {} } = {}) {
if (dry) return `/api/files/uploads/estimate/${path.basename(ref)}`;
const key = keyOf(ref);
if (cache[key]) return cache[key];
- const type = contentType(ref);
- const blob = typeof fs.openAsBlob === "function" ? await fs.openAsBlob(ref, { type }) : new Blob([fs.readFileSync(ref)], { type });
- const form = new FormData();
- form.append("file", blob, path.basename(ref));
- log(`Uploading ${path.basename(ref)}`);
- const asset = await client.request("POST", "/api/uploads", { form });
- cache[key] = asset.url;
- if (cacheFile) writeJson(cacheFile, cache);
- return asset.url;
+ // The same file twice in one request (a clip joined to itself) goes up once.
+ if (!pending.has(key)) pending.set(key, send(ref, key).finally(() => pending.delete(key)));
+ return pending.get(key);
},
/** The same inputs with every local path replaced by its URL. */
async inputs(inputs) {
@@ -68,6 +63,18 @@ export function uploader(client, runDir, { dry = false, log = () => {} } = {}) {
return out;
},
};
+ /** Upload one file and remember its URL. */
+ async function send(ref, key) {
+ const type = contentType(ref);
+ const blob = typeof fs.openAsBlob === "function" ? await fs.openAsBlob(ref, { type }) : new Blob([fs.readFileSync(ref)], { type });
+ const form = new FormData();
+ form.append("file", blob, path.basename(ref));
+ log(`Uploading ${path.basename(ref)}`);
+ const asset = await client.request("POST", "/api/uploads", { form });
+ cache[key] = asset.url;
+ if (cacheFile) writeJson(cacheFile, cache);
+ return asset.url;
+ }
}
/** ffprobe's facts about a clip: {duration, fps, width, height, hasAudio}, or {} when ffprobe isn't there. */
diff --git a/scripts/eval/lib/report.mjs b/scripts/eval/lib/report.mjs
index 7cde28c3..4a4f8035 100644
--- a/scripts/eval/lib/report.mjs
+++ b/scripts/eval/lib/report.mjs
@@ -37,7 +37,8 @@ export function jobScores(row, metricsDoc) {
if (row.status === "succeeded" && ms != null) out.seconds = Math.round(ms / 100) / 10;
const cost = row.costUsd?.actual ?? row.costUsd?.estimate;
if (row.status === "succeeded" && cost != null) out.costUsd = cost;
- const vram = row.vram?.torchPeakGb ?? row.vram?.peakUsedGb;
+ // On a CPU ComfyUI the device's memory is the whole machine's RAM: kept in the row, not scored as VRAM.
+ const vram = row.vram?.type === "cpu" ? null : (row.vram?.torchPeakGb ?? row.vram?.peakUsedGb);
if (vram != null) out.vramGb = vram;
return out;
}
@@ -194,8 +195,9 @@ function chips(scores, keys) {
/** The contact sheet. */
export function reportHtml(summary) {
- const keys = summary.metrics.keys;
const free = summary.engine !== "cloud";
+ // Cost is in each card's first line; per metric it only matters on the cloud.
+ const keys = summary.metrics.keys.filter((k) => !(free && k === "costUsd"));
const variantCards = Object.entries(summary.variants)
.map(([v, s]) => {
const lines = keys.filter((k) => s.mean[k] != null).map((k) => `<div class="stat"><span>${esc(METRIC_INFO[k].label)}</span><span>${k === "costUsd" ? esc(money(s.mean[k])) : esc(fmt(k, s.mean[k]))} <span class="muted">n=${s.n[k]}</span></span></div>`);
@@ -206,8 +208,9 @@ export function reportHtml(summary) {
.filter((p) => Object.keys(p.metrics).length)
.map(
(p) =>
- `<div class="card"><h3>${esc(p.base)} vs ${esc(p.other)}</h3>${Object.entries(p.metrics)
- .map(([k, s]) => `<div class="stat"><span>${esc(METRIC_INFO[k].label)}</span><span><span class="chip good">${s.wins} better</span> <span class="chip bad">${s.losses} worse</span> <span class="chip">${s.ties} same</span></span></div>`)
+ `<div class="card"><h3>${esc(p.base)} against ${esc(p.other)}</h3><p class="muted" style="font-size:12px">How often ${esc(p.base)} is better, worse or the same on the same case, prompt and seed</p>${Object.entries(p.metrics)
+ .filter(([k]) => keys.includes(k))
+ .map(([k, s]) => `<div class="stat"><span>${esc(METRIC_INFO[k].label)}</span><span><span class="good-text">${s.wins} better</span> · <span class="bad-text">${s.losses} worse</span> · ${s.ties} same</span></div>`)
.join("")}</div>`,
)
.join("");
@@ -253,7 +256,7 @@ ${summary.comfy ? `<div><b>ComfyUI</b>${esc(summary.comfy.version ?? (summary.co
${skipped.length ? `<p class="muted">Not scored: ${skipped.map(([k, v]) => `${esc(k)} (${esc(v)})`).join("; ")}</p>` : ""}
${summary.skips.length ? `<p class="muted">Skipped jobs: ${summary.skips.map((s) => `${s.count} × ${esc(s.reason)}`).join("; ")}</p>` : ""}
<h2>Variants</h2><div class="stats">${variantCards}</div>
-${pairCards ? `<h2>Same case, same seed</h2><div class="stats">${pairCards}</div>` : ""}
+${pairCards ? `<h2>Variant against variant</h2><div class="stats">${pairCards}</div>` : ""}
${ratings}
<h2>Cases</h2>
${caseBlocks}
diff --git a/scripts/eval/lib/review.mjs b/scripts/eval/lib/review.mjs
index 77ab8c93..7c6dddfc 100644
--- a/scripts/eval/lib/review.mjs
+++ b/scripts/eval/lib/review.mjs
@@ -98,15 +98,26 @@ export function writeReview(run, opts = {}) {
/** The review page: one pair at a time, keyboard first, works on a phone. */
export function reviewHtml(runId, items) {
const css = `
+/* Both results stay side by side, on a phone too: an A/B is judged by looking at the two at once. */
.pair { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
-@media (max-width: 640px) { .pair { grid-template-columns: 1fr; } }
.side { position: relative; border: 2px solid var(--border); border-radius: 12px; padding: 8px; background: var(--card); min-width: 0; }
.side.picked { border-color: var(--accent); }
.side .tag { position: absolute; top: 12px; left: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; font-weight: 600; }
.side img, .side video { width: 100%; max-height: 62vh; object-fit: contain; display: block; border-radius: 8px; background: var(--chip); }
.bar { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); padding: 12px 0; margin-top: 16px; }
.bar .row { justify-content: center; }
+.keys { text-align: center; margin-top: 8px; font-size: 12px; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }
+@media (max-width: 640px) {
+ .pair { gap: 6px; }
+ .side { padding: 4px; border-radius: 10px; }
+ .side .tag { top: 8px; left: 8px; font-size: 12px; }
+ .bar .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
+ .bar .btn { padding: 10px 6px; }
+ .bar .btn.minor { grid-column: span 1; }
+}
+/* Touch screens: no keyboard hints. */
+@media (hover: none) { .keys, .bar kbd { display: none; } }
`;
const body = `<main>
<div class="row" style="justify-content:space-between"><h1>Blind review</h1><div class="row"><button class="btn" type="button" id="download">Download ratings</button><button class="btn" type="button" onclick="toggleTheme()">Light / dark</button></div></div>
@@ -116,12 +127,12 @@ progress { width: 100%; height: 6px; accent-color: var(--accent); }
<p id="count" class="muted"></p>
<section id="stage" aria-live="polite"></section>
<div class="bar"><div class="row">
-<button class="btn" type="button" data-choice="left"><kbd>←</kbd> Left is better</button>
-<button class="btn" type="button" data-choice="same"><kbd>↓</kbd> About the same</button>
-<button class="btn" type="button" data-choice="right">Right is better <kbd>→</kbd></button>
-<button class="btn" type="button" data-choice="skip"><kbd>S</kbd> Skip</button>
-<button class="btn" type="button" id="undo"><kbd>U</kbd> Undo</button>
-</div><p class="muted" style="text-align:center;margin-top:8px;font-size:12px">Keys: <kbd>←</kbd>/<kbd>1</kbd> left · <kbd>→</kbd>/<kbd>2</kbd> right · <kbd>↓</kbd>/<kbd>0</kbd>/<kbd>Space</kbd> same · <kbd>S</kbd> skip · <kbd>U</kbd> undo</p></div>
+<button class="btn primary" type="button" data-choice="left"><kbd>←</kbd> Left is better</button>
+<button class="btn" type="button" data-choice="same"><kbd>↓</kbd> Same</button>
+<button class="btn primary" type="button" data-choice="right">Right is better <kbd>→</kbd></button>
+<button class="btn minor" type="button" data-choice="skip"><kbd>S</kbd> Skip</button>
+<button class="btn minor" type="button" id="undo"><kbd>U</kbd> Undo</button>
+</div><p class="muted keys">Keys: <kbd>←</kbd>/<kbd>1</kbd> left · <kbd>→</kbd>/<kbd>2</kbd> right · <kbd>↓</kbd>/<kbd>0</kbd>/<kbd>Space</kbd> same · <kbd>S</kbd> skip · <kbd>U</kbd> undo</p></div>
</main>`;
const script = `
const RUN = ${JSON.stringify(runId)};
diff --git a/scripts/eval/lib/run.mjs b/scripts/eval/lib/run.mjs
index fbf3214a..cb1c6a4d 100644
--- a/scripts/eval/lib/run.mjs
+++ b/scripts/eval/lib/run.mjs
@@ -147,7 +147,8 @@ export async function runEval(opts, io) {
if (opts.dryRun) {
const final = planSummary(jobs);
- return { dryRun: true, suite: suite.suite, engine, server: io.target?.url ?? client.url, ...final, estimateUsd: estimate, unknownCost, maxUsd, jobs: jobs.map(publicJob) };
+ const { jobs: total, ...counts } = final;
+ return { dryRun: true, suite: suite.suite, engine, server: io.target?.url ?? client.url, total, ...counts, estimateUsd: estimate, unknownCost, maxUsd: Number.isFinite(maxUsd) ? maxUsd : null, jobs: jobs.map(publicJob) };
}
if (engine === "cloud" && estimate > maxUsd) {
throw new Error(`This run would cost about ${money(estimate)}, over the spend cap of ${money(maxUsd)}. Raise it with --max-usd ${Math.ceil(estimate)} or run fewer jobs (--looks, --cases, --limit, --prompts).`);
diff --git a/tests/e2e/eval-review.mjs b/tests/e2e/eval-review.mjs
new file mode 100644
index 00000000..61c0e589
--- /dev/null
+++ b/tests/e2e/eval-review.mjs
@@ -0,0 +1,155 @@
+// The evaluation harness's pages in a browser: the run report (contact sheet) and the blind A/B
+// review, at 1440 and 390 px, light and dark. Checks that nothing scrolls sideways, that the review
+// never names a variant, and that keyboard ratings reach review/ratings.json and the summary.
+//
+// node tests/e2e/eval-review.mjs (builds a small run from the fixtures in a temp folder)
+// node tests/e2e/eval-review.mjs <run dir> (a real run: scripts/eval/results/<runId>)
+//
+// Screenshots go to $SHOTS (default: the temp folder).
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { pathToFileURL } from "node:url";
+import { DESKTOP, launch, PHONE, root } from "./_browser.mjs";
+
+const { writeReport, loadRun } = await import(path.join(root, "scripts/eval/lib/report.mjs"));
+const { serveReview, writeReview } = await import(path.join(root, "scripts/eval/lib/review.mjs"));
+const { latestJobs } = await import(path.join(root, "scripts/eval/lib/store.mjs"));
+
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-eval-review-"));
+const shots = process.env.SHOTS ?? tmp;
+let runDir = process.argv[2] ? path.resolve(process.argv[2]) : null;
+
+/** A run like the runner writes: two looks × two variants × two seeds, on the fixture images. */
+function fixtureRun() {
+ const dir = path.join(tmp, "results", "20261023-120000-soul-open-e2e0");
+ fs.mkdirSync(path.join(dir, "outputs"), { recursive: true });
+ const pics = ["start-frame.png", "end-frame.png", "references/warm-1.png", "references/warm-2.png"].map((f) => path.join(root, "scripts/eval/fixtures", f));
+ const rows = [];
+ const metrics = { version: 1, jobs: {}, groups: {}, models: { clip: { repo: "laion/CLIP-ViT-B-32-laion2B-s34B-b79K", licence: "MIT" } }, skipped: {} };
+ let n = 0;
+ for (const look of ["v1-general", "v2-flash-editorial"]) {
+ for (const variant of ["recipe", "prompt-only"]) {
+ for (const seed of [1001, 2002]) {
+ const id = `soul__${look}--portrait--s${seed}--${variant}`;
+ fs.mkdirSync(path.join(dir, "outputs", id), { recursive: true });
+ fs.copyFileSync(pics[n++ % pics.length], path.join(dir, "outputs", id, "1.png"));
+ rows.push({
+ id,
+ key: `soul/${look}/portrait/s${seed}`,
+ suite: "soul",
+ caseId: `soul/${look}`,
+ caseTitle: look === "v1-general" ? "Soul v1 · General" : "Soul 2.0 · Flash editorial — a long title that has to wrap on a phone without pushing the page sideways",
+ variant,
+ promptId: "portrait",
+ prompt: "a young woman with freckles and loose dark hair looks over her shoulder on a quiet city street",
+ seed,
+ engine: "open",
+ kind: "image",
+ status: "succeeded",
+ model: { id: "oss-z-image-turbo", provider: "comfyui" },
+ outputs: [{ file: `outputs/${id}/1.png`, kind: "image" }],
+ recipe: { kind: "soul-look", look: { name: look }, applied: variant === "recipe" ? [{ file: "AWPortrait-Z.safetensors", strength: 0.6 }] : [], sent: { complete: true, loras: [] }, complete: true },
+ costUsd: { estimate: 0, actual: 0 },
+ timing: { wallMs: 9000 + seed },
+ notes: [],
+ });
+ metrics.jobs[id] = { clip: 25 + seed / 1000 + (variant === "recipe" ? 1 : 0), aesthetic: 5.5, style: 0.6 + (variant === "recipe" ? 0.05 : 0) };
+ }
+ }
+ }
+ fs.writeFileSync(path.join(dir, "run.json"), JSON.stringify({ runId: path.basename(dir), suite: "soul", title: "Fuobe Soul · the 139 looks", engine: "open", variants: ["recipe", "prompt-only"], variantInfo: { recipe: "The research recipe", "prompt-only": "The look's words without LoRAs" }, startedAt: Date.now(), server: { url: "http://localhost:3000" }, harness: { commit: "e2e" } }));
+ fs.writeFileSync(path.join(dir, "jobs.jsonl"), rows.map((r) => JSON.stringify(r)).join("\n") + "\n");
+ fs.writeFileSync(path.join(dir, "metrics.json"), JSON.stringify(metrics));
+ return dir;
+}
+
+runDir ??= fixtureRun();
+const resultsRoot = path.dirname(runDir);
+writeReport(runDir, resultsRoot);
+const runId = path.basename(runDir);
+const made = writeReview({ dir: runDir, runId, rows: latestJobs(runDir) });
+const { server, url } = await serveReview(runDir);
+
+const failures = [];
+const check = (ok, what) => {
+ console.log(`${ok ? "✓" : "✗"} ${what}`);
+ if (!ok) failures.push(what);
+};
+
+const browser = await launch();
+try {
+ for (const [name, device] of [
+ ["1440", DESKTOP],
+ ["390", PHONE],
+ ]) {
+ for (const scheme of ["light", "dark"]) {
+ const ctx = await browser.newContext({ ...device, colorScheme: scheme });
+ const page = await ctx.newPage();
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+
+ await page.goto(pathToFileURL(path.join(runDir, "report.html")).href, { waitUntil: "load" });
+ await page.waitForTimeout(300);
+ const report = await page.evaluate(() => ({
+ overflow: document.scrollingElement.scrollWidth - window.innerWidth,
+ bg: getComputedStyle(document.body).backgroundColor,
+ imgs: [...document.images].filter((i) => i.complete && i.naturalWidth > 0).length,
+ h1: document.querySelector("h1")?.textContent,
+ }));
+ check(report.overflow <= 0, `report ${name} ${scheme}: no sideways scroll (${report.overflow}px over)`);
+ check(scheme === "dark" ? report.bg === "rgb(9, 9, 11)" : report.bg === "rgb(255, 255, 255)", `report ${name} ${scheme}: ${scheme} background (${report.bg})`);
+ check(report.imgs > 0, `report ${name} ${scheme}: ${report.imgs} images load`);
+ await page.screenshot({ path: path.join(shots, `report-${name}-${scheme}.png`), fullPage: false });
+
+ await page.goto(url, { waitUntil: "load" });
+ await page.waitForSelector("#stage img, #stage video, #stage h2, #stage p");
+ const review = await page.evaluate(() => ({ overflow: document.scrollingElement.scrollWidth - window.innerWidth, text: document.body.innerText }));
+ check(review.overflow <= 0, `review ${name} ${scheme}: no sideways scroll (${review.overflow}px over)`);
+ check(!/prompt-only|recipe/.test(review.text), `review ${name} ${scheme}: the page doesn't name a variant`);
+ await page.screenshot({ path: path.join(shots, `review-${name}-${scheme}.png`), fullPage: false });
+ check(errors.length === 0, `${name} ${scheme}: no page errors ${errors.join("; ")}`);
+ await ctx.close();
+ }
+ }
+
+ // Rate every pair with the keyboard on a desktop: ← for the first half, → for the rest, one undo on the way.
+ const ctx = await browser.newContext(DESKTOP);
+ const page = await ctx.newPage();
+ await page.goto(url, { waitUntil: "load" });
+ await page.waitForSelector("#stage");
+ for (let i = 0; i < made.pairs; i++) {
+ await page.keyboard.press(i < made.pairs / 2 ? "ArrowLeft" : "ArrowRight");
+ await page.waitForTimeout(180);
+ if (i === 0) {
+ await page.keyboard.press("u");
+ await page.waitForTimeout(120);
+ await page.keyboard.press("ArrowLeft");
+ await page.waitForTimeout(180);
+ }
+ }
+ await page.waitForTimeout(400);
+ const done = await page.locator("#stage").innerText();
+ check(/All done/.test(done), `review: all ${made.pairs} pairs rated ("${done.split("\n")[0]}")`);
+ check(/Saved to the run folder/.test(await page.locator("#saved").innerText()), "review: ratings saved to the run folder");
+ const saved = JSON.parse(fs.readFileSync(path.join(runDir, "review", "ratings.json"), "utf8"));
+ check(saved.ratings.length === made.pairs, `review/ratings.json holds ${saved.ratings.length} of ${made.pairs} ratings`);
+ // A reload resumes where the ratings are.
+ await page.reload({ waitUntil: "load" });
+ await page.waitForTimeout(300);
+ check(/All done/.test(await page.locator("#stage").innerText()), "review: a reload keeps the ratings");
+ await ctx.close();
+
+ const summary = writeReport(runDir, resultsRoot);
+ check(summary.ratings.total === made.pairs, `summary: ${summary.ratings.total} ratings unblinded (${JSON.stringify(summary.ratings.pairs)})`);
+ check(loadRun(runDir).ratings.ratings.every((r) => ["left", "right", "same", "skip"].includes(r.choice)), "summary: ratings keep their choices");
+} finally {
+ await browser.close();
+ server.close();
+}
+
+console.log(`\nScreenshots: ${shots}`);
+if (failures.length) {
+ console.log(`${failures.length} check(s) failed`);
+ process.exit(1);
+}
diff --git a/tests/eval-harness.test.ts b/tests/eval-harness.test.ts
index 929c1527..94dc6327 100644
--- a/tests/eval-harness.test.ts
+++ b/tests/eval-harness.test.ts
@@ -239,7 +239,7 @@ describe("the runner on the demo provider", () => {
try {
const dry = await cli(["run", "--suite", "soul", "--engine", "cloud", "--looks", "v2-flash-editorial,v1-general", "--dry-run", "--json"]);
const plan = JSON.parse(dry.stdout);
- expect(plan).toMatchObject({ engine: "cloud", runnable: 6, skipped: 0, maxUsd: 5 });
+ expect(plan).toMatchObject({ engine: "cloud", total: 6, runnable: 6, skipped: 0, maxUsd: 5 });
expect(plan.estimateUsd).toBeGreaterThan(0);
const flash = plan.jobs.find((j: { case: string }) => j.case === "soul/v2-flash-editorial");
// On the cloud the civitai Hard Flash LoRA is left out (its link needs a token); fal's LoRA endpoint takes the HF one.