fix: use exported mock for deliverOutboundPayloads in test harness

The test was calling vi.mocked() on a direct import, but the mock was
an anonymous vi.fn() inside an async factory — vi.mocked() returned a
non-mock object. Export deliverOutboundPayloadsMock from the harness
following the same pattern as all other mocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sergio 2026-03-15 17:43:44 -05:00
parent 2908a8363c
commit a42e90b4bb
2 changed files with 7 additions and 6 deletions

View File

@ -10,10 +10,10 @@
* proceed normally.
*/
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
clearFastTestEnv,
deliverOutboundPayloadsMock,
loadRunCronIsolatedAgentTurn,
resetRunCronIsolatedAgentTurnHarness,
resolveCronDeliveryPlanMock,
@ -83,9 +83,7 @@ describe("runCronIsolatedAgentTurn -- announce suppressed send dedupe (#42244)",
source: "delivery",
});
// The harness mock returns undefined which causes TypeError in delivery
// dispatch. Override to return a proper result array.
vi.mocked(deliverOutboundPayloads).mockResolvedValue([{ ok: true } as never]);
deliverOutboundPayloadsMock.mockResolvedValue([{ ok: true } as never]);
});
afterEach(() => {

View File

@ -43,6 +43,7 @@ export const logWarnMock = createMock();
export const countActiveDescendantRunsMock = createMock();
export const listDescendantRunsForRequesterMock = createMock();
export const pickLastNonEmptyTextFromPayloadsMock = createMock();
export const deliverOutboundPayloadsMock = createMock();
export const resolveCronDeliveryPlanMock = createMock();
export const resolveDeliveryTargetMock = createMock();
@ -240,7 +241,7 @@ vi.mock("../../infra/outbound/deliver.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../../infra/outbound/deliver.js")>();
return {
...actual,
deliverOutboundPayloads: vi.fn().mockResolvedValue(undefined),
deliverOutboundPayloads: deliverOutboundPayloadsMock,
};
});
@ -387,6 +388,8 @@ export function resetRunCronIsolatedAgentTurnHarness(): void {
listDescendantRunsForRequesterMock.mockReturnValue([]);
pickLastNonEmptyTextFromPayloadsMock.mockReset();
pickLastNonEmptyTextFromPayloadsMock.mockReturnValue("test output");
deliverOutboundPayloadsMock.mockReset();
deliverOutboundPayloadsMock.mockResolvedValue([]);
resolveCronDeliveryPlanMock.mockReset();
resolveCronDeliveryPlanMock.mockReturnValue({ requested: false, mode: "none" });
resolveDeliveryTargetMock.mockReset();