Skip to content

Commit

Permalink
feat(html-reporter): add file name copy button (#32652)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Sep 17, 2024
1 parent f6219e6 commit c216c25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/html-reporter/src/testCaseView.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
flex: none;
align-items: center;
padding: 0 8px 8px;
line-height: 24px;
}

.test-case-path {
Expand Down
6 changes: 3 additions & 3 deletions packages/html-reporter/src/testCaseView.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 5 additions & 1 deletion packages/html-reporter/src/testCaseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>}
Expand Down

0 comments on commit c216c25

Please sign in to comment.