Refactoring

This commit is contained in:
Aman Kumar 2024-05-22 12:42:05 +05:30
parent 70f442e93a
commit 2b2e9584ee
3 changed files with 8 additions and 8 deletions

View file

@ -46,8 +46,8 @@ export class Filter {
labels.add(token);
continue;
}
if (token.startsWith('a:')) {
annotations.add(token.slice(2));
if (token.startsWith('annot:')) {
annotations.add(token.slice('annot:'.length));
continue;
}
text.push(token.toLowerCase());
@ -135,7 +135,7 @@ export class Filter {
}
if (this.annotations.length) {
const matches = this.annotations.every(annotation =>
searchValues.annotations.some(_annotation => _annotation.includes(annotation)));
searchValues.annotations.some(a => a.includes(annotation)));
if (!matches)
return false;
}

View file

@ -59,6 +59,6 @@ test('should toggle filters', async ({ page, mount }) => {
await expect(page).toHaveURL(/#\?q=s:flaky/);
await component.locator('a', { hasText: 'Skipped' }).click();
await expect(page).toHaveURL(/#\?q=s:skipped/);
await component.getByRole('searchbox').fill('a:annotation type=annotation description');
expect(filters).toEqual(['', 's:passed', 's:failed', 's:flaky', 's:skipped', 'a:annotation type=annotation description']);
await component.getByRole('searchbox').fill('annot:annotation type=annotation description');
expect(filters).toEqual(['', 's:passed', 's:failed', 's:flaky', 's:skipped', 'annot:annotation type=annotation description']);
});

View file

@ -1702,8 +1702,8 @@ for (const useIntermediateMergeReport of [false] as const) {
const passedNavMenu = page.locator('.subnav-item:has-text("Passed")');
const failedNavMenu = page.locator('.subnav-item:has-text("Failed")');
const allNavMenu = page.locator('.subnav-item:has-text("All")');
const smokeLabelButton = page.locator('.test-file-test', { has: page.getByText('@smoke fails', { exact: true }) }).locator('.label', { hasText: 'smoke' });
const regressionLabelButton = page.locator('.test-file-test', { has: page.getByText('@regression passes', { exact: true }) }).locator('.label', { hasText: 'regression' });
const smokeLabelButton = page.locator('.label', { hasText: 'smoke' }).first();
const regressionLabelButton = page.locator('.label', { hasText: 'regression' }).first();
await failedNavMenu.click();
await smokeLabelButton.click();
@ -2231,7 +2231,7 @@ for (const useIntermediateMergeReport of [false] as const) {
const searchInput = page.locator('.subnav-search-input');
await searchInput.fill('a:key=value');
await searchInput.fill('annot:key=value');
await expect(page.getByText('a.test.js', { exact: true })).toBeVisible();
await expect(page.getByText('non-annotated test')).not.toBeVisible();
await expect(page.getByText('annotated test')).toBeVisible();