fix: support multiple keys per action and harden runtime/parsing
This commit is contained in:
@@ -64,3 +64,30 @@ test("decodeEvent returns null for unrelated or malformed events", () => {
|
||||
assert.equal(decodeEvent({ event: "message", data: JSON.stringify({ type: "logData", data: "{}" }) }), null);
|
||||
assert.equal(decodeEvent({ event: "message", data: "not json" }), null);
|
||||
});
|
||||
|
||||
test("decodeEvent returns null when modelStatus data is not an array", () => {
|
||||
const msg: SseMessage = {
|
||||
event: "message",
|
||||
data: JSON.stringify({
|
||||
type: "modelStatus",
|
||||
data: JSON.stringify({ id: "DeepSeek-V4-Flash-0731", state: "ready" }),
|
||||
}),
|
||||
};
|
||||
assert.equal(decodeEvent(msg), null);
|
||||
});
|
||||
|
||||
test("decodeEvent handles inflight with a non-array requests field and no request field", () => {
|
||||
const msg: SseMessage = {
|
||||
event: "message",
|
||||
data: JSON.stringify({
|
||||
type: "inflight",
|
||||
data: JSON.stringify({ operation: "snapshot", requests: "oops" }),
|
||||
}),
|
||||
};
|
||||
const ev = decodeEvent(msg);
|
||||
assert.ok(ev && ev.type === "inflight");
|
||||
if (ev && ev.type === "inflight") {
|
||||
assert.equal(ev.operation, "snapshot");
|
||||
assert.deepEqual(ev.requests, []);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user