Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

composerSlashCommandSearch.test.ts

68 lines2.2 KB

1import { describe, expect, it } from "vitest";
2​
3import type { ComposerCommandItem } from "./ComposerCommandMenu";
4import { searchSlashCommandItems } from "./composerSlashCommandSearch";
5​
6describe("searchSlashCommandItems", () => {
7 it("moves exact provider command matches ahead of broader description matches", () => {
8 const items = [
9 {
10 id: "slash:default",
11 type: "slash-command",
12 command: "default",
13 label: "/default",
14 description: "Switch this thread back to normal build mode",
15 },
16 {
17 id: "provider-slash-command:claudeAgent:ui",
18 type: "provider-slash-command",
19 provider: "claudeAgent",
20 command: { name: "ui" },
21 label: "/ui",
22 description: "Explore, build, and refine UI.",
23 },
24 {
25 id: "provider-slash-command:claudeAgent:frontend-design",
26 type: "provider-slash-command",
27 provider: "claudeAgent",
28 command: { name: "frontend-design" },
29 label: "/frontend-design",
30 description: "Create distinctive, production-grade frontend interfaces",
31 },
32 ] satisfies Array<
33 Extract<ComposerCommandItem, { type: "slash-command" | "provider-slash-command" }>
34 >;
35​
36 expect(searchSlashCommandItems(items, "ui").map((item) => item.id)).toEqual([
37 "provider-slash-command:claudeAgent:ui",
38 "slash:default",
39 ]);
40 });
41​
42 it("supports fuzzy provider command matches", () => {
43 const items = [
44 {
45 id: "provider-slash-command:claudeAgent:gh-fix-ci",
46 type: "provider-slash-command",
47 provider: "claudeAgent",
48 command: { name: "gh-fix-ci" },
49 label: "/gh-fix-ci",
50 description: "Fix failing GitHub Actions",
51 },
52 {
53 id: "provider-slash-command:claudeAgent:github",
54 type: "provider-slash-command",
55 provider: "claudeAgent",
56 command: { name: "github" },
57 label: "/github",
58 description: "General GitHub help",
59 },
60 ] satisfies Array<
61 Extract<ComposerCommandItem, { type: "slash-command" | "provider-slash-command" }>
62 >;
63​
64 expect(searchSlashCommandItems(items, "gfc").map((item) => item.id)).toEqual([
65 "provider-slash-command:claudeAgent:gh-fix-ci",
66 ]);
67 });
68});