Skip to content

Commit 81d634b

Browse files
authored
test: speed CLI capture suites (#107993)
1 parent d61250e commit 81d634b

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/agents/cli-runner.reliability.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ import { MAX_AGENT_HOOK_HISTORY_MESSAGES } from "./harness/hook-history.js";
6363

6464
const MAX_CLI_SESSION_HISTORY_MESSAGES = MAX_AGENT_HOOK_HISTORY_MESSAGES;
6565

66+
// Gateway unit coverage owns quiet-admission timing. These reliability cases only
67+
// need to drain calls already in flight, so skip the repeated 250 ms quiet window.
68+
vi.mock("../gateway/mcp-http.loopback-runtime.js", async (importOriginal) => {
69+
const actual = await importOriginal<typeof import("../gateway/mcp-http.loopback-runtime.js")>();
70+
return {
71+
...actual,
72+
waitForMcpLoopbackToolCallCaptureIdle: (
73+
captureKey: string,
74+
options: Parameters<typeof actual.waitForMcpLoopbackToolCallCaptureIdle>[1],
75+
) =>
76+
actual.waitForMcpLoopbackToolCallCaptureIdle(captureKey, {
77+
...options,
78+
admissionGraceMs: 0,
79+
}),
80+
};
81+
});
82+
6683
vi.mock("../plugins/hook-runner-global.js", () => ({
6784
getGlobalHookRunner: vi.fn(() => null),
6885
}));

src/agents/cli-runner.spawn.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ import { setCliRunnerPrepareTestDeps } from "./cli-runner/prepare.js";
6565
import type { PreparedCliRunContext } from "./cli-runner/types.js";
6666
import { createClaudeApiErrorFixture } from "./test-helpers/claude-api-error-fixture.js";
6767

68+
// Gateway unit coverage owns quiet-admission timing. These spawn cases only
69+
// need to drain calls already in flight, so skip the repeated 250 ms quiet window.
70+
vi.mock("../gateway/mcp-http.loopback-runtime.js", async (importOriginal) => {
71+
const actual = await importOriginal<typeof import("../gateway/mcp-http.loopback-runtime.js")>();
72+
return {
73+
...actual,
74+
waitForMcpLoopbackToolCallCaptureIdle: (
75+
captureKey: string,
76+
options: Parameters<typeof actual.waitForMcpLoopbackToolCallCaptureIdle>[1],
77+
) =>
78+
actual.waitForMcpLoopbackToolCallCaptureIdle(captureKey, {
79+
...options,
80+
admissionGraceMs: 0,
81+
}),
82+
};
83+
});
84+
6885
vi.mock("../plugin-sdk/anthropic-cli.js", () => ({
6986
CLAUDE_CLI_BACKEND_ID: "claude-cli",
7087
isClaudeCliProvider: (providerId: string) => providerId === "claude-cli",

0 commit comments

Comments
 (0)