























@@ -0,0 +1,64 @@
1+import { beforeEach, describe, expect, it, vi } from "vitest";
2+import type { PluginChannelCatalogEntry } from "../../plugins/channel-catalog-registry.js";
3+import {
4+hasBundledChannelPackageState,
5+listBundledChannelIdsForPackageState,
6+} from "./package-state-probes.js";
7+8+const listChannelCatalogEntriesMock = vi.hoisted(() => vi.fn());
9+10+vi.mock("../../plugins/channel-catalog-registry.js", () => ({
11+listChannelCatalogEntries: listChannelCatalogEntriesMock,
12+}));
13+14+function makeBundledChannelCatalogEntry(params: {
15+pluginId: string;
16+channelId: string;
17+}): PluginChannelCatalogEntry {
18+return {
19+pluginId: params.pluginId,
20+origin: "bundled",
21+rootDir: "/tmp/openclaw-channel-plugin",
22+channel: {
23+id: params.channelId,
24+configuredState: {
25+env: {
26+allOf: ["ALIAS_CHAT_TOKEN"],
27+},
28+},
29+},
30+};
31+}
32+33+beforeEach(() => {
34+listChannelCatalogEntriesMock.mockReset();
35+});
36+37+describe("channel package-state probes", () => {
38+it("uses channel ids when manifest plugin ids differ", () => {
39+listChannelCatalogEntriesMock.mockReturnValue([
40+makeBundledChannelCatalogEntry({
41+pluginId: "vendor-alias-chat-plugin",
42+channelId: "alias-chat",
43+}),
44+]);
45+46+expect(listBundledChannelIdsForPackageState("configuredState")).toEqual(["alias-chat"]);
47+expect(
48+hasBundledChannelPackageState({
49+metadataKey: "configuredState",
50+channelId: "alias-chat",
51+cfg: {},
52+env: { ALIAS_CHAT_TOKEN: "token" },
53+}),
54+).toBe(true);
55+expect(
56+hasBundledChannelPackageState({
57+metadataKey: "configuredState",
58+channelId: "vendor-alias-chat-plugin",
59+cfg: {},
60+env: { ALIAS_CHAT_TOKEN: "token" },
61+}),
62+).toBe(false);
63+});
64+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。