import { renderToStaticMarkup } from "react-dom/server"; import { ProviderDriverKind } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; import { ComposerCommandMenu, composerSuggestionOptionId } from "./ComposerCommandMenu"; describe("composerSuggestionOptionId", () => { it("keeps whitespace, escape-like paths, and malformed UTF-16 distinct", () => { const paths = [ "docs/my file.md", "docs/my_file.md", "docs/my%20file.md", "docs/my\tfile.md", "docs/\ud800.md", "docs/\ud801.md", "docs/\udc00.md", "docs/\ufffd.md", "docs/\\ud800.md", "docs/\ud83d\ude80.md", ]; const ids = paths.map((path) => composerSuggestionOptionId("suggestions", `path:file:${path}`)); expect(new Set(ids).size).toBe(paths.length); for (const id of ids) expect(id).not.toMatch(/\s|[\ud800-\udfff]/u); expect(composerSuggestionOptionId("other-composer", paths[0]!)).not.toBe( composerSuggestionOptionId("suggestions", paths[0]!), ); }); }); describe("ComposerCommandMenu", () => { it("renders slash commands with their descriptions", () => { const markup = renderToStaticMarkup( {}} onSelect={() => {}} />, ); expect(markup).toContain("/model"); expect(markup).toContain("Switch response model for this thread"); }); it("shows the app source for an app skill", () => { const markup = renderToStaticMarkup( {}} onSelect={() => {}} />, ); expect(markup).toContain("Browser"); expect(markup).toContain('data-slot="badge"'); expect(markup).toContain(">App Skill"); expect(markup).toContain("Open and control the in-app browser"); expect(markup).toContain(" { const markup = renderToStaticMarkup( {}} onSelect={() => {}} />, ); expect(markup).toContain('/skill:Ask Matt'); expect(markup).toContain('data-slot="badge"'); expect(markup).toContain("lucide-folder"); expect(markup).toContain(">Repo"); expect(markup).toContain("Find the right skill or workflow"); }); });