Skip to content

Commit

Permalink
cherry-pick(#29821): feat(ui mode): text filter should filter by expl…
Browse files Browse the repository at this point in the history
…icit tags

Fixes #29815.
  • Loading branch information
dgozman committed Mar 5, 2024
1 parent 9749f75 commit f822d65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/trace-viewer/src/ui/uiModeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion tests/playwright-test/ui-mode-test-filters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
});
`,
Expand All @@ -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);

Expand Down

0 comments on commit f822d65

Please sign in to comment.