web: live chat transcript over chat_event (C5)
This commit is contained in:
@@ -231,3 +231,29 @@ test("a run action throws when the reply has no run detail", async () => {
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run" });
|
||||
await assert.rejects(() => repo.cancelRun(7), ProtocolError);
|
||||
});
|
||||
|
||||
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",
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user