mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 08:40:22 +00:00
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { beforeEach } from "vitest";
|
|
import { slackPlugin, setSlackRuntime } from "../../extensions/slack/index.js";
|
|
import { telegramPlugin, setTelegramRuntime } from "../../extensions/telegram/index.js";
|
|
import { whatsappPlugin, setWhatsAppRuntime } from "../../extensions/whatsapp/index.js";
|
|
import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
|
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
|
import { createPluginRuntime } from "../plugins/runtime/index.js";
|
|
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
|
|
|
const slackChannelPlugin = slackPlugin as unknown as ChannelPlugin;
|
|
const telegramChannelPlugin = telegramPlugin as unknown as ChannelPlugin;
|
|
const whatsappChannelPlugin = whatsappPlugin as unknown as ChannelPlugin;
|
|
|
|
export function installHeartbeatRunnerTestRuntime(params?: { includeSlack?: boolean }): void {
|
|
beforeEach(() => {
|
|
const runtime = createPluginRuntime();
|
|
setTelegramRuntime(runtime);
|
|
setWhatsAppRuntime(runtime);
|
|
if (params?.includeSlack) {
|
|
setSlackRuntime(runtime);
|
|
setActivePluginRegistry(
|
|
createTestRegistry([
|
|
{ pluginId: "slack", plugin: slackChannelPlugin, source: "test" },
|
|
{ pluginId: "whatsapp", plugin: whatsappChannelPlugin, source: "test" },
|
|
{ pluginId: "telegram", plugin: telegramChannelPlugin, source: "test" },
|
|
]),
|
|
);
|
|
return;
|
|
}
|
|
setActivePluginRegistry(
|
|
createTestRegistry([
|
|
{ pluginId: "whatsapp", plugin: whatsappChannelPlugin, source: "test" },
|
|
{ pluginId: "telegram", plugin: telegramChannelPlugin, source: "test" },
|
|
]),
|
|
);
|
|
});
|
|
}
|