test: fix exec approval and pty fallback e2e flows

This commit is contained in:
Peter Steinberger
2026-02-13 19:19:15 +00:00
parent 34eb14d24f
commit 7d1be585de
2 changed files with 16 additions and 24 deletions

View File

@@ -1,22 +1,21 @@
import { afterEach, expect, test, vi } from "vitest";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool, setPtyModuleLoaderForTests } from "./bash-tools.exec";
import { createExecTool } from "./bash-tools.exec";
vi.mock("@lydell/node-pty", () => ({
spawn: () => {
const err = new Error("spawn EBADF");
(err as NodeJS.ErrnoException).code = "EBADF";
throw err;
},
}));
afterEach(() => {
resetProcessRegistryForTests();
setPtyModuleLoaderForTests();
vi.clearAllMocks();
});
test("exec falls back when PTY spawn fails", async () => {
setPtyModuleLoaderForTests(async () => ({
spawn: () => {
const err = new Error("spawn EBADF");
(err as NodeJS.ErrnoException).code = "EBADF";
throw err;
},
}));
const tool = createExecTool({ allowBackground: false });
const result = await tool.execute("toolcall", {
command: "printf ok",