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

Fixes #29815.
This commit is contained in:
Dmitry Gozman 2024-03-05 10:58:55 -08:00
parent 9749f75426
commit f822d650b2
2 changed files with 13 additions and 3 deletions

View File

@ -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);

View File

@ -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);