mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 23:03:21 +02:00
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { renderRootHelpText } from "./root-help.js";
|
|
|
|
const getPluginCliCommandDescriptorsMock = vi.fn(
|
|
async (_config?: unknown, _env?: unknown, _loaderOptions?: unknown) => [
|
|
{
|
|
name: "matrix",
|
|
description: "Matrix channel utilities",
|
|
hasSubcommands: true,
|
|
},
|
|
],
|
|
);
|
|
|
|
vi.mock("./core-command-descriptors.js", () => ({
|
|
getCoreCliCommandDescriptors: () => [
|
|
{
|
|
name: "status",
|
|
description: "Show status",
|
|
hasSubcommands: false,
|
|
},
|
|
],
|
|
getCoreCliCommandsWithSubcommands: () => [],
|
|
}));
|
|
|
|
vi.mock("./subcli-descriptors.js", () => ({
|
|
getSubCliEntries: () => [
|
|
{
|
|
name: "config",
|
|
description: "Manage config",
|
|
hasSubcommands: true,
|
|
},
|
|
],
|
|
getSubCliCommandsWithSubcommands: () => ["config"],
|
|
}));
|
|
|
|
vi.mock("../../plugins/cli.js", () => ({
|
|
getPluginCliCommandDescriptors: (...args: [unknown?, unknown?, unknown?]) =>
|
|
getPluginCliCommandDescriptorsMock(...args),
|
|
}));
|
|
|
|
describe("root help", () => {
|
|
it("passes isolated config and env through to plugin CLI descriptor loading", async () => {
|
|
const config = {
|
|
agents: {
|
|
defaults: {
|
|
workspace: "/tmp/openclaw-root-help-workspace",
|
|
},
|
|
},
|
|
};
|
|
const env = { OPENCLAW_STATE_DIR: "/tmp/openclaw-root-help-state" } as NodeJS.ProcessEnv;
|
|
|
|
await renderRootHelpText({ config, env, pluginSdkResolution: "src" });
|
|
|
|
expect(getPluginCliCommandDescriptorsMock).toHaveBeenCalledWith(config, env, {
|
|
pluginSdkResolution: "src",
|
|
});
|
|
});
|
|
|
|
it("includes plugin CLI descriptors alongside core and sub-CLI commands", async () => {
|
|
const text = await renderRootHelpText();
|
|
|
|
expect(text).toContain("status");
|
|
expect(text).toContain("config");
|
|
expect(text).toContain("matrix");
|
|
expect(text).toContain("Matrix channel utilities");
|
|
});
|
|
});
|