Merge branch 'main' into web-chat-composer

# Conflicts:
#	web/src/app.js
#	web/src/client.js
#	web/src/protocol.js
#	web/test/chat.test.mjs
#	web/test/repository.test.mjs
#	web/test/ui-smoke.mjs
This commit is contained in:
2026-10-19 07:33:49 +01:00
14 changed files with 1840 additions and 39 deletions
+87
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 };
@@ -309,3 +370,29 @@ test("nativeChatMessageId mirrors the Android id: msg_ + alphanumerics, capped",
assert.equal(nativeChatMessageId("a".repeat(300)).length, "msg_".length + 120);
assert.match(newChatOperationId(), /^web-chat-[a-z0-9]+-[a-z0-9]+$/);
});
test("subscribeChat sends exactly {type:'chat_subscribe',chat_subscribe:{session_id}}", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "chat_subscribe" });
await repo.subscribeChat("ses_eae413f50ffeLQDExlg8cYnscN");
assert.deepEqual(lastFrame(ws), {
type: "chat_subscribe",
chat_subscribe: { session_id: "ses_eae413f50ffeLQDExlg8cYnscN" },
});
});
test("subscribeChat rejects a blank session id without sending anything", async () => {
const { repo, ws } = connected();
await assert.rejects(() => repo.subscribeChat(" "), ProtocolError);
assert.equal(ws.sent.length, 0);
});
test("subscribeChat surfaces a server refusal as a ProtocolError", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "error", error: "unknown command: chat_subscribe" });
await assert.rejects(() => repo.subscribeChat("ses_1"), {
name: "ProtocolError",
message: "unknown command: chat_subscribe",
});
});