{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "test-results",
  "title": "Test Results",
  "description": "A test run's pass, fail and skip counts over a filterable tree of suites, each failure open to its stack trace.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/stack-trace",
    "@kind-ui/internal-tree"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/test-results.tsx",
      "content": "\"use client\";\n\nimport { testResultsPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { TreeItemData } from \"@ui-sdk/react/tree\";\nimport { type ComponentProps, memo } from \"react\";\nimport {\n  KindTree,\n  KindTreeGroup,\n  KindTreeItem,\n  KindTreeItemIndicator,\n  KindTreeItemLabel,\n} from \"./internal/tree\";\nimport { StackTrace } from \"./stack-trace\";\n\nconst parts = createParts(testResultsPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  meta: \"span\",\n  content: \"div\",\n  filter: \"div\",\n  count: \"button\",\n  tree: \"div\",\n  item: \"span\",\n  \"item-status\": \"span\",\n  failure: \"div\",\n  empty: \"p\",\n});\n\n// Lucide \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst CHEVRON = (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" aria-hidden=\"true\">\n    <path d=\"m9 18 6-6-6-6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n);\n\nexport type TestResultsProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A test run as a step: its duration in the header, its counts beside it, which filter the tests when pressed, over a\n * tree of suites and tests in which a failed test opens to its message and stack trace. Any `children` replace the\n * default parts.\n */\nexport function TestResults({ children, ...props }: TestResultsProps) {\n  return <parts.Root {...props}>{children !== undefined ? children : DEFAULT_PARTS}</parts.Root>;\n}\n\nexport const TestResultsTrigger = parts.Trigger;\nexport const TestResultsIcon = parts.Icon;\nexport const TestResultsContent = parts.Content;\n\nexport type TestResultsTitleProps = ComponentProps<typeof parts.Title>;\n\n/** The `label`, else \"Tests\", unless you pass children. */\nexport function TestResultsTitle({ children = ({ title }) => title, ...props }: TestResultsTitleProps) {\n  return <parts.Title {...props}>{children}</parts.Title>;\n}\n\nexport type TestResultsMetaProps = ComponentProps<typeof parts.Meta>;\n\n/** The run's duration, unless you pass children. */\nexport function TestResultsMeta({ children = ({ duration }) => duration, ...props }: TestResultsMetaProps) {\n  return <parts.Meta {...props}>{children}</parts.Meta>;\n}\n\nexport type TestResultsFilterProps = ComponentProps<typeof parts.Filter>;\n\n/** Holds the counts beside the trigger: a `TestResultsCount` for passed, failed and skipped, unless you pass children. */\nexport function TestResultsFilter({ children = COUNTS, ...props }: TestResultsFilterProps) {\n  return <parts.Filter {...props}>{children}</parts.Filter>;\n}\n\nexport type TestResultsCountProps = ComponentProps<typeof parts.Count>;\n\n/**\n * A toggle button for the tests with its `value` (`\"pass\"`, `\"fail\"` or `\"skip\"`): pressing it shows only those, and\n * pressing it again shows every test. \"3 passed\", unless you pass children.\n */\nexport function TestResultsCount({ children = ({ text }) => text, ...props }: TestResultsCountProps) {\n  return <parts.Count {...props}>{children}</parts.Count>;\n}\n\nconst COUNTS = (\n  <>\n    <TestResultsCount value=\"pass\" />\n    <TestResultsCount value=\"fail\" />\n    <TestResultsCount value=\"skip\" />\n  </>\n);\n\nexport type TestResultsTreeProps = ComponentProps<typeof parts.Tree>;\n\n/** The suites and tests as a UI SDK Tree, with a row for each, unless you pass children. */\nexport function TestResultsTree({\n  children = (tree) => (\n    <KindTree {...tree}>\n      <TestResultsRows items={tree.items} />\n    </KindTree>\n  ),\n  ...props\n}: TestResultsTreeProps) {\n  return <parts.Tree {...props}>{children}</parts.Tree>;\n}\n\n// Every row has an indicator, a passed or skipped test's an empty spacer that lines its name up with the others. It's\n// hidden from agents, which hides UI SDK's Tree from them while the rows stay the Test Results'.\nexport type TestResultsRowsProps = { items: TreeItemData[] };\n\n/** A Tree row for each item: a suite holds its tests, and a failed test its `TestResultsFailure`. */\nexport function TestResultsRows({ items }: TestResultsRowsProps) {\n  return items.map((item) => <TestResultsRow key={item.value} item={item} />);\n}\n\n// Memoized by item, which core keeps while the host keeps its suite, so a streamed test renders only its suite's rows.\nconst TestResultsRow = memo(function TestResultsRow({ item }: { item: TreeItemData }) {\n  return (\n    <KindTreeItem value={item.value}>\n      <KindTreeItemLabel>\n        <KindTreeItemIndicator data-agent-hidden=\"\">{item.children ? CHEVRON : null}</KindTreeItemIndicator>\n        <TestResultsItem value={item.value} />\n      </KindTreeItemLabel>\n      {item.children ? (\n        <KindTreeGroup>\n          {item.children.length > 0 ? (\n            <TestResultsRows items={item.children} />\n          ) : (\n            <TestResultsFailure value={item.value} />\n          )}\n        </KindTreeGroup>\n      ) : null}\n    </KindTreeItem>\n  );\n});\n\nexport type TestResultsItemProps = ComponentProps<typeof parts.Item>;\n\n/**\n * A row's name and its status mark, unless you pass children. Its `value` is the suite's id or the test's\n * `suiteId/testId`. The duration is drawn after them.\n */\nexport function TestResultsItem({\n  children = ({ name }) => (\n    <>\n      <span data-test-results-name=\"\">{name}</span> <TestResultsItemStatus />\n    </>\n  ),\n  ...props\n}: TestResultsItemProps) {\n  return <parts.Item {...props}>{children}</parts.Item>;\n}\n\nexport type TestResultsItemStatusProps = ComponentProps<typeof parts.ItemStatus>;\n\n/** A row's status mark, read as its status and duration, like \"failed, 12 ms\". */\nexport function TestResultsItemStatus(props: TestResultsItemStatusProps) {\n  return <parts.ItemStatus {...props} />;\n}\n\nexport type TestResultsFailureProps = ComponentProps<typeof parts.Failure>;\n\n/** A failed test's message and stack trace, as a Stack Trace, unless you pass children. Its `value` is the test's. */\nexport function TestResultsFailure({\n  children = ({ message, stack, motion }) => (\n    <StackTrace message={message || undefined} stack={stack} autoOpen=\"never\" motion={motion} />\n  ),\n  ...props\n}: TestResultsFailureProps) {\n  return <parts.Failure {...props}>{children}</parts.Failure>;\n}\n\nexport type TestResultsEmptyProps = ComponentProps<typeof parts.Empty>;\n\n/** What shows when the filter lets no test through, like \"No failed tests\", unless you pass children. */\nexport function TestResultsEmpty({ children = ({ text }) => text, ...props }: TestResultsEmptyProps) {\n  return <parts.Empty {...props}>{children}</parts.Empty>;\n}\n\nconst DEFAULT_PARTS = (\n  <>\n    <TestResultsTrigger>\n      <TestResultsIcon />\n      <TestResultsTitle />\n      <TestResultsMeta />\n    </TestResultsTrigger>\n    <TestResultsFilter />\n    <TestResultsContent>\n      <div data-test-results-panel=\"\">\n        <TestResultsTree />\n        <TestResultsEmpty />\n      </div>\n    </TestResultsContent>\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/test-results.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
