mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:34:35 +00:00
refactor(test): centralize trigger and cron test helpers
This commit is contained in:
@@ -2,9 +2,14 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { vi } from "vitest";
|
||||
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
|
||||
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js";
|
||||
import * as replyModule from "../auto-reply/reply.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveMainSessionKey } from "../config/sessions.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { createPluginRuntime } from "../plugins/runtime/index.js";
|
||||
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
|
||||
export type HeartbeatSessionSeed = {
|
||||
sessionId?: string;
|
||||
@@ -91,3 +96,11 @@ export async function withTempTelegramHeartbeatSandbox<T>(
|
||||
unsetEnvVars: ["TELEGRAM_BOT_TOKEN"],
|
||||
});
|
||||
}
|
||||
|
||||
export function setupTelegramHeartbeatPluginRuntimeForTests() {
|
||||
const runtime = createPluginRuntime();
|
||||
setTelegramRuntime(runtime);
|
||||
setActivePluginRegistry(
|
||||
createTestRegistry([{ pluginId: "telegram", plugin: telegramPlugin, source: "test" }]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user