Write test case for annotation search
This commit is contained in:
parent
c3ff7722a3
commit
1e2d17fd96
|
|
@ -135,9 +135,7 @@ export class Filter {
|
||||||
}
|
}
|
||||||
if (this.annotations.length) {
|
if (this.annotations.length) {
|
||||||
const matches = this.annotations.every(annotation =>
|
const matches = this.annotations.every(annotation =>
|
||||||
searchValues.annotations.some(_annotation => (
|
searchValues.annotations.some(_annotation => _annotation.includes(annotation)));
|
||||||
_annotation.includes(annotation)
|
|
||||||
)));
|
|
||||||
if (!matches)
|
if (!matches)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,6 @@ test('should toggle filters', async ({ page, mount }) => {
|
||||||
await expect(page).toHaveURL(/#\?q=s:flaky/);
|
await expect(page).toHaveURL(/#\?q=s:flaky/);
|
||||||
await component.locator('a', { hasText: 'Skipped' }).click();
|
await component.locator('a', { hasText: 'Skipped' }).click();
|
||||||
await expect(page).toHaveURL(/#\?q=s:skipped/);
|
await expect(page).toHaveURL(/#\?q=s:skipped/);
|
||||||
expect(filters).toEqual(['', 's:passed', 's:failed', 's:flaky', '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']);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1702,8 +1702,8 @@ for (const useIntermediateMergeReport of [false] as const) {
|
||||||
const passedNavMenu = page.locator('.subnav-item:has-text("Passed")');
|
const passedNavMenu = page.locator('.subnav-item:has-text("Passed")');
|
||||||
const failedNavMenu = page.locator('.subnav-item:has-text("Failed")');
|
const failedNavMenu = page.locator('.subnav-item:has-text("Failed")');
|
||||||
const allNavMenu = page.locator('.subnav-item:has-text("All")');
|
const allNavMenu = page.locator('.subnav-item:has-text("All")');
|
||||||
const smokeLabelButton = page.locator('.label', { hasText: 'smoke' }).first();
|
const smokeLabelButton = page.locator('.test-file-test', { has: page.getByText('@smoke fails', { exact: true }) }).locator('.label', { hasText: 'smoke' });
|
||||||
const regressionLabelButton = page.locator('.label', { hasText: 'regression' }).first();
|
const regressionLabelButton = page.locator('.test-file-test', { has: page.getByText('@regression passes', { exact: true }) }).locator('.label', { hasText: 'regression' });
|
||||||
|
|
||||||
await failedNavMenu.click();
|
await failedNavMenu.click();
|
||||||
await smokeLabelButton.click();
|
await smokeLabelButton.click();
|
||||||
|
|
@ -2214,6 +2214,29 @@ for (const useIntermediateMergeReport of [false] as const) {
|
||||||
await expect(page.getByText('passes title')).toBeVisible();
|
await expect(page.getByText('passes title')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('tests should filter by annotation texts', async ({ runInlineTest, showReport, page }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'a.test.js': `
|
||||||
|
const { test, expect } = require('@playwright/test');
|
||||||
|
test('annotated test',{ annotation :[{type:'key',description:'value'}]}, async ({}) => {expect(1).toBe(1);});
|
||||||
|
test('non-annotated test', async ({}) => {expect(1).toBe(2);});
|
||||||
|
`,
|
||||||
|
}, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' });
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.passed).toBe(1);
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
|
||||||
|
await showReport();
|
||||||
|
|
||||||
|
const searchInput = page.locator('.subnav-search-input');
|
||||||
|
|
||||||
|
await searchInput.fill('a: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();
|
||||||
|
});
|
||||||
|
|
||||||
test('tests should filter by fileName:line/column', async ({ runInlineTest, showReport, page }) => {
|
test('tests should filter by fileName:line/column', async ({ runInlineTest, showReport, page }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'a.test.js': `
|
'a.test.js': `
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue