Delicious testing

pull/1/head
Caleb James DeLisle 8 years ago
parent 7b94106bac
commit 24f37ea414

@ -1,5 +1,6 @@
/* global process */ /* global process */
var WebDriver = require("selenium-webdriver"); var WebDriver = require("selenium-webdriver");
var nThen = require('nthen');
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') { if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
// We can't do saucelabs on pull requests so don't fail. // We can't do saucelabs on pull requests so don't fail.
@ -21,12 +22,18 @@ if (process.env.SAUCE_USERNAME !== undefined) {
driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build(); driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build();
} }
driver.get('http://localhost:3000/assert/'); var nt = nThen;
[
'/assert/',
'/auth/#?test=test'
].forEach(function (path) {
var url = 'http://localhost:3000' + path;
nt = nThen(function (waitFor) {
driver.get(url);
var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000); var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
report.getAttribute("class").then(function (cls) { report.getAttribute("class").then(waitFor(function (cls) {
report.getText().then(function (text) { report.getText().then(waitFor(function (text) {
console.log("\n-----\n" + text + "\n-----"); console.log("\n-----\n" + url + ' ' + text + "\n-----");
driver.quit();
if (!cls) { if (!cls) {
throw new Error("cls is null"); throw new Error("cls is null");
} else if (cls.indexOf("failure") !== -1) { } else if (cls.indexOf("failure") !== -1) {
@ -34,5 +41,11 @@ report.getAttribute("class").then(function (cls) {
} else if (cls.indexOf("success") === -1) { } else if (cls.indexOf("success") === -1) {
throw new Error("cls does not contain the word success"); throw new Error("cls does not contain the word success");
} }
}));
}));
}).nThen;
}); });
});
nt(function () {
driver.quit();
})

@ -1,8 +1,9 @@
define([ define([
'jquery', 'jquery',
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/test.js',
'/bower_components/tweetnacl/nacl-fast.min.js' '/bower_components/tweetnacl/nacl-fast.min.js'
], function ($, Cryptpad) { ], function ($, Cryptpad, Test) {
var Nacl = window.nacl; var Nacl = window.nacl;
var signMsg = function (msg, privKey) { var signMsg = function (msg, privKey) {
@ -23,6 +24,11 @@ define([
Cryptpad.ready(function () { Cryptpad.ready(function () {
console.log('IFRAME READY'); console.log('IFRAME READY');
Test(function () {
// This is only here to maybe trigger an error.
window.drive = Cryptpad.getStore().getProxy().proxy['drive'];
Test.passed();
});
$(window).on("message", function (jqe) { $(window).on("message", function (jqe) {
var evt = jqe.originalEvent; var evt = jqe.originalEvent;
var data = JSON.parse(evt.data); var data = JSON.parse(evt.data);

@ -0,0 +1,30 @@
define([], function () {
var out = function () { };
if (window.location.hash.indexOf("?test=test") > -1) {
window.onerror = function (msg, url, lineNo, columnNo, e) {
document.body.innerHTML = '<div class="report fail">' +
JSON.stringify([
msg,
url,
lineNo,
columnNo,
e ? e.message : null,
e ? e.stack : null
]).replace(/</g, '') +
'</div>';
};
require.onError = function (e) {
document.body.innerHTML = '<div class="report fail">' +
JSON.stringify([
e ? e.message : null,
e ? e.stack : null
]).replace(/</g, '') +
'</div>';
};
out = function (f) { f(); }
}
out.passed = function () {
document.body.innerHTML = '<div class="report success">Test Passed</div>';
}
return out;
});
Loading…
Cancel
Save