Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(ui mode): text filter should filter by explicit tags (#29821)

Dmitry Gozmanabfd2c4e663a
diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx
index b0c392884f..8e5bb3831b 100644
--- a/packages/trace-viewer/src/ui/uiModeView.tsx
+++ b/packages/trace-viewer/src/ui/uiModeView.tsx
@@ -965,8 +965,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);