feat(html-reporter): add file name copy button (#32652)

This commit is contained in:
Max Schmitt 2024-09-17 15:54:22 +02:00 committed by GitHub
parent f6219e6e79
commit c216c25a1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -47,6 +47,7 @@
flex: none;
align-items: center;
padding: 0 8px 8px;
line-height: 24px;
}
.test-case-path {

View File

@ -81,9 +81,9 @@ test('should render copy buttons for annotations', async ({ mount, page, context
const component = await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={testCase} run={0} anchor=''></TestCaseView>);
await expect(component.getByText('Annotation text', { exact: false }).first()).toBeVisible();
component.getByText('Annotation text', { exact: false }).first().hover();
await expect(component.getByLabel('Copy to clipboard').first()).toBeVisible();
await component.getByLabel('Copy to clipboard').first().click();
await component.getByText('Annotation text', { exact: false }).first().hover();
await expect(component.locator('.test-case-annotation').getByLabel('Copy to clipboard').first()).toBeVisible();
await component.locator('.test-case-annotation').getByLabel('Copy to clipboard').first().click();
const handle = await page.evaluateHandle(() => navigator.clipboard.readText());
const clipboardContent = await handle.jsonValue();
expect(clipboardContent).toBe('Annotation text');

View File

@ -50,7 +50,11 @@ export const TestCaseView: React.FC<{
{test && <div className='test-case-path'>{test.path.join(' ')}</div>}
{test && <div className='test-case-title'>{test?.title}</div>}
{test && <div className='hbox'>
<div className='test-case-location'>{test.location.file}:{test.location.line}</div>
<div className='test-case-location'>
<CopyToClipboardContainer value={`${test?.location.file}:${test?.location.line}`}>
{test.location.file}:{test.location.line}
</CopyToClipboardContainer>
</div>
<div style={{ flex: 'auto' }}></div>
<div className='test-case-duration'>{msToString(test.duration)}</div>
</div>}