From 6755c8017286060fb78df43fb37f0449aefa95d1 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 5 Feb 2025 21:04:04 -0800 Subject: [PATCH] chore(html-report): total duration should be selected run duration for test case --- .../html-reporter/src/testCaseView.spec.tsx | 33 +++++++++++++++++-- packages/html-reporter/src/testCaseView.tsx | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/html-reporter/src/testCaseView.spec.tsx b/packages/html-reporter/src/testCaseView.spec.tsx index 7cc9f8991c..183d44c019 100644 --- a/packages/html-reporter/src/testCaseView.spec.tsx +++ b/packages/html-reporter/src/testCaseView.spec.tsx @@ -59,7 +59,7 @@ const testCase: TestCase = { ], tags: [], outcome: 'expected', - duration: 10, + duration: 200, ok: true, results: [result] }; @@ -212,6 +212,35 @@ test('should correctly render prev and next', async ({ mount }) => { - text: group - link "« previous" - link "next »" - - text: "My test test.spec.ts:42 10ms" + - text: "My test test.spec.ts:42 100ms" + `); +}); + + +const testCaseWithTwoAttempts: TestCase = { + ...testCase, + results: [ + { + ...result, + errors: ['Error message'], + status: 'failed', + duration: 50, + }, + { + ...result, + duration: 150, + status: 'passed', + }, + ], +}; + +test('total duration is selected run duration', async ({ mount, page }) => { + const component = await mount(); + await expect(component).toMatchAriaSnapshot(` + - text: "My test test.spec.ts:42 50ms" + `); + await page.getByText('Retry #1').click(); + await expect(component).toMatchAriaSnapshot(` + - text: "My test test.spec.ts:42 150ms" `); }); diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx index e4ffa9c15b..bbd0d7ad13 100644 --- a/packages/html-reporter/src/testCaseView.tsx +++ b/packages/html-reporter/src/testCaseView.tsx @@ -65,7 +65,7 @@ export const TestCaseView: React.FC<{
-
{msToString(test.duration)}
+
{msToString(test.results[selectedResultIndex]?.duration ?? test.duration)}
} {test && (!!test.projectName || labels) &&
{test && !!test.projectName && }