mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 03:30:34 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
40
src/infra/heartbeat-runner.test-harness.ts
Normal file
40
src/infra/heartbeat-runner.test-harness.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { beforeEach } from "vitest";
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
import { slackPlugin } from "../../extensions/slack/src/channel.js";
|
||||
import { setSlackRuntime } from "../../extensions/slack/src/runtime.js";
|
||||
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
|
||||
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js";
|
||||
import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js";
|
||||
import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.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" },
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user