mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
## Summary - Add catalog-backed repair hints for official external channel plugins. - Show configured Feishu/WhatsApp-style external channels as missing-plugin warning rows in status surfaces. - Keep installed-but-unconfigured, disabled, allowlist-denied, and untrusted plugins on their real activation/configuration error paths. Fixes #78702 Fixes #78593
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { resolveMissingOfficialExternalChannelPluginRepairHint } from "./official-external-plugin-repair-hints.js";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
resolveConfiguredChannelPresencePolicy: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("./channel-plugin-ids.js", () => ({
|
|
resolveConfiguredChannelPresencePolicy: (params: unknown) =>
|
|
mocks.resolveConfiguredChannelPresencePolicy(params),
|
|
}));
|
|
|
|
describe("resolveMissingOfficialExternalChannelPluginRepairHint", () => {
|
|
beforeEach(() => {
|
|
mocks.resolveConfiguredChannelPresencePolicy.mockReset();
|
|
});
|
|
|
|
it("returns an install hint when a configured official external channel has no owner", () => {
|
|
mocks.resolveConfiguredChannelPresencePolicy.mockReturnValue([
|
|
{
|
|
channelId: "feishu",
|
|
sources: ["explicit-config"],
|
|
effective: false,
|
|
pluginIds: [],
|
|
blockedReasons: ["no-channel-owner"],
|
|
},
|
|
]);
|
|
|
|
expect(
|
|
resolveMissingOfficialExternalChannelPluginRepairHint({
|
|
config: { channels: { feishu: { appId: "cli_xxx" } } },
|
|
channelId: "feishu",
|
|
}),
|
|
).toEqual(
|
|
expect.objectContaining({
|
|
channelId: "feishu",
|
|
installCommand: "openclaw plugins install @openclaw/feishu",
|
|
doctorFixCommand: "openclaw doctor --fix",
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("does not return install hints for policy-blocked official external channel owners", () => {
|
|
mocks.resolveConfiguredChannelPresencePolicy.mockReturnValue([
|
|
{
|
|
channelId: "whatsapp",
|
|
sources: ["explicit-config"],
|
|
effective: false,
|
|
pluginIds: [],
|
|
blockedReasons: ["not-in-allowlist"],
|
|
},
|
|
]);
|
|
|
|
expect(
|
|
resolveMissingOfficialExternalChannelPluginRepairHint({
|
|
config: { channels: { whatsapp: { enabled: true } } },
|
|
channelId: "whatsapp",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("does not return install hints for active official external channel owners", () => {
|
|
mocks.resolveConfiguredChannelPresencePolicy.mockReturnValue([
|
|
{
|
|
channelId: "whatsapp",
|
|
sources: ["explicit-config"],
|
|
effective: true,
|
|
pluginIds: ["whatsapp"],
|
|
blockedReasons: [],
|
|
},
|
|
]);
|
|
|
|
expect(
|
|
resolveMissingOfficialExternalChannelPluginRepairHint({
|
|
config: { channels: { whatsapp: { enabled: true } } },
|
|
channelId: "whatsapp",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|