refactor(test): centralize trigger and cron test helpers

This commit is contained in:
Peter Steinberger
2026-02-22 20:01:54 +00:00
parent 3c75bc0e41
commit 5e8b1f5ac8
21 changed files with 217 additions and 316 deletions

View File

@@ -1,16 +1,12 @@
import fs from "node:fs/promises";
import path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.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";
import { runHeartbeatOnce } from "./heartbeat-runner.js";
import {
seedSessionStore,
setupTelegramHeartbeatPluginRuntimeForTests,
withTempTelegramHeartbeatSandbox,
} from "./heartbeat-runner.test-utils.js";
@@ -18,11 +14,7 @@ import {
vi.mock("jiti", () => ({ createJiti: () => () => ({}) }));
beforeEach(() => {
const runtime = createPluginRuntime();
setTelegramRuntime(runtime);
setActivePluginRegistry(
createTestRegistry([{ pluginId: "telegram", plugin: telegramPlugin, source: "test" }]),
);
setupTelegramHeartbeatPluginRuntimeForTests();
});
describe("heartbeat transcript pruning", () => {