From b688456810c620aeb395c082956cce995211bcf9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 00:32:20 +0000 Subject: [PATCH] Cover Uint8Array websocket request decoding in runtime tests Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 0c4cd25588..98bcdf68c4 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -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 => { + 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,