import { useState } from "react"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; export type ExplorerStatus = "passed" | "failed" | "skipped" | "pending"; export interface ExplorerScenario { id: string; title: string; status: ExplorerStatus; tags: string[]; /** Source file / feature label shown on the right. */ feature: string; /** Resolved href to the scenario detail page. */ href: string; } export interface ScenarioExplorerProps { scenarios: ExplorerScenario[]; summary?: { total: number; passed: number; failed: number }; } const STATUS_FILTERS: Array<{ value: "all" | ExplorerStatus; label: string }> = [ { value: "all", label: "All" }, { value: "passed", label: "Passed" }, { value: "failed", label: "Failed" }, { value: "skipped", label: "Skipped" }, { value: "pending", label: "Pending" }, ]; /** * Scenario Explorer surface — a shadcn `Command` palette rendered inline. cmdk * filters by the item value (title + feature + tags) as you type; the status * pills pre-filter the list. Each row is a real `` to the detail page. */ export function ScenarioExplorer({ scenarios, summary }: ScenarioExplorerProps) { const [status, setStatus] = useState<"all" | ExplorerStatus>("all"); const visible = status === "all" ? scenarios : scenarios.filter((s) => s.status === status); return (
{summary ? (

{summary.total} scenarios · {summary.passed} passed ·{" "} {summary.failed} failed

) : null}
{STATUS_FILTERS.map((f) => ( ))}
(value.toLowerCase().includes(search.toLowerCase()) ? 1 : 0)} > No scenarios match your filters. {visible.map((s) => (
{s.status} {s.title} {s.tags.slice(0, 3).map((t) => ( {t} ))} {s.feature} ))}
); }