Added some nice testing
This commit is contained in:
parent
bb548b3428
commit
6a2d79249d
@ -26,14 +26,30 @@ if (process.env.SAUCE_USERNAME !== undefined) {
|
|||||||
var SC_GET_DATA = "return (window.__CRYPTPAD_TEST__) ? window.__CRYPTPAD_TEST__.getData() : '[]'";
|
var SC_GET_DATA = "return (window.__CRYPTPAD_TEST__) ? window.__CRYPTPAD_TEST__.getData() : '[]'";
|
||||||
|
|
||||||
var failed = false;
|
var failed = false;
|
||||||
var nt = nThen;
|
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;
|
||||||
|
|
||||||
[
|
[
|
||||||
'/register/#?test=auto',
|
['/register/', {}],
|
||||||
//'/assert/#?test=auto',
|
['/assert/', {}],
|
||||||
'/auth/#?test=auto'
|
['/auth/', {}],
|
||||||
].forEach(function (path) {
|
|
||||||
|
['/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/', {}],
|
||||||
|
|
||||||
|
].forEach(function (x) {
|
||||||
if (failed) { return; }
|
if (failed) { return; }
|
||||||
var url = 'http://localhost:3000' + path;
|
var url = 'http://localhost:3000' + x[0];
|
||||||
nt = nt(function (waitFor) {
|
nt = nt(function (waitFor) {
|
||||||
var done = waitFor();
|
var done = waitFor();
|
||||||
console.log('\n\n-----TEST ' + url + ' -----');
|
console.log('\n\n-----TEST ' + url + ' -----');
|
||||||
@ -70,6 +86,10 @@ var nt = nThen;
|
|||||||
if (done) { setTimeout(logMore, 50); }
|
if (done) { setTimeout(logMore, 50); }
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
driver.manage().addCookie({
|
||||||
|
name: 'test',
|
||||||
|
value: encodeURIComponent(JSON.stringify({ test:'auto', opts: x[1] }))
|
||||||
|
});
|
||||||
driver.get(url).then(waitFor(logMore));
|
driver.get(url).then(waitFor(logMore));
|
||||||
}).nThen;
|
}).nThen;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"jshint": "~2.9.1",
|
"jshint": "~2.9.1",
|
||||||
"less": "2.7.1",
|
"less": "2.7.1",
|
||||||
"lesshint": "^4.5.0",
|
"lesshint": "^4.5.0",
|
||||||
"selenium-webdriver": "^2.53.1"
|
"selenium-webdriver": "^3.6.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
|
|||||||
@ -290,6 +290,12 @@ define([
|
|||||||
if (newPad && !AppConfig.displayCreationScreen) {
|
if (newPad && !AppConfig.displayCreationScreen) {
|
||||||
common.openTemplatePicker();
|
common.openTemplatePicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Test.testing) {
|
||||||
|
cpNfInner.chainpad.onSettle(function () {
|
||||||
|
Test.passed();
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
var onConnectionChange = function (info) {
|
var onConnectionChange = function (info) {
|
||||||
stateChange(info.state ? STATE.INITIALIZING : STATE.DISCONNECTED);
|
stateChange(info.state ? STATE.INITIALIZING : STATE.DISCONNECTED);
|
||||||
@ -385,10 +391,7 @@ define([
|
|||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
common.getSframeChannel().onReady(waitFor());
|
common.getSframeChannel().onReady(waitFor());
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
if (common.getMetadataMgr().getPrivateData().isTesting) {
|
Test.registerInner(common.getSframeChannel());
|
||||||
Test.registerInner(common.getSframeChannel());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AppConfig.displayCreationScreen) { return; }
|
if (!AppConfig.displayCreationScreen) { return; }
|
||||||
if (common.getMetadataMgr().getPrivateData().isNewFile) {
|
if (common.getMetadataMgr().getPrivateData().isNewFile) {
|
||||||
common.getPadCreationScreen(waitFor());
|
common.getPadCreationScreen(waitFor());
|
||||||
|
|||||||
@ -213,4 +213,8 @@ define({
|
|||||||
|
|
||||||
// Pad creation screen: create a pad with the selected attributes (owned, expire)
|
// Pad creation screen: create a pad with the selected attributes (owned, expire)
|
||||||
'Q_CREATE_PAD': true,
|
'Q_CREATE_PAD': true,
|
||||||
|
|
||||||
|
// This is for sending data out of the iframe when we are in testing mode
|
||||||
|
// The exact protocol is defined in common/test.js
|
||||||
|
'EV_TESTDATA': true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
define([], function () {
|
define([], function () {
|
||||||
var out = function () { };
|
if (window.__CRYPTPAD_TEST_OBJ_) { return window.__CRYPTPAD_TEST_OBJ_; }
|
||||||
|
var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) { if (out.testing) { f(); } };
|
||||||
out.passed = out.failed = out;
|
out.passed = out.failed = out;
|
||||||
if (window.location.hash.indexOf("test=auto") > -1) {
|
var enableAuto = function () {
|
||||||
|
console.log("Enable auto testing 1 " + window.origin);
|
||||||
|
if (window.__CRYPTPAD_TEST__) { return; }
|
||||||
var cpt = window.__CRYPTPAD_TEST__ = {
|
var cpt = window.__CRYPTPAD_TEST__ = {
|
||||||
data: [],
|
data: [],
|
||||||
getData: function () {
|
getData: function () {
|
||||||
@ -51,8 +54,7 @@ define([], function () {
|
|||||||
error: { message: e.message, stack: e.stack }
|
error: { message: e.message, stack: e.stack }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
out = function (f) { f(); };
|
out.testing = 'auto';
|
||||||
out.testing = true;
|
|
||||||
out.passed = function () {
|
out.passed = function () {
|
||||||
cpt.data.push({
|
cpt.data.push({
|
||||||
type: 'report',
|
type: 'report',
|
||||||
@ -71,13 +73,13 @@ define([], function () {
|
|||||||
|
|
||||||
out.registerInner = function (sframeChan) {
|
out.registerInner = function (sframeChan) {
|
||||||
sframeChan.whenReg('EV_TESTDATA', function () {
|
sframeChan.whenReg('EV_TESTDATA', function () {
|
||||||
cpt.data.forEach(function (x) { sframeChan.fire('EV_TESTDATA', x); });
|
cpt.data.forEach(function (x) { sframeChan.event('EV_TESTDATA', x); });
|
||||||
// override cpt.data.push() with a function which will send the content to the
|
// override cpt.data.push() with a function which will send the content to the
|
||||||
// outside where it will go on the outer window cpt.data array.
|
// outside where it will go on the outer window cpt.data array.
|
||||||
cpt = window.__CRYPTPAD_TEST__ = {
|
cpt = window.__CRYPTPAD_TEST__ = {
|
||||||
data: {
|
data: {
|
||||||
push: function (elem) {
|
push: function (elem) {
|
||||||
sframeChan.fire('EV_TESTDATA', elem);
|
sframeChan.event('EV_TESTDATA', elem);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getData: function () {
|
getData: function () {
|
||||||
@ -89,10 +91,9 @@ define([], function () {
|
|||||||
out.registerOuter = function (sframeChan) {
|
out.registerOuter = function (sframeChan) {
|
||||||
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); });
|
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); });
|
||||||
};
|
};
|
||||||
|
};
|
||||||
} else if (window.location.hash.indexOf("test=manual") > -1) {
|
var enableManual = function () {
|
||||||
out = function (f) { f(); };
|
out.testing = 'manual';
|
||||||
out.testing = true;
|
|
||||||
out.passed = function () {
|
out.passed = function () {
|
||||||
window.alert("Test passed");
|
window.alert("Test passed");
|
||||||
};
|
};
|
||||||
@ -101,10 +102,27 @@ define([], function () {
|
|||||||
};
|
};
|
||||||
out.registerInner = function () { };
|
out.registerInner = function () { };
|
||||||
out.registerOuter = function () { };
|
out.registerOuter = function () { };
|
||||||
} else {
|
};
|
||||||
out.testing = false;
|
|
||||||
out.registerInner = function () { };
|
out.options = {};
|
||||||
out.registerOuter = function () { };
|
out.testing = false;
|
||||||
|
out.registerInner = function () { };
|
||||||
|
out.registerOuter = function () { };
|
||||||
|
|
||||||
|
if (window.location.hash.indexOf("test=auto") > -1) {
|
||||||
|
enableAuto();
|
||||||
|
} else if (window.location.hash.indexOf("test=manual") > -1) {
|
||||||
|
enableManual();
|
||||||
|
} else if (document.cookie.indexOf('test=') === 0) {
|
||||||
|
try {
|
||||||
|
var x = JSON.parse(decodeURIComponent(document.cookie.replace('test=', '')));
|
||||||
|
if (x.test === 'auto') {
|
||||||
|
out.options = x.opts;
|
||||||
|
enableAuto('auto');
|
||||||
|
}
|
||||||
|
console.log("Enable auto testing " + window.origin);
|
||||||
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user