mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
snapshot updates
This commit is contained in:
@ -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('Snapshot') + ':');
|
var log = console.log.bind(console);
|
||||||
|
|
||||||
var IonicReporter = function(options) {
|
var IonicReporter = function(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -15,17 +15,18 @@ var IonicSnapshot = function(options) {
|
|||||||
self.domain = options.domain || 'ionic-snapshot-go.appspot.com';
|
self.domain = options.domain || 'ionic-snapshot-go.appspot.com';
|
||||||
self.groupId = options.groupId || 'test_group';
|
self.groupId = options.groupId || 'test_group';
|
||||||
self.appId = options.appId || 'test_app';
|
self.appId = options.appId || 'test_app';
|
||||||
|
self.sleepBetweenSpecs = options.sleepBetweenSpecs || 750;
|
||||||
self.testId = browser.params.test_id || 'test_id';
|
self.testId = browser.params.test_id || 'test_id';
|
||||||
self.platformId = browser.params.platform_id;
|
self.platformId = browser.params.platform_id;
|
||||||
self.platformIndex = browser.params.platform_index;
|
self.platformIndex = browser.params.platform_index;
|
||||||
self.platformCount = browser.params.platform_count;
|
self.platformCount = browser.params.platform_count;
|
||||||
self.sleepBetweenSpecs = options.sleepBetweenSpecs || 750;
|
|
||||||
self.width = browser.params.width || -1;
|
self.width = browser.params.width || -1;
|
||||||
self.height = browser.params.height || -1;
|
self.height = browser.params.height || -1;
|
||||||
self.highestMismatch = 0;
|
|
||||||
self.screenshotRequestPromises = [];
|
self.screenshotRequestPromises = [];
|
||||||
self.results = {};
|
self.results = {};
|
||||||
self.mismatches = [];
|
self.mismatches = [];
|
||||||
|
self.highestMismatch = 0;
|
||||||
|
|
||||||
self.flow = protractor.promise.controlFlow();
|
self.flow = protractor.promise.controlFlow();
|
||||||
|
|
||||||
@ -78,7 +79,9 @@ var IonicSnapshot = function(options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log('init:', _.pick(self, ['testId', 'appId', 'width', 'height', 'platformId']));
|
log(colors.green('Start Snapshot:'),
|
||||||
|
self.groupId, self.appId, self.testId, self.platformId, '(' + self.width + 'x' + self.height + ')');
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IonicReporter.prototype.reportSpecResults = function(spec) {
|
IonicReporter.prototype.reportSpecResults = function(spec) {
|
||||||
@ -101,7 +104,6 @@ var IonicSnapshot = function(options) {
|
|||||||
|
|
||||||
browser.takeScreenshot().then(function(pngBase64) {
|
browser.takeScreenshot().then(function(pngBase64) {
|
||||||
var specIdString = '[' + (spec.id+1) + '/' + self.testData.total_specs + ']';
|
var specIdString = '[' + (spec.id+1) + '/' + self.testData.total_specs + ']';
|
||||||
log(specIdString, spec.getFullName());
|
|
||||||
|
|
||||||
self.testData.spec_index = spec.id;
|
self.testData.spec_index = spec.id;
|
||||||
self.testData.description = spec.getFullName();
|
self.testData.description = spec.getFullName();
|
||||||
@ -124,11 +126,11 @@ var IonicSnapshot = function(options) {
|
|||||||
var mismatch = Math.round(rspData.Mismatch * 100) / 100;
|
var mismatch = Math.round(rspData.Mismatch * 100) / 100;
|
||||||
|
|
||||||
if (rspData.Mismatch > 1) {
|
if (rspData.Mismatch > 1) {
|
||||||
log(specIdString, colors.red('Mismatch: ' + mismatch + '%'));
|
log(specIdString, colors.red('Mismatch: ' + mismatch + '%'), colors.gray(spec.getFullName()));
|
||||||
} else if (rspData.Mismatch > 0) {
|
} else if (rspData.Mismatch > 0) {
|
||||||
log(specIdString, colors.yellow('Mismatch: ' + mismatch + '%'));
|
log(specIdString, colors.yellow('Mismatch: ' + mismatch + '%'), colors.gray(spec.getFullName()));
|
||||||
} else {
|
} else {
|
||||||
log(specIdString, colors.green('Mismatch: ' + mismatch + '%'));
|
log(specIdString, colors.green('Mismatch: ' + mismatch + '%'), colors.gray(spec.getFullName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultKey = (((rspData.Mismatch * 1000) + 1000000) + '').split('.')[0] + '-' + spec.id;
|
var resultKey = (((rspData.Mismatch * 1000) + 1000000) + '').split('.')[0] + '-' + spec.id;
|
||||||
|
@ -2,11 +2,29 @@
|
|||||||
exports.config = {
|
exports.config = {
|
||||||
|
|
||||||
groupId: 'ionic2',
|
groupId: 'ionic2',
|
||||||
|
|
||||||
appId: 'snapshots',
|
appId: 'snapshots',
|
||||||
//domain: 'localhost:8080',
|
|
||||||
domain: 'ionic-snapshot-go.appspot.com',
|
domain: 'ionic-snapshot-go.appspot.com',
|
||||||
|
//domain: 'localhost:8080',
|
||||||
|
|
||||||
specs: 'dist/e2e/**/*e2e.js',
|
specs: 'dist/e2e/**/*e2e.js',
|
||||||
//specs: 'dist/e2e/action-menu/**/*e2e.js',
|
//specs: 'dist/e2e/action-menu/**/*e2e.js',
|
||||||
|
|
||||||
|
sleepBetweenSpecs: 1000,
|
||||||
|
|
||||||
|
platformDefauls: {
|
||||||
|
browser: 'chrome',
|
||||||
|
platform: 'linux',
|
||||||
|
params: {
|
||||||
|
platform_id: 'chrome_local',
|
||||||
|
platform_index: 0,
|
||||||
|
platform_count: 1,
|
||||||
|
width: 400,
|
||||||
|
height: 800
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
accessKey: process.env.IONIC_SNAPSHOT_KEY
|
accessKey: process.env.IONIC_SNAPSHOT_KEY
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
|
||||||
|
module.exports = function(gulp, argv, buildConfig) {
|
||||||
|
|
||||||
|
var snapshotConfig = require('./snapshot.config').config;
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var connect = require('connect');
|
var connect = require('connect');
|
||||||
@ -7,11 +11,9 @@ var path = require('canonical-path');
|
|||||||
var uuid = require('node-uuid');
|
var uuid = require('node-uuid');
|
||||||
|
|
||||||
var projectRoot = path.resolve(__dirname, '../..');
|
var projectRoot = path.resolve(__dirname, '../..');
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(gulp, argv, buildConfig) {
|
|
||||||
|
|
||||||
var protractorHttpServer;
|
var protractorHttpServer;
|
||||||
|
var snapshotValues = _.merge(snapshotConfig.platformDefauls, argv);
|
||||||
|
|
||||||
gulp.task('protractor-server', function() {
|
gulp.task('protractor-server', function() {
|
||||||
var app = connect().use(serveStatic(projectRoot + '/' + buildConfig.dist)); // serve everything that is static
|
var app = connect().use(serveStatic(projectRoot + '/' + buildConfig.dist)); // serve everything that is static
|
||||||
protractorHttpServer = http.createServer(app).listen(buildConfig.protractorPort);
|
protractorHttpServer = http.createServer(app).listen(buildConfig.protractorPort);
|
||||||
@ -23,20 +25,9 @@ module.exports = function(gulp, argv, buildConfig) {
|
|||||||
snapshot(done, protractorConfigFile);
|
snapshot(done, protractorConfigFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
var snapshotValues = _.merge({
|
|
||||||
browser: 'chrome',
|
|
||||||
platform: 'linux',
|
|
||||||
params: {
|
|
||||||
platform_id: 'chrome_local',
|
|
||||||
platform_index: 0,
|
|
||||||
platform_count: 1,
|
|
||||||
width: 400,
|
|
||||||
height: 800,
|
|
||||||
test_id: uuid.v4().split('-')[0]
|
|
||||||
}
|
|
||||||
}, argv);
|
|
||||||
|
|
||||||
function snapshot(done, protractorConfigFile) {
|
function snapshot(done, protractorConfigFile) {
|
||||||
|
snapshotValues.params.test_id = uuid.v4().split('-')[0];
|
||||||
|
|
||||||
var protractorArgs = [
|
var protractorArgs = [
|
||||||
'--browser <%= browser %>',
|
'--browser <%= browser %>',
|
||||||
'--platform <%= platform %>',
|
'--platform <%= platform %>',
|
||||||
@ -56,8 +47,6 @@ module.exports = function(gulp, argv, buildConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function protractor(done, args) {
|
function protractor(done, args) {
|
||||||
console.log('Start protractor:', snapshotValues.params.test_id);
|
|
||||||
|
|
||||||
var child = cp.spawn('protractor', args, {
|
var child = cp.spawn('protractor', args, {
|
||||||
stdio: [process.stdin, process.stdout, 'pipe']
|
stdio: [process.stdin, process.stdout, 'pipe']
|
||||||
});
|
});
|
||||||
@ -76,9 +65,7 @@ module.exports = function(gulp, argv, buildConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function e2ePublish(testId) {
|
function e2ePublish(testId) {
|
||||||
var snapshotConfig = require('./snapshot.config').config;
|
|
||||||
snapshotConfig.testId = testId;
|
snapshotConfig.testId = testId;
|
||||||
|
|
||||||
require('../e2e/e2e-publish')(snapshotConfig);
|
require('../e2e/e2e-publish')(snapshotConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user