13404b2a2b
Close three rows of the browser client's parity checklist, matching the Android
app's wording and behaviour:
- P1 pipeline list: name; "id {id} · v{version} · {N stages}"; "updated d MMM
HH:mm"; a last-run line joined from list_runs (status chip plus
"{ago} · {duration} · run {id}", or "no runs recorded").
- P2 filter + sort: Filter menu (name contains, Runs Any/Has runs/No runs, the
seven server run statuses, Clear filters) and Sort menu (Server order default,
Name A-Z/Z-A, Most recent run, Fewest/Most stages, Reset). Server order is
preserved.
- P3 pipeline detail: Summary/Graph/Source tabs; Summary shows the content hash
(monospace), latest version, created/updated and a collapsed-by-default
Versions section. The Graph tab carries the browser guidance note only; the
rendered graph stays P6.
New src/pipelines.js holds the pure, DOM-free helpers (timestamps, durations,
last-run join, comparators, filter, empty states); app.js is wiring only.
web/test/pipelines.test.mjs covers the helpers; web/test/ui-smoke.mjs captures
the list, controls and detail against the live server. All server strings are
set with textContent.
194 lines
8.0 KiB
JavaScript
194 lines
8.0 KiB
JavaScript
// Live browser check for the web client: serve the page, open it in headless
|
|
// Chrome, connect to a running Pipelines server through the page's own proxy,
|
|
// and capture what actually rendered.
|
|
//
|
|
// node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR]
|
|
//
|
|
// This is the UI evidence a review stage produces: real screenshots of the
|
|
// rendered client, not a claim. It needs a running Pipelines server (the live one
|
|
// or a scratch one) and the installed Chrome; it has no npm dependencies.
|
|
import { spawn } from "node:child_process";
|
|
import { mkdir, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { eventually, launchChrome } from "./browser.mjs";
|
|
|
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
|
function flag(argv, name, fallback) {
|
|
const i = argv.indexOf(name);
|
|
return i !== -1 && argv[i + 1] ? argv[i + 1] : fallback;
|
|
}
|
|
|
|
const port = Number(flag(process.argv, "--port", process.env.WEB_UI_PORT ?? 8091));
|
|
const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET ?? "127.0.0.1:8080");
|
|
const out = resolve(
|
|
flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")),
|
|
);
|
|
|
|
const shots = [];
|
|
let serve = null;
|
|
let browser = null;
|
|
let page = null;
|
|
let failed = false;
|
|
|
|
function step(label) {
|
|
console.log(`• ${label}`);
|
|
}
|
|
|
|
async function shot(name) {
|
|
const path = `${out}/${name}`;
|
|
shots.push(await page.screenshot(path));
|
|
console.log(` capture ${path}`);
|
|
return path;
|
|
}
|
|
|
|
const text = (selector) =>
|
|
page.evaluate(`document.querySelector(${JSON.stringify(selector)})?.textContent ?? ""`);
|
|
|
|
try {
|
|
await mkdir(out, { recursive: true });
|
|
|
|
step(`serving web/ on 127.0.0.1:${port} (proxy /connect -> ${pipelines})`);
|
|
serve = spawn(process.execPath, ["serve.mjs", "--port", String(port), "--pipelines", pipelines], {
|
|
cwd: ROOT,
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
let serveLog = "";
|
|
serve.stdout.on("data", (chunk) => (serveLog += chunk.toString()));
|
|
serve.stderr.on("data", (chunk) => (serveLog += chunk.toString()));
|
|
await eventually(
|
|
async () => {
|
|
if (serve.exitCode != null) throw new Error(`serve.mjs exited: ${serveLog.trim().slice(-300)}`);
|
|
const res = await fetch(`http://127.0.0.1:${port}/`).catch(() => null);
|
|
return res?.ok;
|
|
},
|
|
{ what: "the page to be served" },
|
|
);
|
|
|
|
step("launching headless Chrome");
|
|
browser = await launchChrome({ width: 1440, height: 900 });
|
|
page = await browser.openPage(`http://127.0.0.1:${port}/`);
|
|
|
|
step("connecting the page to the server through its own proxy");
|
|
await page.fill("#url", `ws://127.0.0.1:${port}/connect`);
|
|
await page.click("#connectBtn");
|
|
await page.waitForSelector(".row-title", { timeout: 25000 });
|
|
await page.waitForText("connected", { timeout: 25000 });
|
|
const pipelineCount = await page.evaluate(
|
|
`document.querySelectorAll("#pipelineRows button.row").length`,
|
|
);
|
|
if (!pipelineCount) throw new Error("connected but no pipelines rendered");
|
|
console.log(` pipelines rendered: ${pipelineCount}`);
|
|
|
|
// 1. The list with its filter menu open: the name field, the Runs section, the
|
|
// Last run status multi-select and the Clear filters reset (P1 + P2).
|
|
step("capturing the pipeline list with the filter menu open");
|
|
await page.click("#filterToggle");
|
|
await page.waitForSelector(".filter-panel");
|
|
await shot("01-pipelines-controls.png");
|
|
|
|
// 2. The sort menu, and exercising it changes the ordering (P2).
|
|
step("capturing and exercising the sort menu");
|
|
await page.click("#sortToggle");
|
|
await page.waitForSelector(".sort-panel");
|
|
await shot("02-pipelines-sort.png");
|
|
await page.clickText(".sort-panel .sort-option", "Name A\u2013Z");
|
|
const sorted = await text("#sortToggle");
|
|
if (!sorted.includes("Name A\u2013Z")) throw new Error(`sort did not apply: ${sorted}`);
|
|
await page.click("#sortToggle");
|
|
await page.waitForSelector(".sort-panel");
|
|
await page.clickText(".sort-panel button", "Reset");
|
|
const reset = await text("#sortToggle");
|
|
if (!reset.includes("Server order")) throw new Error(`sort reset failed: ${reset}`);
|
|
|
|
// 3. The name facet narrows live; an unmatched name shows the name-only empty state.
|
|
step("narrowing by name and capturing the name-only empty state");
|
|
await page.click("#filterToggle");
|
|
await page.waitForSelector(".filter-panel");
|
|
await page.fill("#pipelineNameFilter", "Android");
|
|
const narrowed = await page.evaluate(
|
|
`document.querySelectorAll("#pipelineRows button.row").length`,
|
|
);
|
|
if (!narrowed || narrowed >= pipelineCount) {
|
|
throw new Error(`name filter did not narrow (${narrowed} of ${pipelineCount})`);
|
|
}
|
|
console.log(` name filter narrowed ${pipelineCount} -> ${narrowed}`);
|
|
await page.fill("#pipelineNameFilter", "zzz-no-such-pipeline");
|
|
await page.waitForText('No pipelines match "zzz-no-such-pipeline".');
|
|
await shot("03-pipelines-empty-name.png");
|
|
await page.click(".empty button");
|
|
await page.waitForSelector("#pipelineRows button.row");
|
|
|
|
// 4. A run facet with no matches shows the general empty state and a reset.
|
|
step("capturing the run-facet empty state");
|
|
await page.click("#status-interrupted");
|
|
await page.waitForText("No pipelines match the current filters.");
|
|
await shot("04-pipelines-empty-filters.png");
|
|
await page.click(".empty button");
|
|
await page.waitForSelector("#pipelineRows button.row");
|
|
await page.click("#filterToggle");
|
|
|
|
// 5. Pipeline detail: Summary (name, subtitle, content hash, created/updated).
|
|
step("opening a pipeline detail (Summary)");
|
|
await page.click("#pipelineRows button.row");
|
|
await page.waitForSelector(".detail h2");
|
|
await page.waitForSelector(".monospace");
|
|
await page.evaluate(`document.querySelector(".detail")?.scrollIntoView({ block: "start" })`);
|
|
await shot("05-pipeline-summary.png");
|
|
|
|
// 6. The Versions section is collapsed by default; expanding shows its rows.
|
|
step("expanding the Versions section");
|
|
await page.click(".section-toggle");
|
|
await page.waitForSelector(".versions-list");
|
|
await page.evaluate(`document.querySelector(".versions-list")?.scrollIntoView({ block: "start" })`);
|
|
await shot("06-pipeline-summary-versions.png");
|
|
|
|
// 7. Source tab: the rendered pipeline source in a monospace block.
|
|
step("opening the Source tab");
|
|
await page.clickText(".detail-tabs button", "Source");
|
|
await page.waitForSelector(".source-code");
|
|
await page.evaluate(`document.querySelector(".detail")?.scrollIntoView({ block: "start" })`);
|
|
await shot("07-pipeline-source.png");
|
|
|
|
// 8. Graph tab: the guidance note only; the rendered graph is P6.
|
|
step("opening the Graph tab (guidance note only)");
|
|
await page.clickText(".detail-tabs button", "Graph");
|
|
await page.waitForSelector(".graph-note");
|
|
await shot("08-pipeline-graph.png");
|
|
|
|
// 9. Runs regression: the pre-existing run list + detail still work.
|
|
step("switching to Runs and opening a run detail");
|
|
await page.clickText("nav.tabs button.tab", "Runs");
|
|
await page.waitForSelector("#content .list button.row", { timeout: 25000 });
|
|
await page.click("#content .list button.row");
|
|
await page.waitForSelector(".detail h2", { timeout: 25000 });
|
|
await shot("09-run-detail.png");
|
|
|
|
console.log("\nUI SMOKE PASS");
|
|
for (const shot of shots) console.log(` ${shot}`);
|
|
} catch (error) {
|
|
failed = true;
|
|
console.error(`\nUI SMOKE FAIL: ${error.message}`);
|
|
if (page) {
|
|
try {
|
|
shots.push(await page.screenshot(`${out}/failure.png`));
|
|
console.error(` failure capture: ${shots.at(-1)}`);
|
|
console.error((await page.text()).split("\n").slice(0, 25).join("\n"));
|
|
} catch {
|
|
// the page may be gone; the error above is the real signal
|
|
}
|
|
}
|
|
} finally {
|
|
await page?.close().catch(() => {});
|
|
await browser?.close().catch(() => {});
|
|
serve?.kill("SIGTERM");
|
|
await eventually(async () => serve?.exitCode != null, { timeout: 5000, what: "serve exit" }).catch(
|
|
() => {},
|
|
);
|
|
if (!failed) await rm(`${out}/failure.png`, { force: true }).catch(() => {});
|
|
}
|
|
|
|
process.exit(failed ? 1 : 0);
|