From 25039e973e329ef7abf1b2cfb553fbe86d4798dd Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 23 Apr 2026 08:59:41 +0100 Subject: [PATCH] test(gateway): avoid send handler reimports --- src/gateway/server-methods/send.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gateway/server-methods/send.test.ts b/src/gateway/server-methods/send.test.ts index 2ebc7096ad4..68329abf28b 100644 --- a/src/gateway/server-methods/send.test.ts +++ b/src/gateway/server-methods/send.test.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { jsonResult } from "../../agents/tools/common.js"; import type { ChannelPlugin } from "../../channels/plugins/types.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; @@ -76,6 +76,12 @@ vi.mock("../../config/plugin-auto-enable.js", () => ({ vi.mock("../../plugins/loader.js", () => ({ loadOpenClawPlugins: mocks.loadOpenClawPlugins, + resolveRuntimePluginRegistry: vi.fn(), +})); + +vi.mock("../../infra/outbound/channel-bootstrap.runtime.js", () => ({ + bootstrapOutboundChannelPlugin: vi.fn(), + resetOutboundChannelBootstrapStateForTests: vi.fn(), })); vi.mock("../../infra/outbound/targets.js", () => ({ @@ -106,8 +112,7 @@ vi.mock("../../config/sessions.js", async () => { }; }); -async function loadFreshSendHandlersForTest() { - vi.resetModules(); +async function loadSendHandlersForTest() { ({ sendHandlers } = await import("./send.js")); } @@ -194,6 +199,10 @@ function mockDeliverySuccess(messageId: string) { describe("gateway send mirroring", () => { let registrySeq = 0; + beforeAll(async () => { + await loadSendHandlersForTest(); + }); + beforeEach(async () => { vi.clearAllMocks(); registrySeq += 1; @@ -218,7 +227,6 @@ describe("gateway send mirroring", () => { }); mocks.sendPoll.mockResolvedValue({ messageId: "poll-1" }); mocks.getChannelPlugin.mockReturnValue({ outbound: { sendPoll: mocks.sendPoll } }); - await loadFreshSendHandlersForTest(); }); it("accepts media-only sends without message", async () => {