Elffuss BraidHub

kikocis/continue public

main · 2.7 KiBRawPermalink
1import type { AssistantConfig } from "@continuedev/sdk";
2import { describe, expect, it } from "vitest";
3
4import { getAllSlashCommands } from "./commands.js";
5
6describe("Slash Commands Integration", () => {
7 const mockAssistant: AssistantConfig = {
8 name: "test-assistant",
9 version: "1.0.0",
10 prompts: [
11 {
12 name: "test-prompt",
13 prompt: "Test prompt",
14 description: "Test prompt description",
15 },
16 ],
17 };
18
19 describe("System Commands Registration", () => {
20 it("should include all system commands in the commands list", () => {
21 const commands = getAllSlashCommands(mockAssistant);
22 const commandNames = commands.map((cmd) => cmd.name);
23
24 // Check that system commands are present (mode commands have been removed)
25 expect(commandNames).toContain("help");
26 expect(commandNames).toContain("clear");
27 expect(commandNames).toContain("exit");
28 expect(commandNames).toContain("login");
29 expect(commandNames).toContain("logout");
30 expect(commandNames).toContain("whoami");
31
32 expect(commandNames).toContain("model");
33 expect(commandNames).toContain("config");
34 });
35
36 it("should include assistant prompt commands", () => {
37 const commands = getAllSlashCommands(mockAssistant);
38 const commandNames = commands.map((cmd) => cmd.name);
39
40 expect(commandNames).toContain("test-prompt");
41 });
42
43 it("should categorize system commands correctly", () => {
44 const commands = getAllSlashCommands(mockAssistant);
45 const systemCommands = commands.filter((cmd) =>
46 [
47 "help",
48 "clear",
49 "exit",
50 "login",
51 "logout",
52 "whoami",
53 "model",
54 "config",
55 ].includes(cmd.name),
56 );
57
58 systemCommands.forEach((cmd) => {
59 expect(cmd.category).toBe("system");
60 });
61 });
62
63 it("should categorize assistant commands correctly", () => {
64 const commands = getAllSlashCommands(mockAssistant);
65 const assistantCommands = commands.filter(
66 (cmd) => cmd.name === "test-prompt",
67 );
68
69 assistantCommands.forEach((cmd) => {
70 expect(cmd.category).toBe("assistant");
71 });
72 });
73
74 it("should only show remote mode commands in remote mode", () => {
75 const commands = getAllSlashCommands(mockAssistant, {
76 isRemoteMode: true,
77 });
78 const commandNames = commands.map((cmd) => cmd.name);
79
80 // In remote mode, only remote commands should be available
81 expect(commandNames).toContain("exit");
82 expect(commandNames).toContain("diff");
83 expect(commandNames).toContain("apply");
84 expect(commandNames).toHaveLength(3);
85 });
86 });
87});