Delicious testing

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

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

@ -1,8 +1,9 @@
define([
'jquery',
'/common/cryptpad-common.js',
'/common/test.js',
'/bower_components/tweetnacl/nacl-fast.min.js'
], function ($, Cryptpad) {
], function ($, Cryptpad, Test) {
var Nacl = window.nacl;
var signMsg = function (msg, privKey) {
@ -23,6 +24,11 @@ define([
Cryptpad.ready(function () {
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) {
var evt = jqe.originalEvent;
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