Files
t3code/apps/web/src/components/chat/composerSlashCommandSearch.test.ts
T
58e5f714b0 Add provider skill discovery (#1905)
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: codex <[email protected]>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
2026-04-10 17:19:23 -07:00

69 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { ComposerCommandItem } from "./ComposerCommandMenu";
import { searchSlashCommandItems } from "./composerSlashCommandSearch";
describe("searchSlashCommandItems", () => {
it("moves exact provider command matches ahead of broader description matches", () => {
const items = [
{
id: "slash:default",
type: "slash-command",
command: "default",
label: "/default",
description: "Switch this thread back to normal build mode",
},
{
id: "provider-slash-command:claudeAgent:ui",
type: "provider-slash-command",
provider: "claudeAgent",
command: { name: "ui" },
label: "/ui",
description: "Explore, build, and refine UI.",
},
{
id: "provider-slash-command:claudeAgent:frontend-design",
type: "provider-slash-command",
provider: "claudeAgent",
command: { name: "frontend-design" },
label: "/frontend-design",
description: "Create distinctive, production-grade frontend interfaces",
},
] satisfies Array<
Extract<ComposerCommandItem, { type: "slash-command" | "provider-slash-command" }>
>;
expect(searchSlashCommandItems(items, "ui").map((item) => item.id)).toEqual([
"provider-slash-command:claudeAgent:ui",
"slash:default",
]);
});
it("supports fuzzy provider command matches", () => {
const items = [
{
id: "provider-slash-command:claudeAgent:gh-fix-ci",
type: "provider-slash-command",
provider: "claudeAgent",
command: { name: "gh-fix-ci" },
label: "/gh-fix-ci",
description: "Fix failing GitHub Actions",
},
{
id: "provider-slash-command:claudeAgent:github",
type: "provider-slash-command",
provider: "claudeAgent",
command: { name: "github" },
label: "/github",
description: "General GitHub help",
},
] satisfies Array<
Extract<ComposerCommandItem, { type: "slash-command" | "provider-slash-command" }>
>;
expect(searchSlashCommandItems(items, "gfc").map((item) => item.id)).toEqual([
"provider-slash-command:claudeAgent:gh-fix-ci",
]);
});
});