test: dedupe shared setup in channel and doctor config tests

This commit is contained in:
Peter Steinberger
2026-02-18 03:38:06 +00:00
parent d1ab852972
commit e57628165a
5 changed files with 62 additions and 114 deletions

View File

@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import type { ChannelPlugin } from "../channels/plugins/types.js";
import type { PluginRegistry } from "../plugins/registry.js";
import { setActivePluginRegistry } from "../plugins/runtime.js";
import { createTestRegistry } from "../test-utils/channel-plugins.js";
import { resolveChannelCapabilities } from "./channel-capabilities.js";
import type { OpenClawConfig } from "./config.js";
@@ -86,7 +86,7 @@ describe("resolveChannelCapabilities", () => {
it("supports msteams capabilities", () => {
setActivePluginRegistry(
createRegistry([
createTestRegistry([
{
pluginId: "msteams",
source: "test",
@@ -127,22 +127,6 @@ describe("resolveChannelCapabilities", () => {
});
});
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
plugins: [],
tools: [],
hooks: [],
typedHooks: [],
commands: [],
channels,
providers: [],
gatewayHandlers: {},
httpHandlers: [],
httpRoutes: [],
cliRegistrars: [],
services: [],
diagnostics: [],
});
const createStubPlugin = (id: string): ChannelPlugin => ({
id,
meta: {
@@ -159,7 +143,7 @@ const createStubPlugin = (id: string): ChannelPlugin => ({
},
});
const baseRegistry = createRegistry([
const baseRegistry = createTestRegistry([
{ pluginId: "telegram", source: "test", plugin: createStubPlugin("telegram") },
{ pluginId: "slack", source: "test", plugin: createStubPlugin("slack") },
]);