web: live run updates over a single app-wide watch (R10)

This commit is contained in:
2026-10-19 14:22:53 +01:00
parent 2fe63012f9
commit 21a6ee3c4d
13 changed files with 1580 additions and 90 deletions
+45
View File
@@ -129,6 +129,51 @@ test("a server-pushed chat_event frame reaches a frame listener", async () => {
assert.equal(frames[0].chat_event.session_id, "ses_1");
});
test("sendOnly sends a frame, returns its id and never waits for a reply", () => {
const { client, ws } = connectedClient();
const frames = [];
client.addEventListener("frame", (event) => frames.push(event.detail));
// No reply is scripted: a send-only frame must not hang the caller.
const id = client.sendOnly({ type: "subscribe", workspace: "" });
assert.match(id, /^web-\d+$/);
assert.deepEqual(ws.sent, [{ type: "subscribe", workspace: "", id }]);
// A server that does ack (or refuse) still reaches the app as an unsolicited
// frame carrying that id, not as a resolved request.
ws.push({ id, type: "subscribe" });
assert.equal(frames.length, 1);
assert.equal(frames[0].type, "subscribe");
});
test("sendOnly before connect is rejected as not connected", () => {
const client = freshClient();
assert.throws(() => client.sendOnly({ type: "subscribe" }), NotConnectedError);
});
test("back-to-back sendOnly frames keep their order on the wire", () => {
const { client, ws } = connectedClient();
client.sendOnly({ type: "unsubscribe" });
client.sendOnly({ type: "subscribe", workspace: "" });
assert.deepEqual(
ws.sent.map((frame) => frame.type),
["unsubscribe", "subscribe"],
);
});
test("a server-pushed run_event frame reaches a frame listener", async () => {
const { client, ws } = connectedClient();
const frames = [];
client.addEventListener("frame", (event) => frames.push(event.detail));
ws.push({ type: "run_event", run_event: { run_id: 7, status: "running" } });
await flush();
assert.equal(frames.length, 1);
assert.equal(frames[0].type, "run_event");
assert.equal(frames[0].run_event.run_id, 7);
});
test("a malformed frame is ignored and does not reject a pending call", async () => {
const { client, ws } = connectedClient();
const pending = client.call({ type: "ping" });