web: live run updates over a single app-wide watch (R10)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { PipelinesClient, ProtocolError } from "../src/client.js";
|
||||
import { PipelinesClient, ProtocolError, NotConnectedError } from "../src/client.js";
|
||||
import { PipelinesRepository, SHELL_OUTPUT_LIMIT, nativeChatMessageId, newChatOperationId } from "../src/repository.js";
|
||||
import { validateServerUrl } from "../src/serverUrl.js";
|
||||
|
||||
@@ -270,6 +270,43 @@ test("setRunTitle sends exactly {type:'set_run_title',run_id,title} and returns
|
||||
assert.deepEqual(detail, RUN_DETAIL);
|
||||
});
|
||||
|
||||
test("subscribeRuns sends exactly {type:'subscribe',workspace:''} with no run_ids", async () => {
|
||||
const { repo, ws } = connected();
|
||||
const id = repo.subscribeRuns();
|
||||
assert.match(id, /^web-\d+$/);
|
||||
assert.deepEqual(lastFrame(ws), { type: "subscribe", workspace: "" });
|
||||
});
|
||||
|
||||
test("subscribeRuns includes run_ids only when ids are given and sends the workspace verbatim", () => {
|
||||
const { repo, ws } = connected();
|
||||
repo.subscribeRuns("", [3, 4]);
|
||||
assert.deepEqual(lastFrame(ws), { type: "subscribe", workspace: "", run_ids: [3, 4] });
|
||||
repo.subscribeRuns("/tmp/ws", []);
|
||||
assert.deepEqual(lastFrame(ws), { type: "subscribe", workspace: "/tmp/ws" });
|
||||
});
|
||||
|
||||
test("subscribeRuns is send-only: it returns the id and never awaits a reply", () => {
|
||||
const { repo, ws } = connected();
|
||||
// No reply is scripted; a send-only call must not hang or reject.
|
||||
const id = repo.subscribeRuns();
|
||||
assert.equal(ws.sent.at(-1).id, id);
|
||||
});
|
||||
|
||||
test("unsubscribeRuns sends exactly {type:'unsubscribe'} and is send-only", () => {
|
||||
const { repo, ws } = connected();
|
||||
const id = repo.unsubscribeRuns();
|
||||
assert.match(id, /^web-\d+$/);
|
||||
assert.deepEqual(lastFrame(ws), { type: "unsubscribe" });
|
||||
});
|
||||
|
||||
test("the run watch commands are refused before connect", () => {
|
||||
FakeWebSocket.instances = [];
|
||||
const client = new PipelinesClient({ WebSocketImpl: FakeWebSocket });
|
||||
const repo = new PipelinesRepository(client);
|
||||
assert.throws(() => repo.subscribeRuns(), NotConnectedError);
|
||||
assert.throws(() => repo.unsubscribeRuns(), NotConnectedError);
|
||||
});
|
||||
|
||||
test("each run action rejects a server error envelope instead of returning a detail", async () => {
|
||||
const calls = [
|
||||
(repo) => () => repo.decideRun(440, { option: "approve" }),
|
||||
|
||||
Reference in New Issue
Block a user