import type { Component } from 'solid-js' import type { ConsoleEntry, TestNode } from '~/components/types' import { createMemo, For, Show } from 'solid-js' import { StatusIcon } from '~/components' import { formatDuration, getAggregateStatus } from '~/components/utils' import { ansiToHtml } from '~/utils/ansi' export interface TestDetailsProps { test: TestNode tests: Record consoleEntries?: ConsoleEntry[] onNavigate: (id: string | null) => void } const TestDetails: Component = (props) => { const breadcrumb = createMemo(() => { const path: Array<{ id: string, name: string }> = [] let current: TestNode | undefined = props.test while (current) { path.unshift({ id: current.id, name: current.name }) current = current.parentId ? props.tests[current.parentId] : undefined } return path }) const filteredConsole = createMemo(() => { return (props.consoleEntries ?? []).filter(e => e.testId === props.test.id) }) const fileLocation = createMemo(() => { if (!props.test.url) return null const line = props.test.line !== undefined ? `:${props.test.line}` : '' return `${props.test.url}${line}` }) const statusColors: Record = { passed: { bg: 'bg-emerald-500/10', text: 'text-emerald-400', border: 'border-emerald-500/20' }, failed: { bg: 'bg-red-500/10', text: 'text-red-400', border: 'border-red-500/20' }, timeout: { bg: 'bg-red-500/10', text: 'text-red-400', border: 'border-red-500/20' }, skipped: { bg: 'bg-gray-500/10', text: 'text-gray-400', border: 'border-gray-500/20' }, todo: { bg: 'bg-violet-500/10', text: 'text-violet-400', border: 'border-violet-500/20' }, running: { bg: 'bg-amber-500/10', text: 'text-amber-400', border: 'border-amber-500/20' }, idle: { bg: 'bg-gray-500/10', text: 'text-gray-500', border: 'border-gray-500/20' }, } const status = createMemo(() => getAggregateStatus(props.test, props.tests)) const colors = createMemo(() => statusColors[status()] ?? statusColors.idle!, ) const childErrors = createMemo(() => { if (props.test.type !== 'describe') return [] return props.test.children .map(id => props.tests[id]) .filter((child): child is TestNode => Boolean(child?.error)) }) return (

{props.test.name}

{props.test.duration !== undefined ? formatDuration(props.test.duration) : '\u00A0'}

1}>
Type: {props.test.type}
Status: {status()}
File: {fileLocation()}
Duration: {formatDuration(props.test.duration)}

Error

0}>

Console Output {filteredConsole().length} {' '} entries

{entry => (
{entry.level}
)}
0}>

Tests ( {props.test.children.length} )

{(childId) => { const child = () => props.tests[childId] return ( ) }}
0}>

Errors ( {childErrors().length} )

{child => (
)}
) } export default TestDetails