Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/html-reporter/src/labels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const ProjectAndTagLabelsView: React.FC<{
useLinks?: boolean,
style?: React.CSSProperties,
}> = ({ projectNames, activeProjectName, otherLabels, useLinks, style }) => {
return (projectNames.length > 0 || otherLabels.length > 0) && <span className='label-row' style={style ?? {}}>
// We can have an empty project name if we have no projects specified in the config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also have multiple empty projects. Will this code work in such a case?

projects: [
  { name: 'chromium' },
  { /* some settings */ },
  { /* different settings */ },
  { name: 'webkit' },
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-08-26 at 5 46 02 AM

It functions with any project without a name.

const hasProjectNames = projectNames.length > 0 && !!activeProjectName;

return (hasProjectNames || otherLabels.length > 0) && <span className='label-row' style={style ?? {}}>
<ProjectLink projectNames={projectNames} projectName={activeProjectName} />
{!!useLinks ? <LabelsLinkView labels={otherLabels} /> : <LabelsClickView labels={otherLabels} />}
</span>;
Expand Down
19 changes: 19 additions & 0 deletions tests/playwright-test/reporter-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,25 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await expect(page.locator('.label')).toHaveText('webkit');
});

test('project label should not show if there are no explicit projects', async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({
'a.test.js': `
const { expect, test } = require('@playwright/test');
test('pass', async ({}) => {
expect(1).toBe(1);
});
`,
}, { reporter: 'dot,html' }, { PLAYWRIGHT_HTML_OPEN: 'never' });

expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);

await showReport();

await expect(page.locator('.test-file-test .label')).toHaveCount(0);
await expect(page.locator('.label-row')).not.toBeVisible();
});

test('testCaseView - after click test label and go back, testCaseView should be visible', async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({
'playwright.config.js': `
Expand Down
Loading