import { readFileSync } from 'node:fs'; import { describe, expect, it } from '@rstest/core'; const statusStyles = readFileSync( new URL('./status-badge.less', import.meta.url), 'utf8', ); const baseStyles = readFileSync( new URL('./index.less', import.meta.url), 'utf8', ); const tokenStyles = readFileSync( new URL('./tokens.less', import.meta.url), 'utf8', ); const figmaEvidenceStyles = readFileSync( new URL('./figma-evidence.less', import.meta.url), 'utf8', ); const figmaDetailStyles = readFileSync( new URL('./figma-detail.less', import.meta.url), 'utf8', ); const figmaOverviewStyles = readFileSync( new URL('./figma-overview.less', import.meta.url), 'utf8', ); const figmaShellStyles = readFileSync( new URL('./figma-shell.less', import.meta.url), 'utf8', ); const source = readFileSync(new URL('./index.tsx', import.meta.url), 'utf8'); const breakdown = readFileSync( new URL('./project-breakdown.tsx', import.meta.url), 'utf8', ); const inspector = readFileSync( new URL('./evidence-inspector.tsx', import.meta.url), 'utf8', ); const workspace = readFileSync( new URL('./case-workspace.tsx', import.meta.url), 'utf8', ); const executionPanel = readFileSync( new URL('./execution-panel.tsx', import.meta.url), 'utf8', ); const filters = readFileSync( new URL('./case-filters.tsx', import.meta.url), 'utf8', ); const header = readFileSync( new URL('./case-workspace-header.tsx', import.meta.url), 'utf8', ); const attemptSelect = readFileSync( new URL('./attempt-select.tsx', import.meta.url), 'utf8', ); const select = readFileSync(new URL('./select.tsx', import.meta.url), 'utf8'); const selectStyles = readFileSync( new URL('./select.less', import.meta.url), 'utf8', ); const appSource = readFileSync( new URL('../../App.tsx', import.meta.url), 'utf8', ); describe('Midscene Test report layout', () => { it('uses themed brand artwork without repeating its report title', () => { expect(source).toContain('alt="Midscene.js Test Report"'); expect(source).toContain( 'src={isDarkMode ? reportLogoDark : reportLogoLight}', ); expect(source).not.toContain('Test Report'); expect(source).toContain('className="runner-header-inner"'); expect(source).toContain('Midscene {midsceneVersion}'); expect(source).toContain('report.get().sdkVersion.trim()'); expect(source).toContain('aria-label="Test report content"'); expect(source).not.toContain('Midscene Test Report'); expect(source).not.toContain('Test Runner'); }); it('uses the shared status tag spacing', () => { expect(statusStyles).toMatch( /\.runner-status-badge\.runner-status-pill\s*\{[^}]*min-height: 24px;[^}]*padding: 4px 8px;[^}]*border-radius: 8px;/s, ); }); it('uses the report status palette and aligned attempt tag spacing', () => { for (const token of [ '--runner-danger: #e53f39;', '--runner-danger-soft: #feece9;', '--runner-warning: #d97906;', '--runner-warning-soft: #fff0d6;', '--runner-success: #2d9b44;', '--runner-success-soft: #edf8ef;', ]) { expect(tokenStyles).toContain(token); } expect(attemptSelect).toContain('optionLabelProp="label"'); expect(attemptSelect).toContain('popupMatchSelectWidth'); expect(figmaDetailStyles).not.toContain( '.runner-attempt-select-shell > span.is-', ); expect(selectStyles).toMatch( /\.runner-status-badge\.runner-status-pill\.runner-attempt-option-status\s*\{[^}]*box-sizing: border-box;[^}]*width: 60px;[^}]*height: 24px;[^}]*min-height: 24px;[^}]*padding: 0 8px;/s, ); expect(selectStyles).toMatch( /\.runner-attempt-option-status\.is-success\s*\{[^}]*color: var\(--runner-success, #2d9b44\);[^}]*background: var\(--runner-success-soft, #edf8ef\);/s, ); expect(selectStyles).toMatch( /\.runner-attempt-option-status\.is-failed\s*\{[^}]*color: var\(--runner-danger, #e53f39\);[^}]*background: var\(--runner-danger-soft, #feece9\);/s, ); expect(select).toContain("closest('.test-runner-report')"); expect(selectStyles).toMatch( /\.runner-select-chevron\s*\{[^}]*width: 15px;[^}]*height: 15px;[^}]*mask: url\('\.\/assets\/overview-chevron-down.svg'\)/s, ); }); it('opens a Case at its failed Step from the row', () => { expect(breakdown).toContain('className="runner-case-open"'); expect(breakdown).toContain('onClick={() => onOpen(item, failure?.id)}'); }); it('keeps File and Case metrics aligned in semantic tables', () => { expect(breakdown).toContain('
/,
);
expect(inspector).toContain('className="runner-detail-tabs-row"');
expect(figmaEvidenceStyles).toMatch(
/\.runner-detail-evidence-heading \.runner-detail-step-description\s*\{/,
);
});
it('keeps the embedded trace resizable without a separate page action', () => {
expect(inspector).not.toContain('Open AI trace in new tab');
expect(inspector).not.toContain('target="_blank"');
expect(appSource).toContain('aria-label="Resize report sidebar"');
expect(appSource).toContain('clampSidebarWidth(');
expect(figmaEvidenceStyles).toMatch(
/\.runner-detail-inline-trace \.main-layout > \.resize-handle\s*\{[^}]*display: block;[^}]*width: 8px;/s,
);
expect(figmaEvidenceStyles).not.toMatch(
/\.runner-detail-inline-trace \.main-layout > \.resize-handle\s*\{[^}]*display: none;/s,
);
});
it('reserves trace height while switching tabs to prevent page jumps', () => {
expect(inspector).toContain('stabilizeContentHeight={hasAgentTrace}');
expect(figmaEvidenceStyles).toMatch(
/\.runner-detail-inspector-content\.has-stable-trace-height\s*\{[^}]*min-height: 864px;/s,
);
});
it('shows a large timeline preview and keeps one frame paired with the selected step', () => {
const timeline = readFileSync(
new URL('./attempt-timeline.tsx', import.meta.url),
'utf8',
);
expect(timeline).toContain('Hover to preview');
expect(timeline).toContain(
'{formatTimelineTime(previewFrame.offsetMs)}',
);
expect(timeline).not.toContain('click to lock');
expect(timeline).toContain('onClick={() => onSelectFrame(item)}');
expect(timeline).toContain('aria-pressed={isSelected}');
expect(timeline).toContain('runner-detail-timeline-preview-callout');
expect(timeline).toContain('resolveTimelinePreviewPlacement');
expect(baseStyles).toMatch(
/\.runner-detail-timeline-preview-callout\.is-above\s*\{[^}]*bottom: calc\(100% \+ 8px\);/s,
);
expect(timeline).toContain('previewFrame.frame.screenshot.base64');
expect(timeline).toContain('item.stepId === selectedStepId');
});
it('draws keyboard focus inside step rows so scrolling cannot clip the ring', () => {
expect(figmaDetailStyles).toMatch(
/\.runner-detail-step-list > button:focus-visible\s*\{[^}]*outline: 2px solid var\(--runner-primary\);[^}]*outline-offset: -2px;/s,
);
});
it('keeps the interactive timeline visible inside Execution', () => {
expect(workspace).toContain('