test: trim message action poll runner setup

This commit is contained in:
Shakker 2026-04-01 20:16:00 +01:00 committed by Peter Steinberger
parent 0875c2e370
commit 768ec2a712
1 changed files with 12 additions and 14 deletions

View File

@ -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<typeof import("./outbound-send-service.js")>(
"./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<typeof import("./outbound-send-service.js")>(
"./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(() => {