mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
upload e2e tests
This commit is contained in:
81
scripts/e2e/e2e-publish.js
Normal file
81
scripts/e2e/e2e-publish.js
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
|
||||||
|
module.exports = function(options) {
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var request = require('request');
|
||||||
|
var inputDir = path.join(__dirname, '../../dist');
|
||||||
|
|
||||||
|
|
||||||
|
function uploadFiles(dir, urlPath) {
|
||||||
|
fs.readdir(dir, function(err, list) {
|
||||||
|
|
||||||
|
list.forEach(function(file) {
|
||||||
|
var url = urlPath + '/' + file
|
||||||
|
|
||||||
|
if (url.indexOf('/test/') > -1) return;
|
||||||
|
|
||||||
|
fs.stat(dir + '/' + file, function(err, stat) {
|
||||||
|
if (stat && stat.isDirectory()) {
|
||||||
|
uploadFiles(dir + '/' + file, urlPath + '/' + file);
|
||||||
|
} else {
|
||||||
|
uploadFile(url, dir + '/' + file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadFile(archiveFileUrlPath, archiveFileLocalPath) {
|
||||||
|
var formData = {
|
||||||
|
url_path: archiveFileUrlPath,
|
||||||
|
group_id: options.groupId,
|
||||||
|
app_id: options.appId,
|
||||||
|
test_id: options.testId,
|
||||||
|
access_key: process.env.IONIC_SNAPSHOT_KEY
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post({
|
||||||
|
url: options.domain + '/e2e/upload-url',
|
||||||
|
formData: formData
|
||||||
|
},
|
||||||
|
function(err, httpResponse, body) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Get upload failed:', err);
|
||||||
|
} else {
|
||||||
|
if (httpResponse.statusCode == 200) {
|
||||||
|
uploadE2E(body, archiveFileUrlPath, archiveFileLocalPath);
|
||||||
|
} else {
|
||||||
|
console.error('Get upload error:', httpResponse.statusCode, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadE2E(uploadUrl, archiveFileUrlPath, archiveFileLocalPath) {
|
||||||
|
var formData = {
|
||||||
|
file: fs.createReadStream(archiveFileLocalPath)
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post({
|
||||||
|
url: uploadUrl,
|
||||||
|
formData: formData
|
||||||
|
},
|
||||||
|
function(err, httpResponse, body) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Upload failed:', err);
|
||||||
|
} else {
|
||||||
|
if (httpResponse.statusCode != 200) {
|
||||||
|
console.error('Upload error:', httpResponse.statusCode, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadFiles(inputDir, '');
|
||||||
|
};
|
||||||
|
|
@ -23,6 +23,16 @@ module.exports = function(gulp, argv, buildConfig) {
|
|||||||
snapshot(done, configFile);
|
snapshot(done, configFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('e2e-publish', function(done) {
|
||||||
|
var e2ePublish = require('../e2e/e2e-publish');
|
||||||
|
e2ePublish({
|
||||||
|
domain: 'http://ionic-snapshot-go.appspot.com',
|
||||||
|
groupId: 'ionic2',
|
||||||
|
appId: 'snapshot',
|
||||||
|
testId: uuid.v4()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var snapshotValues = _.merge({
|
var snapshotValues = _.merge({
|
||||||
browser: 'chrome',
|
browser: 'chrome',
|
||||||
platform: 'linux',
|
platform: 'linux',
|
||||||
|
Reference in New Issue
Block a user