fix(html-reporter): do not show empty project name (#20735)

This commit is contained in:
Max Schmitt 2023-02-08 01:07:25 +01:00 committed by GitHub
parent 4259d4e1d6
commit 161f3f144a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -85,6 +85,16 @@ test('should show the project names', async ({ mount }) => {
</HeaderView>);
await expect(component.getByText('Project: my-project')).toBeVisible();
});
await test.step('with 1 project and empty projectName', async () => {
const component = await mount(<HeaderView
stats={stats}
filterText=''
setFilterText={() => {}}
projectNames={['']}
>
</HeaderView>);
await expect(component.getByText('Project:')).toBeHidden();
});
await test.step('with more than 1 project', async () => {
const component = await mount(<HeaderView
stats={stats}

View File

@ -60,7 +60,7 @@ export const HeaderView: React.FC<React.PropsWithChildren<{
</div>
{reportLoaderError && <div className='header-view-status-line pt-2' data-testid='loader-error' style={{ color: 'var(--color-danger-emphasis)', textAlign: 'right' }}>{reportLoaderError}</div>}
<div className='header-view-status-line pt-2'>
{projectNames.length === 1 && <span data-testid="project-name" style={{ color: 'var(--color-fg-subtle)', float: 'left' }}>Project: {projectNames[0]}</span>}
{projectNames.length === 1 && !!projectNames[0] && <span data-testid="project-name" style={{ color: 'var(--color-fg-subtle)', float: 'left' }}>Project: {projectNames[0]}</span>}
<span data-testid="overall-duration" style={{ color: 'var(--color-fg-subtle)', float: 'right' }}>Total time: {msToString(stats.duration)}</span>
</div>
</>);