mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveCliCommandPathPolicy } from "./command-path-policy.js";
|
|
|
|
describe("command-path-policy", () => {
|
|
it("resolves status policy with shared startup semantics", () => {
|
|
expect(resolveCliCommandPathPolicy(["status"])).toEqual({
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "when-suppressed",
|
|
loadPlugins: "text-only",
|
|
hideBanner: false,
|
|
ensureCliPath: false,
|
|
});
|
|
});
|
|
|
|
it("applies exact overrides after broader channel plugin rules", () => {
|
|
expect(resolveCliCommandPathPolicy(["channels", "send"])).toEqual({
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "always",
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
});
|
|
expect(resolveCliCommandPathPolicy(["channels", "add"])).toEqual({
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "never",
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
});
|
|
});
|
|
|
|
it("resolves mixed startup-only rules", () => {
|
|
expect(resolveCliCommandPathPolicy(["config", "validate"])).toEqual({
|
|
bypassConfigGuard: true,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "never",
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
});
|
|
expect(resolveCliCommandPathPolicy(["gateway", "status"])).toEqual({
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "always",
|
|
loadPlugins: "never",
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
});
|
|
expect(resolveCliCommandPathPolicy(["plugins", "update"])).toEqual({
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "never",
|
|
hideBanner: true,
|
|
ensureCliPath: true,
|
|
});
|
|
expect(resolveCliCommandPathPolicy(["cron", "list"])).toEqual({
|
|
bypassConfigGuard: true,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "never",
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
});
|
|
});
|
|
});
|