Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
feat: add diff clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
rostik404 committed Mar 13, 2019
1 parent 740edcd commit f80cf09
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 80 deletions.
6 changes: 5 additions & 1 deletion lib/config/browser-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const getTopLevel = () => {
screenshotsDir: 'gemini/screens',
tolerance: 2.3,
antialiasingTolerance: 0,
compareOpts: {stopOnFirstFail: false},
compareOpts: {
shouldCluster: false,
clustersSize: 10,
stopOnFirstFail: false
},
buildDiffOpts: {
ignoreAntialiasing: true,
ignoreCaret: true
Expand Down
5 changes: 3 additions & 2 deletions lib/state-processor/capture-processor/capture-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ module.exports = class CaptureProcessor {

return capture.image.save(currImg.path)
.then(() => Image.compare(currImg.path, refImg.path, imageCompareOpts))
.then(({equal, diffBounds, metaInfo = {}}) => {
.then(({equal, diffBounds, diffClusters, metaInfo = {}}) => {
Object.assign(refImg, metaInfo.refImg);
const diffAreas = {diffBounds, diffClusters};

return equal
? this._onEqualHandler(refImg, currImg)
: this._onDiffHandler(refImg, currImg, diffBounds);
: this._onDiffHandler(refImg, currImg, diffAreas);
});
}
};
2 changes: 1 addition & 1 deletion lib/state-processor/capture-processor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports.create = (type) => {
.onReference()
.onNoReference(throwNoRefError)
.onEqual((refImg, currImg) => ({refImg, currImg, equal: true}))
.onDiff((refImg, currImg, diffBounds) => ({refImg, currImg, diffBounds, equal: false}));
.onDiff((refImg, currImg, {diffBounds, diffClusters}) => ({refImg, currImg, diffBounds, diffClusters, equal: false}));
}

if (type === 'new-updater') {
Expand Down
147 changes: 72 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"debug": "^2.2.0",
"fs-extra": "^0.30.0",
"gemini-configparser": "^1.0.0",
"gemini-core": "^3.3.0",
"gemini-core": "^3.5.0",
"gemini-coverage": "^2.0.0",
"graceful-fs": "^4.1.11",
"handlebars": "^4.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('state-processor/capture-processor/capture-processor', () => {
Image.compare.resolves({
equal: false,
diffBounds: {left: 0, top: 0, right: 10, bottom: 10},
diffClusters: [{left: 0, top: 0, right: 10, bottom: 10}],
metaInfo: {refImg: {size: {width: 100, height: 200}}}
});
temp.path.withArgs({suffix: '.png'}).returns('/temp/path');
Expand All @@ -180,6 +181,7 @@ describe('state-processor/capture-processor/capture-processor', () => {
refImg: {path: '/ref/path', size: {width: 100, height: 200}},
currImg: {path: '/temp/path', size: {width: 300, height: 400}},
diffBounds: {left: 0, top: 0, right: 10, bottom: 10},
diffClusters: [{left: 0, top: 0, right: 10, bottom: 10}],
equal: false
});
});
Expand Down

0 comments on commit f80cf09

Please sign in to comment.