From e2f9bfb69e22b80ae1bd51bfb15c459651859f7f Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 28 Mar 2024 23:16:38 +0530 Subject: [PATCH] Write test cases for copy annotation text feature --- packages/html-reporter/src/copyToClipboard.tsx | 2 +- packages/html-reporter/src/testCaseView.css | 4 ++-- packages/html-reporter/src/testCaseView.spec.tsx | 8 +++++++- packages/html-reporter/src/testCaseView.tsx | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/html-reporter/src/copyToClipboard.tsx b/packages/html-reporter/src/copyToClipboard.tsx index a24015a671..85132a40df 100644 --- a/packages/html-reporter/src/copyToClipboard.tsx +++ b/packages/html-reporter/src/copyToClipboard.tsx @@ -34,5 +34,5 @@ export const CopyToClipboard: React.FunctionComponent<{ }); }, [value]); const iconElement = icon === 'check' ? icons.check() : icon === 'cross' ? icons.cross() : icons.copy(); - return ; + return ; }; diff --git a/packages/html-reporter/src/testCaseView.css b/packages/html-reporter/src/testCaseView.css index b7727a5a8c..93e26a9b79 100644 --- a/packages/html-reporter/src/testCaseView.css +++ b/packages/html-reporter/src/testCaseView.css @@ -75,12 +75,12 @@ flex-wrap: wrap; } -#annotation-copy-button{ +.annotation-copy-button{ padding-left: 3px; display: none; } -.test-case-annotation:hover #annotation-copy-button{ +.test-case-annotation:hover .annotation-copy-button{ padding-left: 3px; display: inline; } \ No newline at end of file diff --git a/packages/html-reporter/src/testCaseView.spec.tsx b/packages/html-reporter/src/testCaseView.spec.tsx index 28fe8247f5..94d37ec570 100644 --- a/packages/html-reporter/src/testCaseView.spec.tsx +++ b/packages/html-reporter/src/testCaseView.spec.tsx @@ -64,7 +64,13 @@ const testCase: TestCase = { test('should render test case', async ({ mount }) => { const component = await mount(); - await expect(component.getByText('Annotation text', { exact: false }).first()).toBeVisible(); + const firstAnnotationElement = component.getByText('Annotation text', { exact: false }).first(); + await expect(firstAnnotationElement).toBeVisible(); + await expect(component.getByRole('button', { name: 'copy to clipboard' }).first()).not.toBeVisible(); + await expect(component.getByRole('button', { name: 'copy to clipboard' }).nth(1)).not.toBeVisible(); + await firstAnnotationElement.hover(); + await expect(component.getByRole('button', { name: 'copy to clipboard' }).first()).toBeVisible(); + await expect(component.getByRole('button', { name: 'copy to clipboard' }).nth(1)).not.toBeVisible(); await component.getByText('Annotations').click(); await expect(component.getByText('Annotation text')).not.toBeVisible(); await expect(component.getByText('Outer step')).toBeVisible(); diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx index 76ff9b3533..0c8dcf981a 100644 --- a/packages/html-reporter/src/testCaseView.tsx +++ b/packages/html-reporter/src/testCaseView.tsx @@ -78,7 +78,7 @@ function TestCaseAnnotationView({ annotation: { type, description } }: { annotat
{type} {description && : {renderAnnotationDescription(description)}} - {description && } + {description && }
); }