Elffuss BraidHub

kikocis/continue public

main · 1.8 KiBRawPermalink
1import { describe, expect, it, vi, beforeEach } from "vitest";
2
3import { handleSlashCommands } from "./slashCommands.js";
4
5describe("Remote mode slash commands", () => {
6 const mockAssistant = {
7 name: "test",
8 version: "1.0.0",
9 prompts: [],
10 };
11
12 beforeEach(() => {
13 vi.clearAllMocks();
14 });
15
16 describe("/diff and /apply commands", () => {
17 it("should not be handled by handleSlashCommands - these are handled by TUI layer", async () => {
18 // /diff and /apply are handled by handleSpecialCommands in useChat.helpers.ts,
19 // not by the general slash command system. These commands are intercepted
20 // at the TUI layer before reaching handleSlashCommands, so handleSlashCommands
21 // should return null (no match) for these commands.
22
23 const diffResult = await handleSlashCommands("/diff", mockAssistant);
24 expect(diffResult).toBe(null);
25
26 const applyResult = await handleSlashCommands("/apply", mockAssistant);
27 expect(applyResult).toBe(null);
28 });
29
30 it("should return unknown command for remote commands when called directly", async () => {
31 // When called directly (bypassing handleSpecialCommands), /diff and /apply
32 // should return "Unknown command" because they're listed in REMOTE_MODE_SLASH_COMMANDS
33 // for UI display but not implemented as handlers.
34
35 const diffResult = await handleSlashCommands("/diff", mockAssistant, {
36 remoteUrl: "http://localhost:3000",
37 isRemoteMode: true,
38 });
39 expect(diffResult).toEqual({
40 output: "Unknown command: diff",
41 });
42
43 const applyResult = await handleSlashCommands("/apply", mockAssistant, {
44 remoteUrl: "http://localhost:3000",
45 isRemoteMode: true,
46 });
47 expect(applyResult).toEqual({
48 output: "Unknown command: apply",
49 });
50 });
51 });
52});