import { highlightStepParams } from '@/lib/step-params'; import { cn } from '@/lib/utils'; import type { ReportScenario, ReportStep } from 'executable-stories-core'; import { assertionState, assertiveSteps, } from 'executable-stories-core/utils/assertive-steps'; import { formatDuration } from 'executable-stories-core/utils/duration'; import { ReportDocEntries } from './ReportDocEntries'; export interface ReportStepsProps { scenario: ReportScenario; } const STEP_GLYPH: Record = { passed: '✓', failed: '✗', skipped: '○', pending: '○', }; const STEP_GLYPH_COLOR: Record = { passed: 'text-pass', failed: 'text-fail', skipped: 'text-skip', pending: 'text-pend', }; export function ReportSteps({ scenario }: ReportStepsProps) { if (scenario.steps.length === 0) return null; const unasserted = new Set( assertionState(scenario.steps) === 'unasserted' ? assertiveSteps(scenario.steps).map((step) => step.id) : [], ); return (
    {scenario.steps.map((step) => ( ))}
); } export function ReportStepItem({ step, unasserted = false, }: { step: ReportStep; unasserted?: boolean; }) { // And/But (incl. auto-And repeats) read as continuations of the prior step — // indented with a muted keyword, matching the report's `.step.continuation`. const kw = step.keyword.toLowerCase(); const continuation = kw === 'and' || kw === 'but'; return (
  • {STEP_GLYPH[step.status] ?? '○'} {step.keyword} {highlightStepParams(step.text)} {unasserted ? ( No assertion ) : null} {step.durationMs > 0 ? ( {formatDuration(step.durationMs)} ) : null}
    {step.errorMessage ? (
              {step.errorMessage}
            
    ) : null} {step.expected !== undefined || step.actual !== undefined ? (
    {step.expected !== undefined ? ( <>
    Expected
    {step.expected}
    ) : null} {step.actual !== undefined ? ( <>
    Actual
    {step.actual}
    ) : null}
    ) : null} {step.docEntries.length > 0 ? (
    ) : null}
  • ); }