mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
snapshot updates
This commit is contained in:
17
gulpfile.js
17
gulpfile.js
@ -61,7 +61,6 @@ gulp.task('clean.build', function(done) {
|
||||
'e2e',
|
||||
'sass',
|
||||
'fonts',
|
||||
'vendor',
|
||||
done
|
||||
);
|
||||
})
|
||||
@ -73,7 +72,6 @@ gulp.task('build', function(done) {
|
||||
'e2e',
|
||||
'sass',
|
||||
'fonts',
|
||||
'vendor',
|
||||
done
|
||||
);
|
||||
})
|
||||
@ -86,7 +84,6 @@ gulp.task('watch', function(done) {
|
||||
'e2e',
|
||||
'sass',
|
||||
'fonts',
|
||||
'vendor',
|
||||
'serve',
|
||||
function() {
|
||||
watch(
|
||||
@ -173,9 +170,12 @@ gulp.task('tests', function() {
|
||||
})
|
||||
|
||||
gulp.task('copy-scripts', function(){
|
||||
gulp.src(['scripts/resources/*.js', 'config.js', 'dist/js/ionic.bundle.js',
|
||||
'dist/vendor/web-animations-js/web-animations.min.js'])
|
||||
.pipe(gulp.dest('dist/lib'));
|
||||
gulp.src([
|
||||
'scripts/resources/*.js',
|
||||
'scripts/vendor/web-animations-js/web-animations.min.js',
|
||||
'config.js',
|
||||
'dist/js/ionic.bundle.js'
|
||||
]).pipe(gulp.dest('dist/lib'));
|
||||
})
|
||||
|
||||
gulp.task('e2e', ['copy-scripts'], function() {
|
||||
@ -279,11 +279,6 @@ gulp.task('fonts', function() {
|
||||
.pipe(gulp.dest('dist/fonts'));
|
||||
});
|
||||
|
||||
gulp.task('vendor', function() {
|
||||
return gulp.src(['scripts/vendor/**/*'])
|
||||
.pipe(gulp.dest('dist/vendor'));
|
||||
});
|
||||
|
||||
require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig);
|
||||
|
||||
gulp.task('karma', function() {
|
||||
|
@ -8,13 +8,13 @@ import {ThirdPage} from './third-page';
|
||||
@IonicView({
|
||||
template: '' +
|
||||
'<ion-navbar *navbar primary>' +
|
||||
'<ion-title>First Page: {{ val }}</ion-title>' +
|
||||
'<ion-title>First Page</ion-title>' +
|
||||
'<ion-nav-items secondary>' +
|
||||
'<button>S1</button>' +
|
||||
'</ion-nav-items>' +
|
||||
'</ion-navbar>' +
|
||||
'<ion-content class="padding">' +
|
||||
'<p>First Page: {{ val }}</p>' +
|
||||
'<p>First Page</p>' +
|
||||
'<p><button id="from1To2" primary (click)="push()">Push (Go to 2nd)</button></p>' +
|
||||
'<p><button primary [push-data]="pushData" [nav-push]="pushPage">Push w/ nav-push (Go to 2nd)</button></p>' +
|
||||
'<p><button primary (click)="setItems()">setItems() (Go to 3rd, no history)</button></p>' +
|
||||
@ -29,10 +29,7 @@ export class FirstPage {
|
||||
app: IonicApp,
|
||||
config: IonicConfig
|
||||
) {
|
||||
console.log('FirstPage constructor');
|
||||
|
||||
this.nav = nav;
|
||||
this.val = Math.round(Math.random() * 8999) + 1000;
|
||||
|
||||
this.pushPage = SecondPage;
|
||||
this.pushData = {
|
||||
|
@ -11,7 +11,6 @@ import {FirstPage} from './first-page';
|
||||
<p><button id="from2To1" primary nav-pop>Pop with NavPop (Go back to 1st)</button></p>
|
||||
<p><button id="from2To3" primary (click)="push()">Push (Go to 3rd)</button></p>
|
||||
<p><button primary (click)="setItems()">setItems() (Go to 3rd, FirstPage 1st in history)</button></p>
|
||||
<p>Random: {{ val }}</p>
|
||||
<div class="green"><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f></div>
|
||||
</ion-content>
|
||||
`
|
||||
@ -23,7 +22,6 @@ export class SecondPage {
|
||||
) {
|
||||
this.nav = nav;
|
||||
this.params = params;
|
||||
this.val = Math.round(Math.random() * 8999) + 1000;
|
||||
|
||||
console.log('Second page params:', params);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ module.exports = function(options) {
|
||||
var path = require('path');
|
||||
var request = require('request');
|
||||
var inputDir = path.join(__dirname, '../../dist');
|
||||
|
||||
var uploadQueue = [];
|
||||
|
||||
function uploadFiles(dir, urlPath) {
|
||||
fs.readdir(dir, function(err, list) {
|
||||
@ -26,27 +26,60 @@ module.exports = function(options) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
setTimeout(postNextUpload, 100);
|
||||
}
|
||||
|
||||
function uploadFile(archiveFileUrlPath, archiveFileLocalPath) {
|
||||
var formData = {
|
||||
uploadQueue.push({
|
||||
url_path: archiveFileUrlPath,
|
||||
local_path: archiveFileLocalPath,
|
||||
group_id: options.groupId,
|
||||
app_id: options.appId,
|
||||
test_id: options.testId,
|
||||
access_key: process.env.IONIC_SNAPSHOT_KEY
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function postNextUpload() {
|
||||
var uploadData = null;
|
||||
|
||||
var totalUploading = 0;
|
||||
|
||||
for (var i = 0; i < uploadQueue.length; i++) {
|
||||
if (uploadQueue[i].status === 'uploaded') {
|
||||
continue;
|
||||
|
||||
} else if (uploadQueue[i].status === 'uploading') {
|
||||
totalUploading++;
|
||||
continue;
|
||||
|
||||
} else {
|
||||
uploadData = uploadQueue[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (!uploadData || totalUploading > 20) {
|
||||
return;
|
||||
|
||||
} else if (options.verbose) {
|
||||
console.log('Uploading: ' + uploadData.url_path);
|
||||
}
|
||||
|
||||
uploadData.status = 'uploading';
|
||||
|
||||
request.post({
|
||||
uri: 'http://' + options.domain + '/e2e/upload-url',
|
||||
formData: formData
|
||||
formData: uploadData
|
||||
},
|
||||
function(err, httpResponse, body) {
|
||||
if (err) {
|
||||
uploadData.status = 'failed';
|
||||
console.error('Get upload failed:', err);
|
||||
|
||||
} else {
|
||||
if (httpResponse.statusCode == 200) {
|
||||
uploadE2E(body, archiveFileUrlPath, archiveFileLocalPath);
|
||||
uploadE2E(body, uploadData);
|
||||
} else {
|
||||
console.error('Get upload error:', httpResponse.statusCode, body);
|
||||
}
|
||||
@ -55,9 +88,9 @@ module.exports = function(options) {
|
||||
);
|
||||
}
|
||||
|
||||
function uploadE2E(uploadUrl, archiveFileUrlPath, archiveFileLocalPath) {
|
||||
function uploadE2E(uploadUrl, uploadData) {
|
||||
var formData = {
|
||||
file: fs.createReadStream(archiveFileLocalPath)
|
||||
file: fs.createReadStream(uploadData.local_path)
|
||||
};
|
||||
|
||||
request.post({
|
||||
@ -65,11 +98,22 @@ module.exports = function(options) {
|
||||
formData: formData
|
||||
},
|
||||
function(err, httpResponse, body) {
|
||||
setTimeout(postNextUpload, 100);
|
||||
|
||||
if (err) {
|
||||
console.error('Upload failed:', err);
|
||||
uploadData.status = 'failed';
|
||||
|
||||
} else {
|
||||
if (httpResponse.statusCode == 200) {
|
||||
uploadData.status = 'uploaded';
|
||||
|
||||
if (options.verbose) {
|
||||
console.error('Uploaded:', uploadData.url_path);
|
||||
}
|
||||
} else {
|
||||
if (httpResponse.statusCode != 200) {
|
||||
console.error('Upload error:', httpResponse.statusCode, body);
|
||||
uploadData.status = 'failed';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,17 @@ module.exports = function(gulp, argv, buildConfig) {
|
||||
snapshot(done, true);
|
||||
});
|
||||
|
||||
gulp.task('e2e-publish', function(done) {
|
||||
var testId = uuid.v4().split('-')[0];
|
||||
e2ePublish(testId, true);
|
||||
});
|
||||
|
||||
function snapshot(done, quickMode) {
|
||||
var testId = uuid.v4().split('-')[0];
|
||||
|
||||
var protractorConfigFile = path.resolve(projectRoot, 'scripts/snapshot/protractor.config.js');
|
||||
|
||||
snapshotValues.params.test_id = uuid.v4().split('-')[0];
|
||||
snapshotValues.params.test_id = testId;
|
||||
snapshotValues.params.upload = !quickMode;
|
||||
|
||||
var protractorArgs = [
|
||||
@ -48,9 +55,7 @@ module.exports = function(gulp, argv, buildConfig) {
|
||||
return _.template(argument, snapshotValues);
|
||||
});
|
||||
|
||||
if (!quickMode) {
|
||||
e2ePublish(snapshotValues.params.test_id);
|
||||
}
|
||||
e2ePublish(testId, false);
|
||||
|
||||
return protractor(done, [protractorConfigFile].concat(protractorArgs));
|
||||
}
|
||||
@ -73,9 +78,10 @@ module.exports = function(gulp, argv, buildConfig) {
|
||||
});
|
||||
}
|
||||
|
||||
function e2ePublish(testId) {
|
||||
function e2ePublish(testId, verbose) {
|
||||
console.log('e2ePublish: ' + testId);
|
||||
snapshotConfig.testId = testId;
|
||||
snapshotConfig.verbose = verbose;
|
||||
require('../e2e/e2e-publish')(snapshotConfig);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user