Open History to see the last commit
1import { renderToStaticMarkup } from "react-dom/server";
2import { ProviderDriverKind } from "@t3tools/contracts";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ComposerCommandMenu } from "./ComposerCommandMenu";
6
7describe("ComposerCommandMenu", () => {
8 it("renders slash-command results as an attached composer drawer", () => {
9 const markup = renderToStaticMarkup(
10 <ComposerCommandMenu
11 items={[]}
12 resolvedTheme="dark"
13 isLoading={false}
14 triggerKind="slash-command"
15 activeItemId={null}
16 onHighlightedItemChange={() => {}}
17 onSelect={() => {}}
18 />,
19 );
20
21 expect(markup).toContain('data-composer-command-drawer="true"');
22 expect(markup).not.toContain("dropdown-glass");
23 });
24
25 it("renders commands without a category heading or invented icons", () => {
26 const markup = renderToStaticMarkup(
27 <ComposerCommandMenu
28 items={[
29 {
30 id: "slash:model",
31 type: "slash-command",
32 command: "model",
33 label: "/model",
34 description: "Switch response model for this thread",
35 },
36 ]}
37 resolvedTheme="dark"
38 isLoading={false}
39 triggerKind="slash-command"
40 activeItemId="slash:model"
41 onHighlightedItemChange={() => {}}
42 onSelect={() => {}}
43 />,
44 );
45
46 expect(markup).toContain("/model");
47 expect(markup).toContain("Switch response model for this thread");
48 expect(markup).not.toContain("Built-in");
49 expect(markup).not.toContain("<svg");
50 expect(markup).toContain("font-sans text-xs font-medium");
51 expect(markup).not.toContain("font-mono");
52 expect(markup).not.toContain("grid-cols-");
53 expect(markup).toContain("max-w-[45%]");
54 expect(markup).toContain("text-left");
55 });
56
57 it("renders the skill source icon inside its badge", () => {
58 const markup = renderToStaticMarkup(
59 <ComposerCommandMenu
60 items={[
61 {
62 id: "skill:codex:browser",
63 type: "skill",
64 provider: ProviderDriverKind.make("codex"),
65 skill: {
66 name: "browser",
67 path: "/Users/maria/.codex/plugins/browser/skills/browser/SKILL.md",
68 scope: "user",
69 enabled: true,
70 },
71 label: "Browser",
72 description: "Open and control the in-app browser",
73 },
74 ]}
75 resolvedTheme="dark"
76 isLoading={false}
77 triggerKind="skill"
78 activeItemId="skill:codex:browser"
79 onHighlightedItemChange={() => {}}
80 onSelect={() => {}}
81 />,
82 );
83
84 expect(markup).toContain("Browser");
85 expect(markup).toContain('data-slot="badge"');
86 expect(markup).toContain(">App Skill</span>");
87 expect(markup).toContain("Open and control the in-app browser");
88 expect(markup).toContain("max-w-[48ch]");
89 expect(markup).toContain("text-secondary-label text-xs");
90 expect(markup).toContain("ms-auto");
91 expect(markup).toContain("text-current");
92 expect(markup.indexOf("Open and control the in-app browser")).toBeLessThan(
93 markup.indexOf(">App Skill</span>"),
94 );
95 expect(markup).toContain("<svg");
96 expect(markup.indexOf('data-slot="badge"')).toBeLessThan(markup.indexOf("<svg"));
97 });
98
99 it("keeps slash skills aligned with the source icon inside the badge", () => {
100 const markup = renderToStaticMarkup(
101 <ComposerCommandMenu
102 items={[
103 {
104 id: "skill:codex:ask-matt",
105 type: "skill",
106 provider: ProviderDriverKind.make("codex"),
107 skill: {
108 name: "ask-matt",
109 displayName: "Ask Matt",
110 path: "/skills/ask-matt/SKILL.md",
111 scope: "repo",
112 enabled: true,
113 },
114 label: "/skill:ask-matt",
115 description: "Find the right skill or workflow",
116 },
117 ]}
118 resolvedTheme="dark"
119 isLoading={false}
120 triggerKind="slash-command"
121 activeItemId="skill:codex:ask-matt"
122 onHighlightedItemChange={() => {}}
123 onSelect={() => {}}
124 />,
125 );
126
127 expect(markup).toContain('<span class="text-secondary-label">/skill:</span>Ask Matt');
128 expect(markup).toContain('data-slot="badge"');
129 expect(markup).toContain("lucide-folder");
130 expect(markup).toContain(">Repo</span>");
131 expect(markup).toContain("Find the right skill or workflow");
132 expect(markup).not.toContain("font-medium text-secondary-label");
133 });
134});