mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:48:26 +00:00
feat!: move msteams to plugin
This commit is contained in:
71
src/channels/plugins/load.test.ts
Normal file
71
src/channels/plugins/load.test.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
import type { ChannelOutboundAdapter, ChannelPlugin } from "./types.js";
|
||||
import type { PluginRegistry } from "../../plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { loadChannelPlugin } from "./load.js";
|
||||
import { loadChannelOutboundAdapter } from "./outbound/load.js";
|
||||
|
||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
||||
plugins: [],
|
||||
tools: [],
|
||||
channels,
|
||||
providers: [],
|
||||
gatewayHandlers: {},
|
||||
httpHandlers: [],
|
||||
cliRegistrars: [],
|
||||
services: [],
|
||||
diagnostics: [],
|
||||
});
|
||||
|
||||
const emptyRegistry = createRegistry([]);
|
||||
|
||||
const msteamsOutbound: ChannelOutboundAdapter = {
|
||||
deliveryMode: "direct",
|
||||
sendText: async () => ({ channel: "msteams", messageId: "m1" }),
|
||||
sendMedia: async () => ({ channel: "msteams", messageId: "m2" }),
|
||||
};
|
||||
|
||||
const msteamsPlugin: ChannelPlugin = {
|
||||
id: "msteams",
|
||||
meta: {
|
||||
id: "msteams",
|
||||
label: "Microsoft Teams",
|
||||
selectionLabel: "Microsoft Teams (Bot Framework)",
|
||||
docsPath: "/channels/msteams",
|
||||
blurb: "Bot Framework; enterprise support.",
|
||||
aliases: ["teams"],
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: {
|
||||
listAccountIds: () => [],
|
||||
resolveAccount: () => ({}),
|
||||
},
|
||||
outbound: msteamsOutbound,
|
||||
};
|
||||
|
||||
const registryWithMSTeams = createRegistry([
|
||||
{ pluginId: "msteams", plugin: msteamsPlugin, source: "test" },
|
||||
]);
|
||||
|
||||
describe("channel plugin loader", () => {
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(emptyRegistry);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
setActivePluginRegistry(emptyRegistry);
|
||||
});
|
||||
|
||||
it("loads channel plugins from the active registry", async () => {
|
||||
setActivePluginRegistry(registryWithMSTeams);
|
||||
const plugin = await loadChannelPlugin("msteams");
|
||||
expect(plugin).toBe(msteamsPlugin);
|
||||
});
|
||||
|
||||
it("loads outbound adapters from registered plugins", async () => {
|
||||
setActivePluginRegistry(registryWithMSTeams);
|
||||
const outbound = await loadChannelOutboundAdapter("msteams");
|
||||
expect(outbound).toBe(msteamsOutbound);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user