Skip to content

Commit

Permalink
fix(ui mode): do not render anonymous describe
Browse files Browse the repository at this point in the history
Tests inside the anonymous describe are flatten into the parent suite.
  • Loading branch information
dgozman committed Nov 19, 2024
1 parent 6e19bc3 commit 24d0d81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 6 additions & 0 deletions packages/playwright/src/isomorphic/testTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export class TestTree {

const visitSuite = (project: reporterTypes.FullProject, parentSuite: reporterTypes.Suite, parentGroup: GroupItem) => {
for (const suite of parentSuite.suites) {
if (!suite.title) {
// Flatten anonymous describes.
visitSuite(project, suite, parentGroup);
continue;
}

const title = suite.title || '<anonymous>';
let group = parentGroup.children.find(item => item.kind === 'group' && item.title === title) as GroupItem | undefined;
if (!group) {
Expand Down
21 changes: 8 additions & 13 deletions tests/playwright-test/ui-mode-test-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,28 +315,23 @@ test('should list parametrized tests', async ({ runUITest }) => {

await page.getByText('cookies').click();
await page.keyboard.press('ArrowRight');
await page.getByText('<anonymous>').click();
await page.keyboard.press('ArrowRight');

await expect.poll(dumpTestTree(page)).toBe(`
▼ ◯ a.test.ts
▼ ◯ cookies
▼ ◯ <anonymous> <=
◯ test FR
◯ test DE
◯ test LT
▼ ◯ cookies <=
◯ test FR
◯ test DE
◯ test LT
`);
await expect(page.getByTestId('test-tree')).toMatchAriaSnapshot(`
- tree:
- treeitem "[icon-circle-outline] a.test.ts" [expanded]:
- group:
- treeitem "[icon-circle-outline] cookies" [expanded]:
- treeitem "[icon-circle-outline] cookies" [expanded] [selected]:
- group:
- treeitem "[icon-circle-outline] <anonymous>" [expanded] [selected]:
- group:
- treeitem "[icon-circle-outline] test FR"
- treeitem "[icon-circle-outline] test DE"
- treeitem "[icon-circle-outline] test LT"
- treeitem "[icon-circle-outline] test FR"
- treeitem "[icon-circle-outline] test DE"
- treeitem "[icon-circle-outline] test LT"
`);
});

Expand Down

0 comments on commit 24d0d81

Please sign in to comment.