Skip to content

Commit e85362f

Browse files
committed
New task slash command
1 parent b6f571c commit e85362f

File tree

87 files changed

+1138
-857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1138
-857
lines changed

apps/cli/src/__tests__/extension-host.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -433,24 +433,6 @@ describe("ExtensionHost", () => {
433433

434434
expect(handleMsgUpdatedSpy).toHaveBeenCalled()
435435
})
436-
437-
it("should route action messages to handleActionMessage", () => {
438-
const host = createTestHost()
439-
const handleActionSpy = spyOnPrivate(host, "handleActionMessage")
440-
441-
callPrivate(host, "handleExtensionMessage", { type: "action", action: "test" })
442-
443-
expect(handleActionSpy).toHaveBeenCalled()
444-
})
445-
446-
it("should route invoke messages to handleInvokeMessage", () => {
447-
const host = createTestHost()
448-
const handleInvokeSpy = spyOnPrivate(host, "handleInvokeMessage")
449-
450-
callPrivate(host, "handleExtensionMessage", { type: "invoke", invoke: "test" })
451-
452-
expect(handleInvokeSpy).toHaveBeenCalled()
453-
})
454436
})
455437

456438
describe("handleSayMessage", () => {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { describe, it, expect } from "vitest"
2+
import {
3+
GLOBAL_COMMANDS,
4+
getGlobalCommand,
5+
getGlobalCommandsForAutocomplete,
6+
type GlobalCommand,
7+
type GlobalCommandAction,
8+
} from "../globalCommands.js"
9+
10+
describe("globalCommands", () => {
11+
describe("GLOBAL_COMMANDS", () => {
12+
it("should contain the /new command", () => {
13+
const newCommand = GLOBAL_COMMANDS.find((cmd) => cmd.name === "new")
14+
expect(newCommand).toBeDefined()
15+
expect(newCommand?.action).toBe("clearTask")
16+
expect(newCommand?.description).toBe("Start a new task")
17+
})
18+
19+
it("should have valid structure for all commands", () => {
20+
for (const cmd of GLOBAL_COMMANDS) {
21+
expect(cmd.name).toBeTruthy()
22+
expect(typeof cmd.name).toBe("string")
23+
expect(cmd.description).toBeTruthy()
24+
expect(typeof cmd.description).toBe("string")
25+
expect(cmd.action).toBeTruthy()
26+
expect(typeof cmd.action).toBe("string")
27+
}
28+
})
29+
})
30+
31+
describe("getGlobalCommand", () => {
32+
it("should return the command when found", () => {
33+
const cmd = getGlobalCommand("new")
34+
expect(cmd).toBeDefined()
35+
expect(cmd?.name).toBe("new")
36+
expect(cmd?.action).toBe("clearTask")
37+
})
38+
39+
it("should return undefined for unknown commands", () => {
40+
const cmd = getGlobalCommand("unknown-command")
41+
expect(cmd).toBeUndefined()
42+
})
43+
44+
it("should be case-sensitive", () => {
45+
const cmd = getGlobalCommand("NEW")
46+
expect(cmd).toBeUndefined()
47+
})
48+
})
49+
50+
describe("getGlobalCommandsForAutocomplete", () => {
51+
it("should return commands in autocomplete format", () => {
52+
const commands = getGlobalCommandsForAutocomplete()
53+
expect(commands.length).toBe(GLOBAL_COMMANDS.length)
54+
55+
for (const cmd of commands) {
56+
expect(cmd.name).toBeTruthy()
57+
expect(cmd.source).toBe("global")
58+
expect(cmd.action).toBeTruthy()
59+
}
60+
})
61+
62+
it("should include the /new command with correct format", () => {
63+
const commands = getGlobalCommandsForAutocomplete()
64+
const newCommand = commands.find((cmd) => cmd.name === "new")
65+
66+
expect(newCommand).toBeDefined()
67+
expect(newCommand?.description).toBe("Start a new task")
68+
expect(newCommand?.source).toBe("global")
69+
expect(newCommand?.action).toBe("clearTask")
70+
})
71+
72+
it("should not include argumentHint for action commands", () => {
73+
const commands = getGlobalCommandsForAutocomplete()
74+
// Action commands don't have argument hints
75+
for (const cmd of commands) {
76+
expect(cmd).not.toHaveProperty("argumentHint")
77+
}
78+
})
79+
})
80+
81+
describe("type safety", () => {
82+
it("should have valid GlobalCommandAction types", () => {
83+
// This test ensures the type is properly constrained
84+
const validActions: GlobalCommandAction[] = ["clearTask"]
85+
86+
for (const cmd of GLOBAL_COMMANDS) {
87+
expect(validActions).toContain(cmd.action)
88+
}
89+
})
90+
91+
it("should match GlobalCommand interface", () => {
92+
const testCommand: GlobalCommand = {
93+
name: "test",
94+
description: "Test command",
95+
action: "clearTask",
96+
}
97+
98+
expect(testCommand.name).toBe("test")
99+
expect(testCommand.description).toBe("Test command")
100+
expect(testCommand.action).toBe("clearTask")
101+
})
102+
})
103+
})

0 commit comments

Comments
 (0)