Merge branch 'main' into web-chat-live

This commit is contained in:
2026-10-19 07:01:39 +01:00
9 changed files with 583 additions and 3 deletions
+107 -2
View File
@@ -2,11 +2,16 @@
// 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]
// node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR] [--scratch]
//
// 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.
//
// `--scratch` drives ONLY the P5 create-from-template flow (captures 51/52/53)
// against a scratch server and skips the live suite, which needs the operator's
// real runs and chat session. The default run never sends a `submit`: the live
// server's pipeline list is never mutated.
import { spawn } from "node:child_process";
import { mkdir, rm } from "node:fs/promises";
import net from "node:net";
@@ -38,6 +43,9 @@ const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET
const out = resolve(
flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")),
);
// Scratch mode: only the P5 create-from-template flow runs, against a throwaway
// server with its own database. The default (live) run sends no submit.
const scratch = process.argv.includes("--scratch");
// The page must connect through its own proxy (the server rejects a cross-origin
// upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL
@@ -109,6 +117,87 @@ async function openRunDetail(runId) {
}
}
// --- P5: create a pipeline from a template (scratch server only) -----------
// The scratch server has no real runs and no live chat, so this is the whole
// point of a `--scratch` run. It opens a template, opens the create action,
// captures the blank/disabled dialog, fills a unique name, creates it, captures
// the success dialog and then the Pipelines list holding the new row. It sends a
// real validate + submit, but only ever against the scratch database.
async function runScratchCreate() {
step("P5: creating a pipeline from a template (scratch server)");
await ensureConnected();
await page.clickText("nav.tabs button.tab", "Templates");
await page.waitForSelector(".cards button.card", { timeout: 25000 });
await page.click(".cards button.card");
await page.waitForSelector(".detail .tabstrip", { timeout: 25000 });
await page.waitForSelector(".template-create-open", { timeout: 15000 });
const actionLabel = await text(".template-create-open");
if (actionLabel !== "Create pipeline from this template") {
throw new Error(`create action label: ${actionLabel}`);
}
await page.click(".template-create-open");
await page.waitForSelector(".template-create-dialog", { timeout: 15000 });
const blank = await page.evaluate(`(() => ({
title: document.querySelector(".template-create-title")?.textContent ?? "",
label: document.querySelector(".template-create-label")?.textContent ?? "",
note: document.querySelector(".template-create-note")?.textContent ?? "",
confirm: document.querySelector(".template-create-confirm")?.textContent ?? "",
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
confirmDisabled: document.querySelector(".template-create-confirm")?.disabled ?? null,
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
}))()`);
if (!blank.title.startsWith("Create from ")) throw new Error(`create dialog title: ${blank.title}`);
if (blank.label !== "New pipeline name (required)") throw new Error(`create field label: ${blank.label}`);
if (blank.note !== "Creates a new draft pipeline on the server from this template's source; it is not run.") {
throw new Error(`create note: ${blank.note}`);
}
if (blank.confirm !== "Create") throw new Error(`create confirm: ${blank.confirm}`);
if (blank.dismiss !== "Cancel") throw new Error(`create dismiss: ${blank.dismiss}`);
if (blank.confirmDisabled !== true) throw new Error("Create was enabled with a blank name");
if (blank.fieldDisabled !== false) throw new Error("the name field started disabled");
console.log(` blank dialog: "${blank.title}" — Create disabled, field enabled, Cancel offered`);
await shot("51-template-create-dialog.png");
const newName = `Scratch create ${Date.now()}`;
await page.fill(".template-create-name", newName);
await eventually(
() => page.evaluate(`!document.querySelector(".template-create-confirm")?.disabled`),
{ timeout: 5000, what: "Create to enable after a non-blank name" },
);
await page.click(".template-create-confirm");
await page.waitForText(`Created "${newName}". It is in the Pipelines list.`, { timeout: 25000 });
const success = await page.evaluate(`(() => ({
text: document.querySelector(".template-create-success")?.textContent ?? "",
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
}))()`);
if (success.text !== `Created "${newName}". It is in the Pipelines list.`) {
throw new Error(`create success line: ${success.text}`);
}
if (success.dismiss !== "Close") throw new Error(`dismiss after success: ${success.dismiss}`);
if (success.fieldDisabled !== true) throw new Error("the name field was not locked after a success");
console.log(` created: ${JSON.stringify(success.text)}; dismiss now reads ${success.dismiss}`);
await shot("52-template-created.png");
// Cancel now reads Close: dismissing it leaves the Templates view, then the
// refreshed Pipelines list must hold the new row.
await page.click(".template-create-cancel");
await eventually(() => page.evaluate(`!document.querySelector(".template-create-dialog")`), {
timeout: 5000,
what: "the create dialog to close",
});
await page.clickText("nav.tabs button.tab", "Pipelines");
await page.waitForText(newName, { timeout: 25000 });
const listed = await page.evaluate(
`document.querySelector("#pipelineRows")?.textContent.includes(${JSON.stringify(newName)}) ?? false`,
);
if (!listed) throw new Error("the created pipeline is not in the Pipelines list");
console.log(" the created pipeline appears in the scratch server's Pipelines list");
await shot("53-pipeline-created-list.png");
}
// --- Omni-search (S1/S2) ---------------------------------------------------
// The page's own search UI drives every one of the helpers below; nothing is
// stubbed. `searchTargets` opens the panel (if it is not already open), types the
@@ -301,8 +390,23 @@ try {
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 });
// A scratch server starts with no pipelines at all, so the pipeline row that
// proves the live list rendered is skipped there; the connection banner is
// still awaited either way.
if (!scratch) await page.waitForSelector(".row-title", { timeout: 25000 });
await page.waitForText("connected", { timeout: 25000 });
// Scratch mode runs only the P5 create flow above and skips the live suite,
// which needs the operator's real pipelines, runs and chat session. The guard
// below wraps the live steps without reindenting them, keeping this diff
// reviewable; both branches share this file's cleanup in the `finally`.
if (scratch) {
await runScratchCreate();
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
}
if (!scratch) {
const pipelineCount = await page.evaluate(
`document.querySelectorAll("#pipelineRows button.row").length`,
);
@@ -2908,6 +3012,7 @@ try {
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
}
} catch (error) {
failed = true;
console.error(`\nUI SMOKE FAIL: ${error.message}`);