nav/tabs snapshot tests

This commit is contained in:
Adam Bradley
2015-07-23 10:52:46 -05:00
parent 9d5b22cb3b
commit f1c8e1fba6
10 changed files with 68 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ var IonicSnapshot = function(options) {
self.appId = options.appId || 'test_app';
self.sleepBetweenSpecs = options.sleepBetweenSpecs || 750;
self.testId = browser.params.test_id || 'test_id';
self.shouldUpload = browser.params.upload !== 'false';
self.platformId = browser.params.platform_id;
self.platformIndex = browser.params.platform_index;
self.platformCount = browser.params.platform_count;
@@ -54,6 +55,8 @@ var IonicSnapshot = function(options) {
});
});
process.on('exit', function() {
if (!self.shouldUpload) return;
if (self.highestMismatch > 1) {
log(colors.red('Highest Mismatch: ' + self.highestMismatch + '%'));
} else if (self.highestMismatch > 0) {
@@ -102,6 +105,10 @@ var IonicSnapshot = function(options) {
browser.sleep(self.sleepBetweenSpecs).then(function(){
if (!self.shouldUpload) {
return d.fulfill();
}
browser.takeScreenshot().then(function(pngBase64) {
var specIdString = '[' + (spec.id+1) + '/' + self.testData.total_specs + ']';
@@ -109,7 +116,7 @@ var IonicSnapshot = function(options) {
self.testData.description = spec.getFullName();
self.testData.highest_mismatch = self.highestMismatch;
self.testData.png_base64 = pngBase64;
self.testData.url = currentUrl;
self.testData.url = currentUrl.replace('dist/', '/');
pngBase64 = null;
var requestDeferred = q.defer();
@@ -166,6 +173,8 @@ var IonicSnapshot = function(options) {
IonicReporter.prototype.reportRunnerResults = function() {
var self = this;
if (!self.shouldUpload) return;
self.flow.execute(function() {
var d = protractor.promise.defer();
log('Waiting for all screenshots to be posted...');

View File

@@ -9,7 +9,7 @@ exports.config = {
//domain: 'localhost:8080',
specs: 'dist/e2e/**/*e2e.js',
//specs: 'dist/e2e/action-menu/**/*e2e.js',
//specs: 'dist/e2e/nav/basic/*e2e.js',
sleepBetweenSpecs: 1200,

View File

@@ -21,12 +21,18 @@ module.exports = function(gulp, argv, buildConfig) {
});
gulp.task('snapshot', ['clean.build', 'protractor-server'], function(done) {
var protractorConfigFile = path.resolve(projectRoot, 'scripts/snapshot/protractor.config.js');
snapshot(done, protractorConfigFile);
snapshot(done);
});
function snapshot(done, protractorConfigFile) {
gulp.task('snapshot-quick', ['e2e', 'protractor-server'], function(done) {
snapshot(done, true);
});
function snapshot(done, quickMode) {
var protractorConfigFile = path.resolve(projectRoot, 'scripts/snapshot/protractor.config.js');
snapshotValues.params.test_id = uuid.v4().split('-')[0];
snapshotValues.params.upload = !quickMode;
var protractorArgs = [
'--browser <%= browser %>',
@@ -37,11 +43,14 @@ module.exports = function(gulp, argv, buildConfig) {
'--params.width=<%= params.width %>',
'--params.height=<%= params.height %>',
'--params.test_id=<%= params.test_id %>',
'--params.upload=<%= params.upload %>',
].map(function(argument) {
return _.template(argument, snapshotValues);
});
e2ePublish(snapshotValues.params.test_id);
if (!quickMode) {
e2ePublish(snapshotValues.params.test_id);
}
return protractor(done, [protractorConfigFile].concat(protractorArgs));
}
@@ -65,6 +74,7 @@ module.exports = function(gulp, argv, buildConfig) {
}
function e2ePublish(testId) {
console.log('e2ePublish: ' + testId);
snapshotConfig.testId = testId;
require('../e2e/e2e-publish')(snapshotConfig);
}