110 lines
4.1 KiB
JavaScript
110 lines
4.1 KiB
JavaScript
9 years ago
|
/* global process */
|
||
|
var WebDriver = require("selenium-webdriver");
|
||
8 years ago
|
var nThen = require('nthen');
|
||
9 years ago
|
|
||
8 years ago
|
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
||
|
// We can't do saucelabs on pull requests so don't fail.
|
||
|
return;
|
||
|
}
|
||
|
|
||
8 years ago
|
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
|
||
9 years ago
|
var driver;
|
||
|
if (process.env.SAUCE_USERNAME !== undefined) {
|
||
|
var browserArray = process.env.BROWSER.split(':');
|
||
9 years ago
|
driver = new WebDriver.Builder().usingServer(
|
||
|
'http://'+ process.env.SAUCE_USERNAME+':'+process.env.SAUCE_ACCESS_KEY+'@ondemand.saucelabs.com:80/wd/hub'
|
||
|
).withCapabilities({
|
||
|
"tunnel-identifier": process.env.TRAVIS_JOB_NUMBER,
|
||
9 years ago
|
"build": process.env.TRAVIS_JOB_NUMBER,
|
||
9 years ago
|
"username": process.env.SAUCE_USERNAME,
|
||
|
"accessKey": process.env.SAUCE_ACCESS_KEY,
|
||
9 years ago
|
}).forBrowser(browserArray[0], browserArray[1], browserArray[2]).build();
|
||
9 years ago
|
} else {
|
||
7 years ago
|
driver = new WebDriver.Builder().withCapabilities({
|
||
|
browserName: process.env.BROWSER || "chrome"
|
||
|
}).build();
|
||
9 years ago
|
}
|
||
|
|
||
8 years ago
|
var SC_GET_DATA = "return (window.__CRYPTPAD_TEST__) ? window.__CRYPTPAD_TEST__.getData() : '[]'";
|
||
8 years ago
|
|
||
8 years ago
|
var failed = false;
|
||
7 years ago
|
var nt = nThen(function (waitFor) {
|
||
|
driver.get('http://localhost:3000/auth/').then(waitFor());
|
||
|
}).nThen(function (waitFor) {
|
||
|
console.log('initialized');
|
||
|
driver.manage().addCookie({name: 'test', value: 'auto'}).then(waitFor());
|
||
|
}).nThen;
|
||
|
|
||
8 years ago
|
[
|
||
7 years ago
|
// login test must happen after register test
|
||
7 years ago
|
['/register/', {}],
|
||
7 years ago
|
['/login/', {}],
|
||
|
|
||
7 years ago
|
['/assert/', {}],
|
||
|
['/auth/', {}],
|
||
|
|
||
|
['/pad/#/1/edit/1KXFMz5L+nLgvHqXVJjyiQ/IUAE6IzVVg5UIYFOPglmVxvV/', {}],
|
||
|
['/pad/#/1/view/1KXFMz5L+nLgvHqXVJjyiQ/O4kuSnJyviGVlz3qpcr4Fxc8fIK6uTeB30MfMkh86O8/', {}],
|
||
|
|
||
|
['/code/#/1/edit/CWtkq8Qa2re7W1XvXZRDYg/2G7Gse5UZ8dLyGAXUdCV2fLL/', {}],
|
||
|
['/code/#/1/view/CWtkq8Qa2re7W1XvXZRDYg/G1pVa1EL26JRAjk28b43W7Ftc3AkdBblef1U58F3iDk/', {}],
|
||
|
|
||
|
['/slide/#/1/edit/uwKqgj8Ezh2dRaFUWSlrRQ/JkJtAb-hNzfESZEHreAeULU1/', {}],
|
||
|
['/slide/#/1/view/uwKqgj8Ezh2dRaFUWSlrRQ/Xa8jXl+jWMpwep41mlrhkqbRuVKGxlueH80Pbgeu5Go/', {}],
|
||
|
|
||
7 years ago
|
['/poll/#/1/edit/lHhnKHSs0HBsl2UGfSJoLw/ZXSsAq4BORIixuFaLVBFcxoq/', {}],
|
||
|
['/poll/#/1/view/lHhnKHSs0HBsl2UGfSJoLw/TGul8PhswwLh1klHpBto6yEntWtKES2+tetYrrYec4M/', {}]
|
||
|
|
||
7 years ago
|
].forEach(function (x) {
|
||
8 years ago
|
if (failed) { return; }
|
||
7 years ago
|
var url = 'http://localhost:3000' + x[0];
|
||
8 years ago
|
nt = nt(function (waitFor) {
|
||
|
var done = waitFor();
|
||
|
console.log('\n\n-----TEST ' + url + ' -----');
|
||
|
var waitTo = setTimeout(function () {
|
||
8 years ago
|
console.log("no report in 20 seconds, timing out");
|
||
8 years ago
|
failed = true;
|
||
8 years ago
|
done();
|
||
|
done = undefined;
|
||
|
}, 20000);
|
||
8 years ago
|
var logMore = function () {
|
||
8 years ago
|
if (!done) { return; }
|
||
8 years ago
|
driver.executeScript(SC_GET_DATA).then(waitFor(function (dataS) {
|
||
8 years ago
|
if (!done) { return; }
|
||
8 years ago
|
var data = JSON.parse(dataS);
|
||
|
data.forEach(function (d) {
|
||
|
if (d.type !== 'log') { return; }
|
||
|
console.log('>' + d.val);
|
||
|
});
|
||
|
data.forEach(function (d) {
|
||
|
if (d.type !== 'report') { return; }
|
||
|
console.log('RESULT: ' + d.val);
|
||
|
if (d.val !== 'passed') {
|
||
|
if (d.error) {
|
||
|
console.log(d.error.message);
|
||
|
console.log(d.error.stack);
|
||
|
}
|
||
|
failed = true;
|
||
|
}
|
||
|
clearTimeout(waitTo);
|
||
|
console.log('-----END TEST ' + url + ' -----');
|
||
|
done();
|
||
|
done = undefined;
|
||
|
});
|
||
|
if (done) { setTimeout(logMore, 50); }
|
||
8 years ago
|
}));
|
||
|
};
|
||
7 years ago
|
driver.manage().addCookie({
|
||
|
name: 'test',
|
||
|
value: encodeURIComponent(JSON.stringify({ test:'auto', opts: x[1] }))
|
||
|
});
|
||
8 years ago
|
driver.get(url).then(waitFor(logMore));
|
||
8 years ago
|
}).nThen;
|
||
9 years ago
|
});
|
||
8 years ago
|
|
||
8 years ago
|
nt(function (waitFor) {
|
||
|
driver.quit().then(waitFor(function () {
|
||
|
if (failed) { process.exit(100); }
|
||
|
}));
|
||
8 years ago
|
});
|