From 768ec2a71221441a1826a79d0fe92fe3f3fc119d Mon Sep 17 00:00:00 2001 From: Shakker Date: Wed, 1 Apr 2026 20:16:00 +0100 Subject: [PATCH] test: trim message action poll runner setup --- .../message-action-runner.poll.test.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/infra/outbound/message-action-runner.poll.test.ts b/src/infra/outbound/message-action-runner.poll.test.ts index b1ff7fbeefa..c806c46f855 100644 --- a/src/infra/outbound/message-action-runner.poll.test.ts +++ b/src/infra/outbound/message-action-runner.poll.test.ts @@ -3,12 +3,21 @@ import type { ChannelPlugin } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; import { createTestRegistry } from "../../test-utils/channel-plugins.js"; - -let runMessageAction: typeof import("./message-action-runner.js").runMessageAction; +import { runMessageAction } from "./message-action-runner.js"; const mocks = vi.hoisted(() => ({ executePollAction: vi.fn(), })); + +vi.mock("./outbound-send-service.js", async () => { + const actual = await vi.importActual( + "./outbound-send-service.js", + ); + return { + ...actual, + executePollAction: mocks.executePollAction, + }; +}); const telegramConfig = { channels: { telegram: { @@ -92,17 +101,7 @@ async function runPollAction(params: { } describe("runMessageAction poll handling", () => { - beforeEach(async () => { - vi.resetModules(); - vi.doMock("./outbound-send-service.js", async () => { - const actual = await vi.importActual( - "./outbound-send-service.js", - ); - return { - ...actual, - executePollAction: mocks.executePollAction, - }; - }); + beforeEach(() => { setActivePluginRegistry( createTestRegistry([ { @@ -118,7 +117,6 @@ describe("runMessageAction poll handling", () => { payload: { ok: true, corePoll: input.resolveCorePoll() }, pollResult: { ok: true }, })); - ({ runMessageAction } = await import("./message-action-runner.js")); }); afterEach(() => {