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
+61
View File
@@ -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 };