snapshot updates

This commit is contained in:
Adam Bradley
2015-04-02 15:02:15 -05:00
parent cdce613756
commit 3186e0838d
4 changed files with 55 additions and 7 deletions

View File

@ -6,7 +6,7 @@ var IonicSnapshot = function(options) {
var _ = require('lodash'); var _ = require('lodash');
var request = require('request'); var request = require('request');
var colors = require('gulp-util').colors; var colors = require('gulp-util').colors;
var log = console.log.bind(console, '[' + colors.cyan('IonicReporter') + ']'); var log = console.log.bind(console, colors.cyan('Snapshot') + ':');
var IonicReporter = function(options) { var IonicReporter = function(options) {
var self = this; var self = this;
@ -24,6 +24,8 @@ var IonicSnapshot = function(options) {
self.height = browser.params.height || -1; self.height = browser.params.height || -1;
self.highestMismatch = 0; self.highestMismatch = 0;
self.screenshotRequestPromises = []; self.screenshotRequestPromises = [];
self.results = {};
self.mismatches = [];
self.flow = protractor.promise.controlFlow(); self.flow = protractor.promise.controlFlow();
@ -51,7 +53,29 @@ var IonicSnapshot = function(options) {
}); });
}); });
process.on('exit', function() { process.on('exit', function() {
log(colors.green('Highest Mismatch:'), self.highestMismatch, '%'); if (self.highestMismatch > 1) {
log(colors.red('Highest Mismatch: ' + self.highestMismatch + '%'));
} else if (self.highestMismatch > 0) {
log(colors.yellow('Highest Mismatch: ' + self.highestMismatch + '%'));
} else {
log(colors.green('No Mismatches!!'));
}
if (!self.mismatches.length) return;
self.mismatches.sort();
for (var x = 0; x < self.mismatches.length; x++) {
var result = self.results[self.mismatches[x]];
if (result.mismatch > 1) {
log(colors.red('Mismatch:'), colors.red(result.mismatch + '%'), result.name);
} else {
log(colors.yellow('Mismatch:'), colors.yellow(result.mismatch + '%'), result.name);
}
log(' ', colors.gray(result.compareUrl));
}
}); });
log('init:', _.pick(self, ['testId', 'appId', 'width', 'height', 'platformId'])); log('init:', _.pick(self, ['testId', 'appId', 'width', 'height', 'platformId']));
@ -93,10 +117,33 @@ var IonicSnapshot = function(options) {
'http://' + self.domain + '/screenshot', 'http://' + self.domain + '/screenshot',
{ form: self.testData }, { form: self.testData },
function (error, response, body) { function (error, response, body) {
log(specIdString, 'reportSpecResults:', body);
try { try {
var rspData = JSON.parse(body); var rspData = JSON.parse(body);
self.highestMismatch = Math.max(self.highestMismatch, rspData.Mismatch); self.highestMismatch = Math.max(self.highestMismatch, rspData.Mismatch);
var mismatch = Math.round(rspData.Mismatch * 100) / 100;
if (rspData.Mismatch > 1) {
log(specIdString, colors.red('Mismatch: ' + mismatch + '%'));
} else if (rspData.Mismatch > 0) {
log(specIdString, colors.yellow('Mismatch: ' + mismatch + '%'));
} else {
log(specIdString, colors.green('Mismatch: ' + mismatch + '%'));
}
var resultKey = (((rspData.Mismatch * 1000) + 1000000) + '').split('.')[0] + '-' + spec.id;
self.results[resultKey] = {
index: spec.id,
name: spec.getFullName(),
mismatch: mismatch,
compareUrl: rspData.CompareUrl,
screenshotUrl: rspData.ScreenshotUrl,
};
if (rspData.IsMismatch) {
self.mismatches.push(resultKey);
}
} catch(e) { } catch(e) {
log(specIdString, colors.red('reportSpecResults', 'error posting screenshot:'), e); log(specIdString, colors.red('reportSpecResults', 'error posting screenshot:'), e);
} }

View File

@ -2,14 +2,14 @@
var buildConfig = require('../build/config'); var buildConfig = require('../build/config');
var path = require('canonical-path'); var path = require('canonical-path');
var projectRoot = path.resolve(__dirname, '../..'); var projectRoot = path.resolve(__dirname, '../..');
var snapshotConfig = require('./snapshot.config').config;
exports.config = { exports.config = {
// Spec patterns are relative to the location of the spec file. They may // Spec patterns are relative to the location of the spec file. They may
// include glob patterns. // include glob patterns.
specs: [ specs: [
path.resolve(projectRoot, 'dist/e2e/**/*e2e.js'), path.resolve(projectRoot, snapshotConfig.specs)
//path.resolve(projectRoot, 'dist/e2e/toolbar/**/*e2e.js'),
], ],
// Options to be passed to Jasmine-node. // Options to be passed to Jasmine-node.
@ -26,7 +26,6 @@ exports.config = {
patchProtractorWait(global.browser); patchProtractorWait(global.browser);
}); });
var snapshotConfig = require('./snapshot.config').config;
var ionicSnapshot = require('./ionic.snapshot'); var ionicSnapshot = require('./ionic.snapshot');
ionicSnapshot(snapshotConfig); ionicSnapshot(snapshotConfig);
} }

View File

@ -5,6 +5,8 @@ exports.config = {
appId: 'snapshots', appId: 'snapshots',
//domain: 'localhost:8080', //domain: 'localhost:8080',
domain: 'ionic-snapshot-go.appspot.com', domain: 'ionic-snapshot-go.appspot.com',
specs: 'dist/e2e/**/*e2e.js',
//specs: 'dist/e2e/action-menu/**/*e2e.js',
accessKey: process.env.IONIC_SNAPSHOT_KEY accessKey: process.env.IONIC_SNAPSHOT_KEY
}; };

View File

@ -27,7 +27,7 @@ module.exports = function(gulp, argv, buildConfig) {
browser: 'chrome', browser: 'chrome',
platform: 'linux', platform: 'linux',
params: { params: {
platform_id: 'chrome_local_test', platform_id: 'chrome_local',
platform_index: 0, platform_index: 0,
platform_count: 1, platform_count: 1,
width: 400, width: 400,