Skip to content

Commit 0bdeca3

Browse files
committed
Add a test
1 parent 3d818d2 commit 0bdeca3

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

src/schemas/__tests__/index.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// npx jest src/schemas/__tests__/index.test.ts
22

3-
import { GLOBAL_STATE_KEYS } from "../index"
3+
import { contributes } from "../../../package.json"
4+
5+
import { GLOBAL_STATE_KEYS, Package, codeActionIds, terminalActionIds, commandIds } from "../index"
46

57
describe("GLOBAL_STATE_KEYS", () => {
68
it("should contain provider settings keys", () => {
@@ -15,3 +17,25 @@ describe("GLOBAL_STATE_KEYS", () => {
1517
expect(GLOBAL_STATE_KEYS).not.toContain("openRouterApiKey")
1618
})
1719
})
20+
21+
describe("package.json#contributes", () => {
22+
it("is in sync with the schema's commands", () => {
23+
// These aren't explicitly referenced in package.json despite
24+
// being registered by the extension.
25+
const absent = new Set([
26+
"activationCompleted",
27+
"showHumanRelayDialog",
28+
"registerHumanRelayCallback",
29+
"unregisterHumanRelayCallback",
30+
"handleHumanRelayResponse",
31+
])
32+
33+
// This test will notify us if package.json drifts from the schema.
34+
expect(contributes.commands.map((command) => command.command).sort()).toEqual(
35+
[...new Set([...commandIds, ...terminalActionIds, ...codeActionIds])]
36+
.filter((id) => !absent.has(id))
37+
.map((id) => `${Package.name}.${id}`)
38+
.sort(),
39+
)
40+
})
41+
})

src/schemas/index.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,49 @@ export const Package = {
2929
* CodeAction
3030
*/
3131

32-
export type CodeActionName = "EXPLAIN" | "FIX" | "IMPROVE" | "ADD_TO_CONTEXT" | "NEW_TASK"
32+
export const codeActionIds = ["explainCode", "fixCode", "improveCode", "addToContext", "newTask"] as const
33+
34+
export type CodeActionId = (typeof codeActionIds)[number]
3335

34-
export type CodeActionId = "explainCode" | "fixCode" | "improveCode" | "addToContext" | "newTask"
36+
export type CodeActionName = "EXPLAIN" | "FIX" | "IMPROVE" | "ADD_TO_CONTEXT" | "NEW_TASK"
3537

3638
/**
3739
* TerminalAction
3840
*/
3941

42+
export const terminalActionIds = ["terminalAddToContext", "terminalFixCommand", "terminalExplainCommand"] as const
43+
44+
export type TerminalActionId = (typeof terminalActionIds)[number]
45+
4046
export type TerminalActionName = "ADD_TO_CONTEXT" | "FIX" | "EXPLAIN"
4147

4248
export type TerminalActionPromptType = `TERMINAL_${TerminalActionName}`
4349

44-
export type TerminalActionId = "terminalAddToContext" | "terminalFixCommand" | "terminalExplainCommand"
45-
4650
/**
4751
* Command
4852
*/
4953

50-
const commandIds = [
54+
export const commandIds = [
5155
"activationCompleted",
56+
5257
"plusButtonClicked",
53-
"mcpButtonClicked",
5458
"promptsButtonClicked",
59+
"mcpButtonClicked",
60+
"historyButtonClicked",
5561
"popoutButtonClicked",
56-
"openInNewTab",
5762
"settingsButtonClicked",
58-
"historyButtonClicked",
63+
64+
"openInNewTab",
65+
5966
"showHumanRelayDialog",
6067
"registerHumanRelayCallback",
6168
"unregisterHumanRelayCallback",
6269
"handleHumanRelayResponse",
70+
6371
"newTask",
72+
6473
"setCustomStoragePath",
74+
6575
"focusInput",
6676
"acceptInput",
6777
] as const

0 commit comments

Comments
 (0)