perf(test): replace claude runner call polling loop

This commit is contained in:
Peter Steinberger
2026-02-18 17:51:38 +00:00
parent a82ceb81d2
commit c68d1073b5

View File

@@ -1,5 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
import { sleep } from "../utils.js";
import { runClaudeCliAgent } from "./claude-cli-runner.js"; import { runClaudeCliAgent } from "./claude-cli-runner.js";
const mocks = vi.hoisted(() => ({ const mocks = vi.hoisted(() => ({
@@ -65,13 +64,12 @@ function successExit(payload: { message: string; session_id: string }) {
} }
async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) { async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) {
for (let i = 0; i < 50; i += 1) { await vi.waitFor(
if (mockFn.mock.calls.length >= count) { () => {
return; expect(mockFn.mock.calls.length).toBeGreaterThanOrEqual(count);
} },
await sleep(0); { timeout: 2_000, interval: 5 },
} );
throw new Error(`Expected ${count} calls, got ${mockFn.mock.calls.length}`);
} }
describe("runClaudeCliAgent", () => { describe("runClaudeCliAgent", () => {