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

ComposerCommandMenu.test.tsx

101 lines3.1 KB

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 commands with their descriptions", () => {
9 const markup = renderToStaticMarkup(
10 <ComposerCommandMenu
11 items={[
12 {
13 id: "slash:model",
14 type: "slash-command",
15 command: "model",
16 label: "/model",
17 description: "Switch response model for this thread",
18 },
19 ]}
20 resolvedTheme="dark"
21 isLoading={false}
22 triggerKind="slash-command"
23 activeItemId="slash:model"
24 onHighlightedItemChange={() => {}}
25 onSelect={() => {}}
26 />,
27 );
28​
29 expect(markup).toContain("/model");
30 expect(markup).toContain("Switch response model for this thread");
31 });
32​
33 it("shows the app source for an app skill", () => {
34 const markup = renderToStaticMarkup(
35 <ComposerCommandMenu
36 items={[
37 {
38 id: "skill:codex:browser",
39 type: "skill",
40 provider: ProviderDriverKind.make("codex"),
41 skill: {
42 name: "browser",
43 path: "/Users/maria/.codex/plugins/browser/skills/browser/SKILL.md",
44 scope: "user",
45 enabled: true,
46 },
47 label: "Browser",
48 description: "Open and control the in-app browser",
49 },
50 ]}
51 resolvedTheme="dark"
52 isLoading={false}
53 triggerKind="skill"
54 activeItemId="skill:codex:browser"
55 onHighlightedItemChange={() => {}}
56 onSelect={() => {}}
57 />,
58 );
59​
60 expect(markup).toContain("Browser");
61 expect(markup).toContain('data-slot="badge"');
62 expect(markup).toContain(">App Skill</span>");
63 expect(markup).toContain("Open and control the in-app browser");
64 expect(markup).toContain("<svg");
65 });
66​
67 it("shows the repo source for a slash skill", () => {
68 const markup = renderToStaticMarkup(
69 <ComposerCommandMenu
70 items={[
71 {
72 id: "skill:codex:ask-matt",
73 type: "skill",
74 provider: ProviderDriverKind.make("codex"),
75 skill: {
76 name: "ask-matt",
77 displayName: "Ask Matt",
78 path: "/skills/ask-matt/SKILL.md",
79 scope: "repo",
80 enabled: true,
81 },
82 label: "/skill:ask-matt",
83 description: "Find the right skill or workflow",
84 },
85 ]}
86 resolvedTheme="dark"
87 isLoading={false}
88 triggerKind="slash-command"
89 activeItemId="skill:codex:ask-matt"
90 onHighlightedItemChange={() => {}}
91 onSelect={() => {}}
92 />,
93 );
94​
95 expect(markup).toContain('<span class="text-secondary-label">/skill:</span>Ask Matt');
96 expect(markup).toContain('data-slot="badge"');
97 expect(markup).toContain("lucide-folder");
98 expect(markup).toContain(">Repo</span>");
99 expect(markup).toContain("Find the right skill or workflow");
100 });
101});