test(infra): update loaded outbound target mock

This commit is contained in:
Peter Steinberger
2026-04-06 23:34:21 +01:00
parent ab0c102ed7
commit 1990d2e761

View File

@@ -3,30 +3,20 @@ import type { OpenClawConfig } from "../../config/config.js";
import { tryResolveLoadedOutboundTarget } from "./targets-loaded.js";
const mocks = vi.hoisted(() => ({
getChannelPlugin: vi.fn(),
getActivePluginRegistry: vi.fn(),
getActivePluginChannelRegistry: vi.fn(),
getLoadedChannelPlugin: vi.fn(),
}));
vi.mock("../../channels/plugins/index.js", () => ({
getChannelPlugin: mocks.getChannelPlugin,
}));
vi.mock("../../plugins/runtime.js", () => ({
getActivePluginRegistry: mocks.getActivePluginRegistry,
getActivePluginChannelRegistry: mocks.getActivePluginChannelRegistry,
getLoadedChannelPlugin: mocks.getLoadedChannelPlugin,
}));
describe("tryResolveLoadedOutboundTarget", () => {
beforeEach(() => {
mocks.getChannelPlugin.mockReset();
mocks.getActivePluginRegistry.mockReset();
mocks.getActivePluginChannelRegistry.mockReset();
mocks.getLoadedChannelPlugin.mockReset();
});
it("returns undefined when no loaded plugin exists", () => {
mocks.getChannelPlugin.mockReturnValue(undefined);
mocks.getActivePluginRegistry.mockReturnValue(null);
mocks.getLoadedChannelPlugin.mockReturnValue(undefined);
expect(tryResolveLoadedOutboundTarget({ channel: "telegram", to: "123" })).toBeUndefined();
});
@@ -35,7 +25,7 @@ describe("tryResolveLoadedOutboundTarget", () => {
const cfg: OpenClawConfig = {
channels: { telegram: { defaultTo: "123456789" } },
};
mocks.getChannelPlugin.mockReturnValue({
mocks.getLoadedChannelPlugin.mockReturnValue({
id: "telegram",
meta: { label: "Telegram" },
capabilities: {},