test(agents): dedupe cron tool mock wiring

This commit is contained in:
Peter Steinberger
2026-02-18 13:29:44 +00:00
parent 8f866d51c4
commit a18f411fb6
3 changed files with 22 additions and 26 deletions

View File

@@ -1,15 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const callGatewayMock = vi.fn();
vi.mock("../../gateway/call.js", () => ({
callGateway: (opts: unknown) => callGatewayMock(opts),
}));
vi.mock("../agent-scope.js", () => ({
resolveSessionAgentId: () => "agent-123",
}));
import { beforeEach, describe, expect, it } from "vitest";
import { createCronTool } from "./cron-tool.js";
import { callGatewayMock, resetCronToolGatewayMock } from "./cron-tool.test-helpers.js";
describe("cron tool", () => {
async function executeAddAndReadDelivery(params: {
@@ -35,8 +26,7 @@ describe("cron tool", () => {
}
beforeEach(() => {
callGatewayMock.mockReset();
callGatewayMock.mockResolvedValue({ ok: true });
resetCronToolGatewayMock();
});
it.each([

View File

@@ -1,20 +1,10 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const callGatewayMock = vi.fn();
vi.mock("../../gateway/call.js", () => ({
callGateway: (opts: unknown) => callGatewayMock(opts),
}));
vi.mock("../agent-scope.js", () => ({
resolveSessionAgentId: () => "agent-123",
}));
import { beforeEach, describe, expect, it } from "vitest";
import { createCronTool } from "./cron-tool.js";
import { callGatewayMock, resetCronToolGatewayMock } from "./cron-tool.test-helpers.js";
describe("cron tool flat-params", () => {
beforeEach(() => {
callGatewayMock.mockReset();
callGatewayMock.mockResolvedValue({ ok: true });
resetCronToolGatewayMock();
});
it("preserves explicit top-level sessionKey during flat-params recovery", async () => {

View File

@@ -0,0 +1,16 @@
import { vi } from "vitest";
export const callGatewayMock = vi.fn();
vi.mock("../../gateway/call.js", () => ({
callGateway: (opts: unknown) => callGatewayMock(opts),
}));
vi.mock("../agent-scope.js", () => ({
resolveSessionAgentId: () => "agent-123",
}));
export function resetCronToolGatewayMock() {
callGatewayMock.mockReset();
callGatewayMock.mockResolvedValue({ ok: true });
}