Skip to content

Commit

Permalink
Merge pull request #239 from gemini-testing/merge-suite-wiht-children…
Browse files Browse the repository at this point in the history
…-and-browsers

fix(merge-reports): merge suites with children and browsers
  • Loading branch information
CatWithApple authored Jul 17, 2019
2 parents 8d1188a + e1dccdd commit a62cb73
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/merge-reports/data-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ module.exports = class DataTree {

if (suite.children) {
await Promise.map(suite.children, (childSuite) => this._mergeSuiteResult(childSuite));
} else {
}

if (suite.browsers) {
await this._mergeBrowserResult(suite);
}
}
Expand Down Expand Up @@ -94,6 +96,8 @@ module.exports = class DataTree {
existentParentSuite.browsers = existentParentSuite.browsers || [];
existentParentSuite.browsers.push(bro);

setStatusForBranch(this._data.suites, suitePath);

this._mergeStatistics(bro);
await this._moveImages(bro, {fromFields: ['result', 'retries']});
}
Expand Down
10 changes: 7 additions & 3 deletions lib/static/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ function setStatusForBranch(nodes, suitePath) {
return;
}

const statuses = node.browsers
const statusesBrowser = node.browsers
? node.browsers.map(({result: {status}}) => status)
: node.children.map(({status}) => status);
: [];

const status = determineStatus(statuses);
const statusesChildren = node.children
? node.children.map(({status}) => status)
: [];

const status = determineStatus([...statusesBrowser, ...statusesChildren]);

// if newly determined status is the same as current status, do nothing
if (node.status === status) {
Expand Down
136 changes: 136 additions & 0 deletions test/unit/lib/merge-reports/data-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,142 @@ describe('lib/merge-reports/data-tree', () => {
});
});
});

describe('with children and browsers', () => {
it('should add data to suite from children with error status', async () => {
const srcDataSuites1 = mkSuite({
suitePath: ['first suite'],
status: SUCCESS,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: SUCCESS,
browsers: [mkBrowserResult({
result: mkTestResult({status: SUCCESS}),
name: 'first-bro'
})]
})
]
});
const srcDataSuites2 = mkSuite({
suitePath: ['first suite'],
status: ERROR,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: ERROR,
children: [
mkState({
suitePath: ['first suite', 'second suite', 'third suite'],
status: ERROR,
browsers: [mkBrowserResult({
name: 'second-bro',
result: mkTestResult({status: ERROR})
})]
})
]
})
]
});

const initialData = {suites: [srcDataSuites1]};
const dataCollection = {'src-report/path': {suites: [srcDataSuites2]}};

const {suites} = await mkDataTree_(initialData).mergeWith(dataCollection);

assert.deepEqual(suites[0], mkSuite({
suitePath: ['first suite'],
status: ERROR,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: ERROR,
browsers: [mkBrowserResult({
name: 'first-bro',
result: mkTestResult({status: SUCCESS})
})],
children: [
mkState({
suitePath: ['first suite', 'second suite', 'third suite'],
status: ERROR,
browsers: [mkBrowserResult({
name: 'second-bro',
result: mkTestResult({status: ERROR})
})]
})
]
})
]
}));
});

it('should add data to suite from browsers with error status', async () => {
const srcDataSuites1 = mkSuite({
suitePath: ['first suite'],
status: SUCCESS,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: SUCCESS,
children: [
mkState({
suitePath: ['first suite', 'second suite', 'third suite'],
status: SUCCESS,
browsers: [mkBrowserResult({
name: 'first-bro',
result: mkTestResult({status: SUCCESS})
})]
})
]
})
]
});
const srcDataSuites2 = mkSuite({
suitePath: ['first suite'],
status: ERROR,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: ERROR,
browsers: [mkBrowserResult({
name: 'second-bro',
result: mkTestResult({status: ERROR})
})]
})
]
});

const initialData = {suites: [srcDataSuites1]};
const dataCollection = {'src-report/path': {suites: [srcDataSuites2]}};

const {suites} = await mkDataTree_(initialData).mergeWith(dataCollection);

assert.deepEqual(suites[0], mkSuite({
suitePath: ['first suite'],
status: ERROR,
children: [
mkSuite({
suitePath: ['first suite', 'second suite'],
status: ERROR,
children: [
mkState({
suitePath: ['first suite', 'second suite', 'third suite'],
status: SUCCESS,
browsers: [mkBrowserResult({
name: 'first-bro',
result: mkTestResult({status: SUCCESS})
})]
})
],
browsers: [mkBrowserResult({
name: 'second-bro',
result: mkTestResult({status: ERROR})
})]
})
]
}));
});
});
});

describe('merge statistics data', () => {
Expand Down

0 comments on commit a62cb73

Please sign in to comment.