From f822d650b25ee2981576ffe88b320023da144655 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 5 Mar 2024 10:58:55 -0800 Subject: [PATCH] cherry-pick(#29821): feat(ui mode): text filter should filter by explicit tags Fixes #29815. --- packages/trace-viewer/src/ui/uiModeView.tsx | 4 ++-- tests/playwright-test/ui-mode-test-filters.spec.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 1becb6645f..bccdeda9b6 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -949,8 +949,8 @@ function filterTree(rootItem: GroupItem, filterText: string, statusFilters: Map< const filtersStatuses = [...statusFilters.values()].some(Boolean); const filter = (testCase: TestCaseItem) => { - const title = testCase.tests[0].titlePath().join(' ').toLowerCase(); - if (!tokens.every(token => title.includes(token)) && !testCase.tests.some(t => runningTestIds?.has(t.id))) + const titleWithTags = [...testCase.tests[0].titlePath(), ...testCase.tests[0].tags].join(' ').toLowerCase(); + if (!tokens.every(token => titleWithTags.includes(token)) && !testCase.tests.some(t => runningTestIds?.has(t.id))) return false; testCase.children = (testCase.children as TestItem[]).filter(test => { return !filtersStatuses || runningTestIds?.has(test.test.id) || statusFilters.get(test.status); diff --git a/tests/playwright-test/ui-mode-test-filters.spec.ts b/tests/playwright-test/ui-mode-test-filters.spec.ts index 3e21392b66..f35d4dec4a 100644 --- a/tests/playwright-test/ui-mode-test-filters.spec.ts +++ b/tests/playwright-test/ui-mode-test-filters.spec.ts @@ -24,7 +24,7 @@ const basicTestTree = { test('passes', () => {}); test('fails', () => { expect(1).toBe(2); }); test.describe('suite', () => { - test('inner passes', () => {}); + test('inner passes', { tag: '@smoke' }, () => {}); test('inner fails', () => { expect(1).toBe(2); }); }); `, @@ -46,6 +46,16 @@ test('should filter by title', async ({ runUITest }) => { `); }); +test('should filter by explicit tags', async ({ runUITest }) => { + const { page } = await runUITest(basicTestTree); + await page.getByPlaceholder('Filter').fill('@smoke inner'); + await expect.poll(dumpTestTree(page)).toBe(` + ▼ ◯ a.test.ts + ▼ ◯ suite + ◯ inner passes + `); +}); + test('should filter by status', async ({ runUITest }) => { const { page } = await runUITest(basicTestTree);