test: inline cli metadata channel fixture

This commit is contained in:
Peter Steinberger
2026-04-08 12:58:48 +01:00
parent 4e41cf7a6e
commit 640d39d482

View File

@@ -19,6 +19,33 @@ afterAll(() => {
cleanupPluginLoaderFixturesForTest();
});
function inlineChannelPluginEntryFactorySource(): string {
return `function defineChannelPluginEntry(options) {
return {
id: options.id,
name: options.name,
description: options.description,
configSchema: { schema: { type: "object" } },
channelPlugin: options.plugin,
setChannelRuntime: options.setRuntime,
register(api) {
if (api.registrationMode === "cli-metadata") {
options.registerCliMetadata?.(api);
return;
}
options.setRuntime?.(api.runtime);
api.registerChannel({ plugin: options.plugin });
if (api.registrationMode !== "full") {
return;
}
options.registerCliMetadata?.(api);
options.registerFull?.(api);
},
};
}
`;
}
describe("plugin loader CLI metadata", () => {
it("suppresses trust warning logs during CLI metadata loads", async () => {
useNoBundledPlugins();
@@ -162,7 +189,7 @@ describe("plugin loader CLI metadata", () => {
);
fs.writeFileSync(
path.join(pluginDir, "index.cjs"),
`const { defineChannelPluginEntry } = require("openclaw/plugin-sdk/core");
`${inlineChannelPluginEntryFactorySource()}
require("node:fs").writeFileSync(${JSON.stringify(fullMarker)}, "loaded", "utf-8");
module.exports = {
...defineChannelPluginEntry({
@@ -485,7 +512,7 @@ module.exports = {
);
fs.writeFileSync(
path.join(pluginDir, "index.cjs"),
`const { defineChannelPluginEntry } = require("openclaw/plugin-sdk/core");
`${inlineChannelPluginEntryFactorySource()}
module.exports = {
...defineChannelPluginEntry({
id: "full-cli-metadata-channel",