fix(ui mode): do not render anonymous describe (#33675)

This commit is contained in:
Dmitry Gozman 2024-11-20 08:51:31 +00:00 committed by GitHub
parent ae10d56836
commit 50c8fbf750
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 39 deletions

View file

@ -79,14 +79,19 @@ export class TestTree {
const visitSuite = (project: reporterTypes.FullProject, parentSuite: reporterTypes.Suite, parentGroup: GroupItem) => { const visitSuite = (project: reporterTypes.FullProject, parentSuite: reporterTypes.Suite, parentGroup: GroupItem) => {
for (const suite of parentSuite.suites) { for (const suite of parentSuite.suites) {
const title = suite.title || '<anonymous>'; if (!suite.title) {
let group = parentGroup.children.find(item => item.kind === 'group' && item.title === title) as GroupItem | undefined; // Flatten anonymous describes.
visitSuite(project, suite, parentGroup);
continue;
}
let group = parentGroup.children.find(item => item.kind === 'group' && item.title === suite.title) as GroupItem | undefined;
if (!group) { if (!group) {
group = { group = {
kind: 'group', kind: 'group',
subKind: 'describe', subKind: 'describe',
id: 'suite:' + parentSuite.titlePath().join('\x1e') + '\x1e' + title, // account for anonymous suites id: 'suite:' + parentSuite.titlePath().join('\x1e') + '\x1e' + suite.title, // account for anonymous suites
title, title: suite.title,
location: suite.location!, location: suite.location!,
duration: 0, duration: 0,
parent: parentGroup, parent: parentGroup,

View file

@ -315,13 +315,10 @@ test('should list parametrized tests', async ({ runUITest }) => {
await page.getByText('cookies').click(); await page.getByText('cookies').click();
await page.keyboard.press('ArrowRight'); await page.keyboard.press('ArrowRight');
await page.getByText('<anonymous>').click();
await page.keyboard.press('ArrowRight');
await expect.poll(dumpTestTree(page)).toBe(` await expect.poll(dumpTestTree(page)).toBe(`
a.test.ts a.test.ts
cookies cookies <=
<anonymous> <=
test FR test FR
test DE test DE
test LT test LT
@ -330,9 +327,7 @@ test('should list parametrized tests', async ({ runUITest }) => {
- tree: - tree:
- treeitem "[icon-circle-outline] a.test.ts" [expanded]: - treeitem "[icon-circle-outline] a.test.ts" [expanded]:
- group: - group:
- treeitem "[icon-circle-outline] cookies" [expanded]: - treeitem "[icon-circle-outline] cookies" [expanded] [selected]:
- group:
- treeitem "[icon-circle-outline] <anonymous>" [expanded] [selected]:
- group: - group:
- treeitem "[icon-circle-outline] test FR" - treeitem "[icon-circle-outline] test FR"
- treeitem "[icon-circle-outline] test DE" - treeitem "[icon-circle-outline] test DE"
@ -356,13 +351,10 @@ test('should update parametrized tests', async ({ runUITest, writeFiles }) => {
await page.getByText('cookies').click(); await page.getByText('cookies').click();
await page.keyboard.press('ArrowRight'); await page.keyboard.press('ArrowRight');
await page.getByText('<anonymous>').click();
await page.keyboard.press('ArrowRight');
await expect.poll(dumpTestTree(page)).toBe(` await expect.poll(dumpTestTree(page)).toBe(`
a.test.ts a.test.ts
cookies cookies <=
<anonymous> <=
test FR test FR
test DE test DE
test LT test LT
@ -371,9 +363,7 @@ test('should update parametrized tests', async ({ runUITest, writeFiles }) => {
- tree: - tree:
- treeitem "[icon-circle-outline] a.test.ts" [expanded]: - treeitem "[icon-circle-outline] a.test.ts" [expanded]:
- group: - group:
- treeitem "[icon-circle-outline] cookies" [expanded]: - treeitem "[icon-circle-outline] cookies" [expanded] [selected]:
- group:
- treeitem "[icon-circle-outline] <anonymous>" [expanded] [selected]:
- group: - group:
- treeitem "[icon-circle-outline] test FR" - treeitem "[icon-circle-outline] test FR"
- treeitem "[icon-circle-outline] test DE" - treeitem "[icon-circle-outline] test DE"
@ -396,8 +386,7 @@ test('should update parametrized tests', async ({ runUITest, writeFiles }) => {
await expect.poll(dumpTestTree(page)).toBe(` await expect.poll(dumpTestTree(page)).toBe(`
a.test.ts a.test.ts
cookies cookies <=
<anonymous> <=
test FR test FR
test LT test LT
`); `);
@ -405,9 +394,7 @@ test('should update parametrized tests', async ({ runUITest, writeFiles }) => {
- tree: - tree:
- treeitem "[icon-circle-outline] a.test.ts" [expanded]: - treeitem "[icon-circle-outline] a.test.ts" [expanded]:
- group: - group:
- treeitem "[icon-circle-outline] cookies" [expanded]: - treeitem "[icon-circle-outline] cookies" [expanded] [selected]:
- group:
- treeitem "[icon-circle-outline] <anonymous>" [expanded] [selected]:
- group: - group:
- treeitem "[icon-circle-outline] test FR" - treeitem "[icon-circle-outline] test FR"
- treeitem "[icon-circle-outline] test LT" - treeitem "[icon-circle-outline] test LT"