mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
test(gateway): avoid send handler reimports
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user