Merge branch 'main' into web-chat-live
This commit is contained in:
@@ -105,6 +105,67 @@ test("validate throws when the reply has no graph", async () => {
|
||||
await assert.rejects(() => repo.validate("empty"), ProtocolError);
|
||||
});
|
||||
|
||||
/** The new pipeline detail a `submitted` reply carries in these tests. */
|
||||
const SUBMITTED_DETAIL = { id: 91, name: "Release helper", version: 1 };
|
||||
|
||||
test("submit sends exactly {type:'submit',name,source,create_only:true} and returns the detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
const detail = await repo.submit("Release helper", "the source");
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "submit",
|
||||
name: "Release helper",
|
||||
source: "the source",
|
||||
create_only: true,
|
||||
});
|
||||
assert.deepEqual(detail, SUBMITTED_DETAIL);
|
||||
});
|
||||
|
||||
test("submit trims the name before sending it", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
await repo.submit(" Release helper ", "the source");
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "submit",
|
||||
name: "Release helper",
|
||||
source: "the source",
|
||||
create_only: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("submit refuses a blank name without sending anything", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = () => ({ id: "unused", type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
await assert.rejects(() => repo.submit(" ", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: "Enter a pipeline name.",
|
||||
});
|
||||
assert.equal(ws.sent.length, 0);
|
||||
});
|
||||
|
||||
test("submit rejects a server error envelope with the server's own text", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "error", error: 'a pipeline named "Release helper" already exists' });
|
||||
|
||||
await assert.rejects(() => repo.submit("Release helper", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: 'a pipeline named "Release helper" already exists',
|
||||
});
|
||||
});
|
||||
|
||||
test("submit throws when the reply has no pipeline detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", name: "Release helper" });
|
||||
|
||||
await assert.rejects(() => repo.submit("Release helper", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: "The server returned no pipeline detail.",
|
||||
});
|
||||
});
|
||||
|
||||
test("search sends exactly {type:'search',search:{query,kind:'',limit:0}} and returns search_results", async () => {
|
||||
const { repo, ws } = connected();
|
||||
const payload = { query: "release", results: [{ kind: "run" }], cap: 50, scanned_steps: 3 };
|
||||
|
||||
@@ -4,6 +4,18 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
CREATE_CANCEL,
|
||||
CREATE_CLOSE,
|
||||
CREATE_CONFIRM,
|
||||
CREATE_NAME_LABEL,
|
||||
CREATE_NOTE,
|
||||
CREATE_SENDING,
|
||||
createConfirmLabel,
|
||||
createDismissLabel,
|
||||
createFormTitle,
|
||||
createFormValid,
|
||||
createSuccessMessage,
|
||||
createdPipelineName,
|
||||
effectiveStageType,
|
||||
stageCountText,
|
||||
templateCard,
|
||||
@@ -85,3 +97,55 @@ test("templateGraphNote picks the unparsed or parsed note", () => {
|
||||
assert.equal(templateGraphNote(null), TEMPLATE_UNPARSED_GRAPH_NOTE);
|
||||
assert.equal(templateGraphNote({ stages: [] }), TEMPLATE_GRAPH_NOTE);
|
||||
});
|
||||
|
||||
test("createFormTitle names the template, a blank name falling back to the key", () => {
|
||||
assert.equal(createFormTitle({ key: "task", name: "Complete a task" }), "Create from Complete a task");
|
||||
assert.equal(createFormTitle({ key: "task", name: "" }), "Create from task");
|
||||
assert.equal(createFormTitle({ key: "task", name: " " }), "Create from task");
|
||||
});
|
||||
|
||||
test("createFormValid rejects blank/whitespace, sending and an existing creation", () => {
|
||||
assert.equal(createFormValid("a pipeline"), true);
|
||||
assert.equal(createFormValid(""), false);
|
||||
assert.equal(createFormValid(" "), false);
|
||||
assert.equal(createFormValid(null), false);
|
||||
assert.equal(createFormValid("a pipeline", { sending: true }), false);
|
||||
assert.equal(createFormValid("a pipeline", { created: "a pipeline" }), false);
|
||||
assert.equal(createFormValid("a pipeline", { created: "" }), false);
|
||||
// Defaults: a non-blank name with no options is valid.
|
||||
assert.equal(createFormValid("a pipeline", {}), true);
|
||||
});
|
||||
|
||||
test("createConfirmLabel switches Create / Creating…", () => {
|
||||
assert.equal(createConfirmLabel(false), CREATE_CONFIRM);
|
||||
assert.equal(createConfirmLabel(true), CREATE_SENDING);
|
||||
});
|
||||
|
||||
test("createDismissLabel is Cancel until a creation, then Close", () => {
|
||||
assert.equal(createDismissLabel(null), CREATE_CANCEL);
|
||||
assert.equal(createDismissLabel(undefined), CREATE_CANCEL);
|
||||
assert.equal(createDismissLabel("Made"), CREATE_CLOSE);
|
||||
});
|
||||
|
||||
test("createSuccessMessage is the exact success line", () => {
|
||||
assert.equal(createSuccessMessage("Release helper"), 'Created "Release helper". It is in the Pipelines list.');
|
||||
});
|
||||
|
||||
test("createdPipelineName prefers the returned name, else the trimmed submitted name", () => {
|
||||
assert.equal(createdPipelineName({ name: "Server name" }, "Typed name"), "Server name");
|
||||
assert.equal(createdPipelineName({ name: " " }, " Typed name "), "Typed name");
|
||||
assert.equal(createdPipelineName(null, " Typed name "), "Typed name");
|
||||
assert.equal(createdPipelineName({}, ""), "");
|
||||
});
|
||||
|
||||
test("the create dialog's fixed wording is the app's", () => {
|
||||
assert.equal(CREATE_NAME_LABEL, "New pipeline name (required)");
|
||||
assert.equal(
|
||||
CREATE_NOTE,
|
||||
"Creates a new draft pipeline on the server from this template's source; it is not run.",
|
||||
);
|
||||
assert.equal(CREATE_CONFIRM, "Create");
|
||||
assert.equal(CREATE_SENDING, "Creating…");
|
||||
assert.equal(CREATE_CANCEL, "Cancel");
|
||||
assert.equal(CREATE_CLOSE, "Close");
|
||||
});
|
||||
|
||||
+107
-2
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user