fix(ui): when --grep is used, UI should only show selected tests (#31815)
Closes https://github.com/microsoft/playwright/issues/31617.
This commit is contained in:
parent
d5a77c0f0b
commit
bbe5df3f5f
|
|
@ -79,6 +79,8 @@ export interface TestServerInterface {
|
||||||
listTests(params: {
|
listTests(params: {
|
||||||
projects?: string[];
|
projects?: string[];
|
||||||
locations?: string[];
|
locations?: string[];
|
||||||
|
grep?: string;
|
||||||
|
grepInvert?: string;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
report: ReportEntry[],
|
report: ReportEntry[],
|
||||||
status: reporterTypes.FullResult['status']
|
status: reporterTypes.FullResult['status']
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,8 @@ class TestServerDispatcher implements TestServerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
config.cliArgs = params.locations || [];
|
config.cliArgs = params.locations || [];
|
||||||
|
config.cliGrep = params.grep;
|
||||||
|
config.cliGrepInvert = params.grepInvert;
|
||||||
config.cliProjectFilter = params.projects?.length ? params.projects : undefined;
|
config.cliProjectFilter = params.projects?.length ? params.projects : undefined;
|
||||||
config.cliListOnly = true;
|
config.cliListOnly = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
commandQueue.current = commandQueue.current.then(async () => {
|
commandQueue.current = commandQueue.current.then(async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args });
|
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert });
|
||||||
teleSuiteUpdater.processListReport(result.report);
|
teleSuiteUpdater.processListReport(result.report);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
@ -186,7 +186,7 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
if (status !== 'passed')
|
if (status !== 'passed')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args });
|
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert });
|
||||||
teleSuiteUpdater.processListReport(result.report);
|
teleSuiteUpdater.processListReport(result.report);
|
||||||
|
|
||||||
testServerConnection.onListChanged(updateList);
|
testServerConnection.onListChanged(updateList);
|
||||||
|
|
|
||||||
|
|
@ -99,3 +99,8 @@ test('should be case sensitive by default with a regex', async ({ runInlineTest
|
||||||
const result = await runInlineTest(files, { 'grep': '/TesT Cc/' });
|
const result = await runInlineTest(files, { 'grep': '/TesT Cc/' });
|
||||||
expect(result.passed).toBe(0);
|
expect(result.passed).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('excluded tests should not be shown in UI', async ({ runInlineTest, runTSC }) => {
|
||||||
|
const result = await runInlineTest(files, { 'grep': 'Test AA' });
|
||||||
|
expect(result.passed).toBe(3);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -229,3 +229,18 @@ test('should filter skipped', async ({ runUITest, createLatch }) => {
|
||||||
⊘ fails
|
⊘ fails
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should only show tests selected with --grep', async ({ runUITest }) => {
|
||||||
|
const { page } = await runUITest(basicTestTree, undefined, {
|
||||||
|
additionalArgs: ['--grep', 'fails'],
|
||||||
|
});
|
||||||
|
await expect.poll(dumpTestTree(page)).not.toContain('passes');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not show tests filtered with --grep-invert', async ({ runUITest }) => {
|
||||||
|
const { page } = await runUITest(basicTestTree, undefined, {
|
||||||
|
additionalArgs: ['--grep-invert', 'fails'],
|
||||||
|
});
|
||||||
|
await expect.poll(dumpTestTree(page)).toContain('passes');
|
||||||
|
await expect.poll(dumpTestTree(page)).not.toContain('fails');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue