Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(html): dont show empty project label (#39966)

Simon Knott3c43adfd23af
diff --git a/packages/html-reporter/src/labels.tsx b/packages/html-reporter/src/labels.tsx
index 9aa52487cb..044e9ea074 100644
--- a/packages/html-reporter/src/labels.tsx
+++ b/packages/html-reporter/src/labels.tsx
@@ -46,8 +46,8 @@ export const ProjectAndTagLabelsView: React.FC<{
// We can have an empty project name if we have no projects specified in the config
const hasProjectNames = projectNames.length > 0 && !!activeProjectName;
- return (hasProjectNames || otherLabels.length > 0) && <span className='label-row' style={style ?? {}}>
- <ProjectLink projectNames={projectNames} projectName={activeProjectName} />
+ return (hasProjectNames || otherLabels.length > 0) && <span className='label-row' style={style}>
+ {hasProjectNames && <ProjectLink projectNames={projectNames} projectName={activeProjectName} />}
<LabelsClickView labels={otherLabels} />
</span>;
};
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index 6631f7071e..bbc7230cd9 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -1768,7 +1768,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
const result = await runInlineTest({
'a.test.js': `
const { expect, test } = require('@playwright/test');
- test('pass', async ({}) => {
+ test('pass', { tag: '@smoke' }, async ({}) => {
expect(1).toBe(1);
});
`,
@@ -1779,8 +1779,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await showReport();
- await expect(page.locator('.test-file-test .label')).toHaveCount(0);
- await expect(page.locator('.label-row')).not.toBeVisible();
+ await expect(page.locator('.test-file-test .label')).toHaveCount(1);
});
test('testCaseView - after click test label and go back, testCaseView should be visible', async ({ runInlineTest, showReport, page }) => {