Cover Uint8Array websocket request decoding in runtime tests

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 00:32:20 +00:00
1 parent 61ddbacb77
commit b688456810
1 file changed
+34
+34
View File
@@ -501,6 +501,40 @@ describe("runtimeApiServer", () => {
client.socket.close();
});
it("accepts uint8array-encoded websocket request payloads", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const client = await connectClient(server.wsUrl);
await client.nextMessage();
const encoded = new TextEncoder().encode(
JSON.stringify({
type: "request",
id: "uint8array-todos-1",
method: "todos.list",
}),
);
client.socket.send(encoded);
const response = await withTimeout(
(async (): Promise<WsResponseMessage> => {
const message = await client.nextMessage();
if (message.type === "response" && message.id === "uint8array-todos-1") {
return message;
}
return Promise.reject(new Error("Expected matching todos response."));
})(),
);
expect(response.ok).toBe(true);
expect(Array.isArray(response.result)).toBe(true);
client.socket.close();
});
it("replaces an existing websocket client with a new one", async () => {
const server = await startRuntimeApiServer({
port: 0,