chore(html-report): total duration should be selected run duration for test case

This commit is contained in:
Yury Semikhatsky 2025-02-05 21:04:04 -08:00
parent 4b64c47a25
commit 6755c80172
2 changed files with 32 additions and 3 deletions

View file

@ -59,7 +59,7 @@ const testCase: TestCase = {
], ],
tags: [], tags: [],
outcome: 'expected', outcome: 'expected',
duration: 10, duration: 200,
ok: true, ok: true,
results: [result] results: [result]
}; };
@ -212,6 +212,35 @@ test('should correctly render prev and next', async ({ mount }) => {
- text: group - text: group
- link "« previous" - link "« previous"
- link "next »" - 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(<TestCaseView projectNames={['chromium', 'webkit']} test={testCaseWithTwoAttempts} prev={undefined} next={undefined} run={0}></TestCaseView>);
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"
`); `);
}); });

View file

@ -65,7 +65,7 @@ export const TestCaseView: React.FC<{
</CopyToClipboardContainer> </CopyToClipboardContainer>
</div> </div>
<div style={{ flex: 'auto' }}></div> <div style={{ flex: 'auto' }}></div>
<div className='test-case-duration'>{msToString(test.duration)}</div> <div className='test-case-duration'>{msToString(test.results[selectedResultIndex]?.duration ?? test.duration)}</div>
</div>} </div>}
{test && (!!test.projectName || labels) && <div className='test-case-project-labels-row'> {test && (!!test.projectName || labels) && <div className='test-case-project-labels-row'>
{test && !!test.projectName && <ProjectLink projectNames={projectNames} projectName={test.projectName}></ProjectLink>} {test && !!test.projectName && <ProjectLink projectNames={projectNames} projectName={test.projectName}></ProjectLink>}