From e16f93af0cc24d9996e8830d68ca9bf482f4a255 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 21:38:38 +0000 Subject: [PATCH] fix: stabilize ci test typings and mocks --- .../pi-tools.read.workspace-root-guard.test.ts | 14 ++++++++------ src/infra/outbound/outbound-send-service.test.ts | 9 ++++----- src/node-host/invoke-system-run.test.ts | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/agents/pi-tools.read.workspace-root-guard.test.ts b/src/agents/pi-tools.read.workspace-root-guard.test.ts index b94e04b63eb..0e6f76109f6 100644 --- a/src/agents/pi-tools.read.workspace-root-guard.test.ts +++ b/src/agents/pi-tools.read.workspace-root-guard.test.ts @@ -3,10 +3,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { wrapToolWorkspaceRootGuardWithOptions } from "./pi-tools.read.js"; import type { AnyAgentTool } from "./pi-tools.types.js"; -const assertSandboxPath = vi.fn(async () => ({ resolved: "/tmp/root", relative: "" })); +const mocks = vi.hoisted(() => ({ + assertSandboxPath: vi.fn(async () => ({ resolved: "/tmp/root", relative: "" })), +})); vi.mock("./sandbox-paths.js", () => ({ - assertSandboxPath: (...args: unknown[]) => assertSandboxPath(...args), + assertSandboxPath: mocks.assertSandboxPath, })); function createToolHarness() { @@ -26,7 +28,7 @@ describe("wrapToolWorkspaceRootGuardWithOptions", () => { const root = "/tmp/root"; beforeEach(() => { - assertSandboxPath.mockClear(); + mocks.assertSandboxPath.mockClear(); }); it("maps container workspace paths to host workspace root", async () => { @@ -37,7 +39,7 @@ describe("wrapToolWorkspaceRootGuardWithOptions", () => { await wrapped.execute("tc1", { path: "/workspace/docs/readme.md" }); - expect(assertSandboxPath).toHaveBeenCalledWith({ + expect(mocks.assertSandboxPath).toHaveBeenCalledWith({ filePath: path.resolve(root, "docs", "readme.md"), cwd: root, root, @@ -52,7 +54,7 @@ describe("wrapToolWorkspaceRootGuardWithOptions", () => { await wrapped.execute("tc2", { path: "file:///workspace/docs/readme.md" }); - expect(assertSandboxPath).toHaveBeenCalledWith({ + expect(mocks.assertSandboxPath).toHaveBeenCalledWith({ filePath: path.resolve(root, "docs", "readme.md"), cwd: root, root, @@ -67,7 +69,7 @@ describe("wrapToolWorkspaceRootGuardWithOptions", () => { await wrapped.execute("tc3", { path: "/workspace-two/secret.txt" }); - expect(assertSandboxPath).toHaveBeenCalledWith({ + expect(mocks.assertSandboxPath).toHaveBeenCalledWith({ filePath: "/workspace-two/secret.txt", cwd: root, root, diff --git a/src/infra/outbound/outbound-send-service.test.ts b/src/infra/outbound/outbound-send-service.test.ts index e5a75fc8bfb..edc7823b0ec 100644 --- a/src/infra/outbound/outbound-send-service.test.ts +++ b/src/infra/outbound/outbound-send-service.test.ts @@ -8,17 +8,16 @@ const mocks = vi.hoisted(() => ({ })); vi.mock("../../channels/plugins/message-actions.js", () => ({ - dispatchChannelMessageAction: (...args: unknown[]) => mocks.dispatchChannelMessageAction(...args), + dispatchChannelMessageAction: mocks.dispatchChannelMessageAction, })); vi.mock("./message.js", () => ({ - sendMessage: (...args: unknown[]) => mocks.sendMessage(...args), - sendPoll: (...args: unknown[]) => mocks.sendPoll(...args), + sendMessage: mocks.sendMessage, + sendPoll: mocks.sendPoll, })); vi.mock("../../media/local-roots.js", () => ({ - getAgentScopedMediaLocalRoots: (...args: unknown[]) => - mocks.getAgentScopedMediaLocalRoots(...args), + getAgentScopedMediaLocalRoots: mocks.getAgentScopedMediaLocalRoots, })); import { executePollAction, executeSendAction } from "./outbound-send-service.js"; diff --git a/src/node-host/invoke-system-run.test.ts b/src/node-host/invoke-system-run.test.ts index 5a052b28b13..a3d20c792f3 100644 --- a/src/node-host/invoke-system-run.test.ts +++ b/src/node-host/invoke-system-run.test.ts @@ -87,7 +87,6 @@ describe("handleSystemRunInvoke mac app exec host routing", () => { stdout: "app-ok", stderr: "", timedOut: false, - truncated: false, exitCode: 0, error: null, },