import { CheckCircleFilled, ClockCircleOutlined, CloseCircleFilled, MinusCircleOutlined, WarningFilled, } from '@ant-design/icons'; import type { TestRunReportStep } from '@midscene/core'; import { useMemo } from 'react'; import type { ReportIssues } from './issues'; import { getStepDisplayName, isStepTimeout } from './model'; import { buildYamlSource } from './yaml-source'; export function ExecutionYaml({ source, steps, caseIndex, issues, onSelect, }: { source: string; steps: readonly TestRunReportStep[]; caseIndex: number; issues?: ReportIssues['nodes']; onSelect(step: TestRunReportStep): void; }) { const { lines, valid } = useMemo( () => buildYamlSource(source, steps, caseIndex), [source, steps, caseIndex], ); const status = (step: TestRunReportStep) => isStepTimeout(step) ? { label: 'Timeout', tone: 'timeout', icon: } : step.status === 'success' ? { label: 'Success', tone: 'success', icon: } : step.status === 'failed' ? { label: 'Failed', tone: 'failed', icon: } : { label: 'Not run', tone: 'not-run', icon: , }; const label = (step: TestRunReportStep) => `${status(step).label}: ${getStepDisplayName(step)}. View step details`; return ( <> {!valid ? (

Step markers are unavailable because the captured YAML is incomplete or invalid.

) : null}
        
          {lines.map((line) => (
            
              
              
                {line.tokens.flatMap(({ step }) => {
                  if (!step) return [];
                  const warning = issues
                    ?.get(step.id)
                    ?.some((issue) => issue.severity === 'warning');
                  const meta = status(step);
                  const description = `${label(step)}${warning ? ' (with warnings)' : ''}`;
                  return [
                    ,
                  ];
                })}
              
              
                {line.tokens.map((token, index) =>
                  token.step ? (
                    
                  ) : (
                    
                      {token.text}
                    
                  ),
                )}
              
            
          ))}
        
      
); }