mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test: inline cli metadata channel fixture
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user