Address comments

This commit is contained in:
Yury Semikhatsky 2024-03-28 23:28:07 -07:00
parent b276c0ad47
commit 0ac8fc24f9
3 changed files with 16 additions and 29 deletions

View file

@ -341,20 +341,12 @@ export class TeleReporterReceiver {
parent._addSuite(targetSuite);
}
targetSuite.location = this._absoluteLocation(jsonSuite.location);
if (jsonSuite.entries) {
jsonSuite.entries.forEach(e => {
if ('testId' in e)
this._mergeTestInto(e, targetSuite!);
else
this._mergeSuiteInto(e, targetSuite!);
});
} else {
// before 1.44
for (const jsonChildSuite of jsonSuite.suites!)
this._mergeSuiteInto(jsonChildSuite, targetSuite);
for (const jsonTest of jsonSuite.tests!)
this._mergeTestInto(jsonTest, targetSuite);
}
jsonSuite.entries.forEach(e => {
if ('testId' in e)
this._mergeTestInto(e, targetSuite!);
else
this._mergeSuiteInto(e, targetSuite!);
});
}
private _mergeTestInto(jsonTest: JsonTestCase, parent: TeleSuite) {
@ -431,7 +423,7 @@ export class TeleSuite implements reporterTypes.Suite {
allTests(): reporterTypes.TestCase[] {
const result: reporterTypes.TestCase[] = [];
const visit = (suite: reporterTypes.Suite) => {
for (const entry of [...suite.suites, ...suite.tests]) {
for (const entry of suite.entries()) {
if (entry.type === 'test')
result.push(entry);
else
@ -457,13 +449,11 @@ export class TeleSuite implements reporterTypes.Suite {
_addTest(test: TeleTestCase) {
test.parent = this;
this._entries.push(test);
this.tests.push(test);
}
_addSuite(suite: TeleSuite) {
suite.parent = this;
this._entries.push(suite);
this.suites.push(suite);
}
}

View file

@ -538,16 +538,13 @@ class BlobModernizer {
_modernize_1_to_2(events: JsonEvent[]): JsonEvent[] {
return events.map(event => {
if (event.method === 'onProject') {
const modernizeSuite = (suite: blobV1.JsonSuite) => {
for (const child of suite.suites)
modernizeSuite(child);
(suite as any).entries = [...suite.suites, ...suite.tests];
(suite as any).suites = undefined;
(suite as any).tests = undefined;
const modernizeSuite = (suite: blobV1.JsonSuite): JsonSuite => {
const newSuites = suite.suites.map(modernizeSuite);
const { suites, tests, ...remainder } = suite;
return { entries: [...newSuites, ...tests], ...remainder };
};
const project = event.params.project as blobV1.JsonProject;
for (const suite of project.suites)
modernizeSuite(suite);
const project = event.params.project;
project.suites = project.suites.map(modernizeSuite);
}
return event;
});

View file

@ -41,8 +41,8 @@ export type { FullConfig, TestStatus, FullProject } from './test';
*/
export interface Suite {
/**
* Returns type of the suite. The Suites form the following hierarchy: `root` -> `project` -> `file` -> `describe` ->
* ...`describe` -> `test`.
* Returns the type of the suite. The Suites form the following hierarchy: `root` -> `project` -> `file` -> `describe`
* -> ...`describe` -> `test`.
*/
type: 'root' | 'project' | 'file' | 'describe';
/**
@ -56,7 +56,7 @@ export interface Suite {
allTests(): Array<TestCase>;
/**
* Test cases and suites defined directly in this suite. The elements returned in their declaration order. You can
* Test cases and suites defined directly in this suite. The elements are returned in their declaration order. You can
* discriminate between different entry types using
* [testCase.type](https://playwright.dev/docs/api/class-testcase#test-case-type) and
* [suite.type](https://playwright.dev/docs/api/class-suite#suite-type).