Cover terminal cwd file-path validation error

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 00:58:13 +00:00
1 parent e018d55032
commit 62bdc914e8
1 file changed
+36
+36
View File
@@ -1,3 +1,5 @@
import { mkdtempSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import { createServer as createNetServer } from "node:net";
import { afterEach, describe, expect, it } from "vitest";
@@ -1243,6 +1245,40 @@ describe("runtimeApiServer", () => {
client.socket.close();
});
it("returns structured errors when terminal cwd is not a directory", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const client = await connectClient(server.wsUrl);
await client.nextMessage();
const tempDir = mkdtempSync(path.join(os.tmpdir(), "t3-terminal-file-cwd-"));
const fileCwd = path.join(tempDir, "file.txt");
writeFileSync(fileCwd, "not-a-dir", "utf8");
const response = await sendRequest(
client.socket,
client.nextMessage,
"terminal-file-cwd-1",
"terminal.run",
{
command: "pwd",
cwd: fileCwd,
},
);
expect(response.ok).toBe(false);
if (response.ok) {
throw new Error("Expected terminal file cwd response to fail.");
}
expect(response.error?.code).toBe("request_failed");
expect(response.error?.message).toContain("Working directory is not a directory");
client.socket.close();
});
it("returns non-zero terminal exit codes without request failure", async () => {
const server = await startRuntimeApiServer({
port: 0,