diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx index 0e966ed0de..91d1847d49 100644 --- a/packages/html-reporter/src/testCaseView.tsx +++ b/packages/html-reporter/src/testCaseView.tsx @@ -14,7 +14,7 @@ limitations under the License. */ -import type { TestCase } from './types'; +import type { TestCase, TestCaseAnnotation } from './types'; import * as React from 'react'; import { TabbedPane } from './tabbedPane'; import { AutoChip } from './chip'; @@ -33,12 +33,6 @@ export const TestCaseView: React.FC<{ }> = ({ projectNames, test, run, anchor }) => { const [selectedResultIndex, setSelectedResultIndex] = React.useState(run); - const annotations = new Map(); - test?.annotations.forEach(annotation => { - const list = annotations.get(annotation.type) || []; - list.push(annotation.description); - annotations.set(annotation.type, list); - }); const labels = React.useMemo(() => { if (!test) return undefined; @@ -50,11 +44,11 @@ export const TestCaseView: React.FC<{ {test &&
{test?.title}
} {test &&
{test.location.file}:{test.location.line}
} {test && (!!test.projectName || labels) &&
- {!!test.projectName && } + {test && !!test.projectName && } {labels && }
} - {annotations.size > 0 && - {[...annotations].map(annotation => )} + {test && !!test.annotations.length && + {test?.annotations.map(annotation => )} } {test && ({ @@ -73,17 +67,11 @@ function renderAnnotationDescription(description: string) { return description; } -function TestCaseAnnotationView({ type, descriptions }: { type: string, descriptions: (string | undefined)[] }) { - const filteredDescriptions = descriptions.filter(Boolean) as string[]; +function TestCaseAnnotationView({ annotation: { type, description } }: { annotation: TestCaseAnnotation }) { return (
{type} - {!!filteredDescriptions.length && : {filteredDescriptions.map((d, i) => { - const rendered = renderAnnotationDescription(d); - if (i < filteredDescriptions.length - 1) - return <>{rendered}, ; - return rendered; - })}} + {description && : {renderAnnotationDescription(description)}}
); } diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index bff5a35ed2..17560a5874 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -602,11 +602,6 @@ test('should render annotations', async ({ runInlineTest, page, showReport }) => 'a.test.js': ` import { test, expect } from '@playwright/test'; test('skipped test', async ({ page }) => { - test.info().annotations.push({ type: 'issue', description: '#123'}); - test.info().annotations.push({ type: 'issue', description: '#456'}); - test.info().annotations.push({ type: 'issue', description: 'https://playwright.dev'}); - test.info().annotations.push({ type: 'issue' }); - test.info().annotations.push({ type: 'empty' }); test.skip(true, 'I am not interested in this test'); }); `, @@ -616,11 +611,7 @@ test('should render annotations', async ({ runInlineTest, page, showReport }) => await showReport(); await page.click('text=skipped test'); - await expect(page.locator('.test-case-annotation')).toHaveText([ - 'issue: #123, #456, https://playwright.dev', - 'empty', - 'skip: I am not interested in this test', - ]); + await expect(page.locator('.test-case-annotation')).toHaveText('skip: I am not interested in this test'); }); test('should render annotations as link if needed', async ({ runInlineTest, page, showReport, server }) => {