mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 01:10:42 +00:00
test: dedupe command builtin name checks
This commit is contained in:
@@ -190,6 +190,16 @@ function requireCommand<T extends { name: string }>(commands: T[], name: string)
|
||||
return command;
|
||||
}
|
||||
|
||||
function collectBuiltinNames(commands: readonly { name: string; source: string }[]): string[] {
|
||||
const names: string[] = [];
|
||||
for (const command of commands) {
|
||||
if (command.source !== "plugin") {
|
||||
names.push(command.name);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
describe("commands.list handler", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
@@ -286,7 +296,7 @@ describe("commands.list handler", () => {
|
||||
it("filters built-in commands by scope=native (excludes text-only)", () => {
|
||||
const { payload } = callHandler({ scope: "native" });
|
||||
const { commands } = payload as { commands: Array<{ name: string; source: string }> };
|
||||
const builtinNames = commands.filter((c) => c.source !== "plugin").map((c) => c.name);
|
||||
const builtinNames = collectBuiltinNames(commands);
|
||||
expect(builtinNames).not.toContain("commands");
|
||||
expect(builtinNames).toContain("model");
|
||||
expect(builtinNames).toContain("debug_prompt");
|
||||
@@ -295,7 +305,7 @@ describe("commands.list handler", () => {
|
||||
it("filters built-in commands by scope=text (excludes native-only)", () => {
|
||||
const { payload } = callHandler({ scope: "text" });
|
||||
const { commands } = payload as { commands: Array<{ name: string; source: string }> };
|
||||
const builtinNames = commands.filter((c) => c.source !== "plugin").map((c) => c.name);
|
||||
const builtinNames = collectBuiltinNames(commands);
|
||||
expect(builtinNames).toContain("commands");
|
||||
expect(builtinNames).not.toContain("debug_prompt");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user