From edb3d89959e470204d7646cf737ca8629f2cba39 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:29:47 +0000 Subject: [PATCH] Expand runtime tests for token encoding and cwd normalization Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 90e78471d3..0466820fc3 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -154,6 +154,51 @@ describe("runtimeApiServer", () => { client.socket.close(); }); + it("encodes auth token query parameter in runtime websocket URL", async () => { + const server = await startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + authToken: "token with spaces/?&", + }); + servers.push(server); + + const wsUrl = new URL(server.wsUrl); + expect(wsUrl.searchParams.get("token")).toBe("token with spaces/?&"); + + const client = await connectClient(server.wsUrl); + const hello = await client.nextMessage(); + expect(hello.type).toBe("hello"); + client.socket.close(); + }); + + it("normalizes relative launch cwd in app.health response", async () => { + const server = await startRuntimeApiServer({ + port: 0, + launchCwd: ".", + }); + servers.push(server); + + const client = await connectClient(server.wsUrl); + await client.nextMessage(); + + const response = await sendRequest( + client.socket, + client.nextMessage, + "health-relative-cwd", + "app.health", + ); + expect(response.ok).toBe(true); + if (!response.ok) { + throw new Error("Expected health response to succeed."); + } + + const payload = response.result as { + launchCwd: string; + }; + expect(payload.launchCwd).toBe(process.cwd()); + client.socket.close(); + }); + it("responds to todos.list over websocket RPC", async () => { const server = await startRuntimeApiServer({ port: 0,