refactor(auto-reply): share agent-runner test harness mocks

This commit is contained in:
Peter Steinberger
2026-02-15 14:24:06 +00:00
parent af34c8fafe
commit 33a3a56ee1
3 changed files with 53 additions and 46 deletions

View File

@@ -4,6 +4,11 @@ import type { TypingMode } from "../../config/types.js";
import type { TemplateContext } from "../templating.js";
import type { GetReplyOptions } from "../types.js";
import type { FollowupRun, QueueSettings } from "./queue.js";
import {
embeddedPiMockFactory,
modelFallbackMockFactory,
queueMockFactory,
} from "./agent-runner.test-harness.mocks.js";
import { createMockTypingController } from "./test-helpers.js";
// Avoid exporting vitest mock types (TS2742 under pnpm + d.ts emit).
@@ -40,34 +45,14 @@ export function installRunReplyAgentTypingHeartbeatTestHooks() {
}
vi.mock("../../agents/model-fallback.js", () => ({
runWithModelFallback: async ({
provider,
model,
run,
}: {
provider: string;
model: string;
run: (provider: string, model: string) => Promise<unknown>;
}) => ({
result: await run(provider, model),
provider,
model,
}),
...modelFallbackMockFactory(),
}));
vi.mock("../../agents/pi-embedded.js", () => ({
queueEmbeddedPiMessage: vi.fn().mockReturnValue(false),
runEmbeddedPiAgent: (params: unknown) => state.runEmbeddedPiAgentMock(params),
...embeddedPiMockFactory(state),
}));
vi.mock("./queue.js", async () => {
const actual = await vi.importActual<typeof import("./queue.js")>("./queue.js");
return {
...actual,
enqueueFollowupRun: vi.fn(),
scheduleFollowupDrain: vi.fn(),
};
});
vi.mock("./queue.js", queueMockFactory);
export function createMinimalRun(params?: {
opts?: GetReplyOptions;