Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(html-reporter): use selected run for TraceLink instead of first run (#41288)

Aditya Kumar Gupta06dff900c5b9
diff --git a/packages/html-reporter/src/links.tsx b/packages/html-reporter/src/links.tsx
index 4ef431b840..d2d0a905ff 100644
--- a/packages/html-reporter/src/links.tsx
+++ b/packages/html-reporter/src/links.tsx
@@ -132,8 +132,9 @@ export const AttachmentLink: React.FunctionComponent<{
);
};
-export const TraceLink: React.FC<{ test: TestCaseSummary, trailingSeparator?: boolean, dim?: boolean }> = ({ test, trailingSeparator, dim }) => {
- const firstTraces = test.results.map(result => result.attachments.filter(attachment => attachment.name === 'trace')).filter(traces => traces.length > 0)[0];
+export const TraceLink: React.FC<{ test: TestCaseSummary, run?: number, trailingSeparator?: boolean, dim?: boolean }> = ({ test, run, trailingSeparator, dim }) => {
+ const resultsToCheck = run !== undefined && test.results[run] ? [test.results[run]] : test.results;
+ const firstTraces = resultsToCheck.map(result => result.attachments.filter(attachment => attachment.name === 'trace')).filter(traces => traces.length > 0)[0];
if (!firstTraces)
return undefined;
diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx
index 11a031fb36..4e03ea2534 100644
--- a/packages/html-reporter/src/testCaseView.tsx
+++ b/packages/html-reporter/src/testCaseView.tsx
@@ -62,7 +62,7 @@ export const TestCaseView: React.FC<{
</CopyToClipboardContainer>
</div>
<div style={{ flex: 'auto' }}></div>
- <TraceLink test={test} trailingSeparator={true} />
+ <TraceLink test={test} run={selectedResultIndex} trailingSeparator={true} />
<div className='test-case-duration'>{msToString(test.duration)}</div>
</div>
<ProjectAndTagLabelsView style={{ marginLeft: '6px' }} projectNames={report.json().projectNames} activeProjectName={test.projectName} otherLabels={test.tags} />