fix(html): label not matched if first with describe (#22680)

This commit is contained in:
Alex Neo 2023-04-28 06:04:54 +03:00 committed by GitHub
parent 16f664e22c
commit 7937699b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

@ -108,7 +108,7 @@ export class Filter {
if (test.outcome === 'skipped') if (test.outcome === 'skipped')
status = 'skipped'; status = 'skipped';
const searchValues: SearchValues = { const searchValues: SearchValues = {
text: (status + ' ' + test.projectName + ' ' + test.path.join(' ') + test.title).toLowerCase(), text: (status + ' ' + test.projectName + ' ' + test.path.join(' ') + ' ' + test.title).toLowerCase(),
project: test.projectName.toLowerCase(), project: test.projectName.toLowerCase(),
status: status as any, status: status as any,
}; };

View File

@ -118,7 +118,7 @@ const LabelsClickView: React.FC<React.PropsWithChildren<{
return labels.length > 0 ? ( return labels.length > 0 ? (
<> <>
{labels.map(tag => ( {labels.map(tag => (
<span style={{ margin: '6px 0 0 6px', cursor: 'pointer' }} className={'label label-color-' + (hashStringToInt(tag))} onClick={e => onClickHandle(e, tag)}> <span key={tag} style={{ margin: '6px 0 0 6px', cursor: 'pointer' }} className={'label label-color-' + (hashStringToInt(tag))} onClick={e => onClickHandle(e, tag)}>
{tag} {tag}
</span> </span>
))} ))}

View File

@ -1261,18 +1261,23 @@ test.describe('labels', () => {
expect((await firstTitle.boundingBox()).height).toBeGreaterThanOrEqual(100); expect((await firstTitle.boundingBox()).height).toBeGreaterThanOrEqual(100);
}); });
test('should show filtered tests by labels when click on label', async ({ runInlineTest, showReport, page }) => { test('with describe. should show filtered tests by labels when click on label', async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({ const result = await runInlineTest({
'a.test.js': ` 'a.test.js': `
const { expect, test } = require('@playwright/test'); const { expect, test } = require('@playwright/test');
test('@regression passes', async ({}) => { test.describe('Error Pages', () => {
expect(1).toBe(1); test('@regression passes', async ({}) => {
expect(1).toBe(1);
});
}); });
`, `,
'b.test.js': ` 'b.test.js': `
const { expect, test } = require('@playwright/test'); const { expect, test } = require('@playwright/test');
test('@smoke fails', async ({}) => {
expect(1).toBe(2); test.describe('Error Pages', () => {
test('@smoke fails', async ({}) => {
expect(1).toBe(2);
});
}); });
`, `,
}, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' }); }, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' });
@ -1284,7 +1289,7 @@ test.describe('labels', () => {
await showReport(); await showReport();
const searchInput = page.locator('.subnav-search-input'); const searchInput = page.locator('.subnav-search-input');
const smokeLabelButton = page.locator('.test-file-test', { has: page.getByText('@smoke fails', { exact: true }) }).locator('.label', { hasText: 'smoke' }); const smokeLabelButton = page.locator('.test-file-test', { has: page.getByText('Error Pages @smoke fails', { exact: true }) }).locator('.label', { hasText: 'smoke' });
await expect(smokeLabelButton).toBeVisible(); await expect(smokeLabelButton).toBeVisible();
await smokeLabelButton.click(); await smokeLabelButton.click();
@ -1292,9 +1297,9 @@ test.describe('labels', () => {
await expect(page.locator('.test-file-test')).toHaveCount(1); await expect(page.locator('.test-file-test')).toHaveCount(1);
await expect(page.locator('.chip', { hasText: 'a.test.js' })).toHaveCount(0); await expect(page.locator('.chip', { hasText: 'a.test.js' })).toHaveCount(0);
await expect(page.locator('.chip', { hasText: 'b.test.js' })).toHaveCount(1); await expect(page.locator('.chip', { hasText: 'b.test.js' })).toHaveCount(1);
await expect(page.locator('.test-file-test .test-file-title')).toHaveText('@smoke fails'); await expect(page.locator('.test-file-test .test-file-title')).toHaveText('Error Pages @smoke fails');
const regressionLabelButton = page.locator('.test-file-test', { has: page.getByText('@regression passes', { exact: true }) }).locator('.label', { hasText: 'regression' }); const regressionLabelButton = page.locator('.test-file-test', { has: page.getByText('Error Pages @regression passes', { exact: true }) }).locator('.label', { hasText: 'regression' });
await expect(regressionLabelButton).not.toBeVisible(); await expect(regressionLabelButton).not.toBeVisible();
@ -1310,7 +1315,7 @@ test.describe('labels', () => {
await expect(page.locator('.test-file-test')).toHaveCount(1); await expect(page.locator('.test-file-test')).toHaveCount(1);
await expect(page.locator('.chip', { hasText: 'a.test.js' })).toHaveCount(1); await expect(page.locator('.chip', { hasText: 'a.test.js' })).toHaveCount(1);
await expect(page.locator('.chip', { hasText: 'b.test.js' })).toHaveCount(0); await expect(page.locator('.chip', { hasText: 'b.test.js' })).toHaveCount(0);
await expect(page.locator('.test-file-test .test-file-title')).toHaveText('@regression passes'); await expect(page.locator('.test-file-test .test-file-title')).toHaveText('Error Pages @regression passes');
}); });
test('click label should change URL', async ({ runInlineTest, showReport, page }) => { test('click label should change URL', async ({ runInlineTest, showReport, page }) => {