Skip to content

Commit

Permalink
Add visual regression screenshot gallery.
Browse files Browse the repository at this point in the history
- Add 'test:visualRegression' grunt task.
- Run 'test:visualRegression' as part of npm script 'test'.
- Add 'clean:screenshots task'.
- Clean screenshots/session when funtional tests are run.
  • Loading branch information
cjcenizal committed Jun 14, 2016
1 parent 0fb84e4 commit 9e353fd
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target
/test/screenshots/diff
/test/screenshots/failure
/test/screenshots/session
/test/screenshots/visual_regression_gallery.html
/esvm
.htpasswd
.eslintcache
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Tim Sullivan <[email protected]>"
],
"scripts": {
"test": "grunt test",
"test": "grunt test; grunt test:visualRegression",
"test:dev": "grunt test:dev",
"test:quick": "grunt test:quick",
"test:browser": "grunt test:browser",
Expand All @@ -59,8 +59,7 @@
"makelogs": "makelogs",
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk",
"sterilize": "grunt sterilize",
"compareScreenshots": "node utilities/compareScreenshots"
"sterilize": "grunt sterilize"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -153,6 +152,7 @@
"auto-release-sinon": "1.0.3",
"babel-eslint": "4.1.8",
"chokidar": "1.4.3",
"dot": "1.0.3",
"elasticdump": "2.1.1",
"eslint": "1.10.3",
"eslint-plugin-mocha": "1.1.0",
Expand Down Expand Up @@ -191,7 +191,7 @@
"nock": "2.10.0",
"npm": "2.11.0",
"portscanner": "1.0.0",
"simple-git": "1.8.0",
"simple-git": "1.37.0",
"sinon": "1.17.2",
"source-map": "0.4.4",
"source-map-support": "0.4.0",
Expand Down
1 change: 1 addition & 0 deletions tasks/config/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = function (grunt) {
return {
build: 'build',
target: 'target',
screenshots: 'test/screenshots/session',
testsFromModules: 'build/kibana/node_modules/**/{test,tests}/**',
deepModuleBins: 'build/kibana/node_modules/*/node_modules/**/.bin/{' + modules.join(',') + '}',
deepModules: 'build/kibana/node_modules/*/node_modules/**/{' + modules.join(',') + '}/',
Expand Down
17 changes: 15 additions & 2 deletions tasks/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
var _ = require('lodash');
const _ = require('lodash');
const visualRegression = require('../utilities/visual_regression');

module.exports = function (grunt) {
grunt.registerTask(
'test:visualRegression',
'Compare screenshots and generate diff images.',
function () {
const done = this.async();
visualRegression.run(done);
}
);

grunt.registerTask('test:server', [ 'esvm:test', 'simplemocha:all', 'esvm_shutdown:test' ]);
grunt.registerTask('test:browser', [ 'run:testServer', 'karma:unit' ]);
grunt.registerTask('test:coverage', [ 'run:testCoverageServer', 'karma:coverage' ]);
Expand All @@ -21,6 +32,7 @@ module.exports = function (grunt) {
'run:testUIServer',
'downloadSelenium',
'run:seleniumServer',
'clean:screenshots',
'intern:dev',
'esvm_shutdown:ui',
'stop:seleniumServer',
Expand All @@ -35,6 +47,7 @@ module.exports = function (grunt) {
]);

grunt.registerTask('test:ui:runner', [
'clean:screenshots',
'intern:dev'
]);

Expand All @@ -55,7 +68,7 @@ module.exports = function (grunt) {
'intern:api'
]);

grunt.registerTask('test', function (subTask) {
grunt.registerTask('test', subTask => {
if (subTask) grunt.fail.fatal(`invalid task "test:${subTask}"`);

grunt.task.run(_.compact([
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/settings/_index_pattern_results_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bdd.describe('index result field sort', function describeIndexTests() {
return col.selector();
})
.then(function (rowText) {
common.saveScreenshot(`Settings-indices-column-${col.heading}-sort-ascending.png`);
common.saveScreenshot(`Settings-indices-column-${col.heading}-sort-ascending`);
expect(rowText).to.be(col.first);
});
});
Expand All @@ -65,7 +65,7 @@ bdd.describe('index result field sort', function describeIndexTests() {
return col.selector();
})
.then(function (rowText) {
common.saveScreenshot(`Settings-indices-column-${col.heading}-sort-descending.png`);
common.saveScreenshot(`Settings-indices-column-${col.heading}-sort-descending`);
expect(rowText).to.be(col.last);
});
});
Expand Down
1 change: 0 additions & 1 deletion test/functional/apps/visualize/_metric_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ bdd.describe('visualize app', function describeIndexTests() {
var toTime = '2015-09-23 18:31:44.000';

bdd.before(function () {
var vizName1 = 'Visualization MetricChart';
common.debug('navigateToApp visualize');
return common.navigateToApp('visualize')
.then(function () {
Expand Down
1 change: 0 additions & 1 deletion test/screenshots/visual_regression_gallery.html

This file was deleted.

43 changes: 0 additions & 43 deletions utilities/compareScreenshots.js

This file was deleted.

Loading

0 comments on commit 9e353fd

Please sign in to comment.