web: live chat transcript over chat_event (C5)
This commit is contained in:
@@ -90,9 +90,11 @@ test("an error reply surfaces the server text as a ProtocolError", async () => {
|
||||
await assert.rejects(() => client.call({ type: "get_run" }), ProtocolError);
|
||||
});
|
||||
|
||||
test("an unsolicited envelope with no matching id is dropped, not misattributed", async () => {
|
||||
test("an unsolicited envelope is surfaced as a frame event and not misattributed", async () => {
|
||||
const { client, ws } = connectedClient();
|
||||
ws.reply = undefined;
|
||||
const frames = [];
|
||||
client.addEventListener("frame", (event) => frames.push(event.detail));
|
||||
|
||||
const pending = client.call({ type: "ping" });
|
||||
let settled = false;
|
||||
@@ -102,10 +104,29 @@ test("an unsolicited envelope with no matching id is dropped, not misattributed"
|
||||
ws.push({ type: "pipelines", pipelines: [] }); // no id
|
||||
await flush();
|
||||
assert.equal(settled, false);
|
||||
assert.deepEqual(frames, [{ type: "pipelines", pipelines: [] }]);
|
||||
|
||||
const frame = ws.sent.at(-1);
|
||||
ws.push({ id: frame.id, type: "pong" });
|
||||
assert.equal((await pending).type, "pong");
|
||||
// A matched reply is not also broadcast as an unsolicited frame.
|
||||
assert.equal(frames.length, 1);
|
||||
});
|
||||
|
||||
test("a server-pushed chat_event frame reaches a frame listener", async () => {
|
||||
const { client, ws } = connectedClient();
|
||||
const frames = [];
|
||||
client.addEventListener("frame", (event) => frames.push(event.detail));
|
||||
|
||||
ws.push({
|
||||
type: "chat_event",
|
||||
chat_event: { session_id: "ses_1", message_id: "a1", kind: "text", delta: "hi" },
|
||||
});
|
||||
await flush();
|
||||
|
||||
assert.equal(frames.length, 1);
|
||||
assert.equal(frames[0].type, "chat_event");
|
||||
assert.equal(frames[0].chat_event.session_id, "ses_1");
|
||||
});
|
||||
|
||||
test("a malformed frame is ignored and does not reject a pending call", async () => {
|
||||
|
||||
Reference in New Issue
Block a user