mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 01:10:22 +00:00
fix(plugins): honor channels.<id>.enabled for bundled channels
This commit is contained in:
committed by
Peter Steinberger
parent
65d57eac12
commit
3cadc3eed1
@@ -195,6 +195,104 @@ describe("loadOpenClawPlugins", () => {
|
||||
expect(registry.channels.some((entry) => entry.plugin.id === "telegram")).toBe(true);
|
||||
});
|
||||
|
||||
it("loads bundled channel plugins when channels.<id>.enabled=true", () => {
|
||||
const bundledDir = makeTempDir();
|
||||
writePlugin({
|
||||
id: "telegram",
|
||||
body: `export default { id: "telegram", register(api) {
|
||||
api.registerChannel({
|
||||
plugin: {
|
||||
id: "telegram",
|
||||
meta: {
|
||||
id: "telegram",
|
||||
label: "Telegram",
|
||||
selectionLabel: "Telegram",
|
||||
docsPath: "/channels/telegram",
|
||||
blurb: "telegram channel"
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: {
|
||||
listAccountIds: () => [],
|
||||
resolveAccount: () => ({ accountId: "default" })
|
||||
},
|
||||
outbound: { deliveryMode: "direct" }
|
||||
}
|
||||
});
|
||||
} };`,
|
||||
dir: bundledDir,
|
||||
filename: "telegram.js",
|
||||
});
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledDir;
|
||||
|
||||
const registry = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
config: {
|
||||
channels: {
|
||||
telegram: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
|
||||
expect(telegram?.status).toBe("loaded");
|
||||
expect(registry.channels.some((entry) => entry.plugin.id === "telegram")).toBe(true);
|
||||
});
|
||||
|
||||
it("still respects explicit disable via plugins.entries for bundled channels", () => {
|
||||
const bundledDir = makeTempDir();
|
||||
writePlugin({
|
||||
id: "telegram",
|
||||
body: `export default { id: "telegram", register(api) {
|
||||
api.registerChannel({
|
||||
plugin: {
|
||||
id: "telegram",
|
||||
meta: {
|
||||
id: "telegram",
|
||||
label: "Telegram",
|
||||
selectionLabel: "Telegram",
|
||||
docsPath: "/channels/telegram",
|
||||
blurb: "telegram channel"
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: {
|
||||
listAccountIds: () => [],
|
||||
resolveAccount: () => ({ accountId: "default" })
|
||||
},
|
||||
outbound: { deliveryMode: "direct" }
|
||||
}
|
||||
});
|
||||
} };`,
|
||||
dir: bundledDir,
|
||||
filename: "telegram.js",
|
||||
});
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledDir;
|
||||
|
||||
const registry = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
config: {
|
||||
channels: {
|
||||
telegram: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
entries: {
|
||||
telegram: { enabled: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
|
||||
expect(telegram?.status).toBe("disabled");
|
||||
expect(telegram?.error).toBe("disabled in config");
|
||||
});
|
||||
|
||||
it("enables bundled memory plugin when selected by slot", () => {
|
||||
const registry = loadBundledMemoryPluginRegistry();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user