Skip to content

Commit bf67869

Browse files
authored
Merge pull request #471 from gemini-testing/HERMIONE-968.fix_reuse_references
fix: do not reuse reference images from another browser
2 parents 06f78d2 + cb0467e commit bf67869

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

lib/test-adapter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ module.exports = class TestAdapter {
9696
}
9797

9898
_getExpectedKey(stateName) {
99+
const {id, browserId} = this._testResult;
99100
// TODO: remove toString after publish major version
100-
return this._testResult.id.toString() + '#' + stateName;
101+
return [id.toString(), browserId, stateName].join('/');
101102
}
102103

103104
_getExpectedPath(stateName, status) {

test/unit/lib/test-adapter.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,24 +605,27 @@ describe('hermione test adapter', () => {
605605
});
606606

607607
describe('expected path', () => {
608-
let lastImageInfo;
609-
610-
beforeEach(() => {
611-
lastImageInfo = [{
608+
const mkLastImageInfo_ = (opts = {}) => {
609+
const {stateName, expectedImgPath} = _.defaults(opts, {
612610
stateName: 'plain',
611+
expectedImgPath: 'default/expected/img/path.png'
612+
});
613+
614+
return [{
615+
stateName,
613616
expectedImg: {
614-
path: 'expectedImgPath'
617+
path: expectedImgPath
615618
}
616619
}];
617-
});
620+
};
618621

619622
it('should be pulled from the database if exists', async () => {
620623
sqliteAdapter.query.withArgs({
621624
select: 'imagesInfo',
622625
where: 'suitePath = ? AND name = ?',
623626
orderBy: 'timestamp',
624627
orderDescending: true
625-
}).returns({imagesInfo: JSON.stringify(lastImageInfo)});
628+
}).returns({imagesInfo: JSON.stringify(mkLastImageInfo_())});
626629

627630
const testResult = mkTestResult_({
628631
fullTitle: () => 'some-title',
@@ -651,7 +654,7 @@ describe('hermione test adapter', () => {
651654
});
652655

653656
it('should be generated on update', async () => {
654-
sqliteAdapter.query.returns({imagesInfo: JSON.stringify(lastImageInfo)});
657+
sqliteAdapter.query.returns({imagesInfo: JSON.stringify(mkLastImageInfo_())});
655658
const testResult = mkTestResult_({
656659
fullTitle: () => 'some-title',
657660
assertViewResults: [mkErrStub()],
@@ -664,8 +667,20 @@ describe('hermione test adapter', () => {
664667
assert.calledOnce(utils.getReferencePath);
665668
});
666669

670+
it('should be queried from the database for each browser', async () => {
671+
const chromeTestResult = mkTestResult_({browserId: 'chrome'});
672+
const firefoxTestResult = mkTestResult_({browserId: 'firefox'});
673+
674+
mkHermioneTestResultAdapter(chromeTestResult, {status: FAIL}).getImagesFor(FAIL, 'plain');
675+
mkHermioneTestResultAdapter(firefoxTestResult, {status: FAIL}).getImagesFor(FAIL, 'plain');
676+
677+
assert.calledTwice(sqliteAdapter.query);
678+
assert.calledWith(sqliteAdapter.query.firstCall, sinon.match.any, sinon.match.any, 'chrome');
679+
assert.calledWith(sqliteAdapter.query.secondCall, sinon.match.any, sinon.match.any, 'firefox');
680+
});
681+
667682
it('should be queried from the database once per state', async () => {
668-
sqliteAdapter.query.returns({imagesInfo: JSON.stringify(lastImageInfo)});
683+
sqliteAdapter.query.returns({imagesInfo: JSON.stringify(mkLastImageInfo_())});
669684
const testResult = mkTestResult_({
670685
fullTitle: () => 'some-title',
671686
assertViewResults: [mkErrStub()],

0 commit comments

Comments
 (0)