pull/1/head
Caleb James DeLisle 7 years ago
parent 9b6f3b3162
commit 6ac4fa4689

@ -28,9 +28,9 @@ var SC_GET_DATA = "return (window.__CRYPTPAD_TEST__) ? window.__CRYPTPAD_TEST__.
var failed = false; var failed = false;
var nt = nThen; var nt = nThen;
[ [
//'/register/#?test=test', '/register/#?test=auto',
'/assert/#?test=test', //'/assert/#?test=auto',
// '/auth/#?test=test' // TODO(cjd): Not working on automatic tests, understand why. '/auth/#?test=auto'
].forEach(function (path) { ].forEach(function (path) {
if (failed) { return; } if (failed) { return; }
var url = 'http://localhost:3000' + path; var url = 'http://localhost:3000' + path;

@ -12,6 +12,7 @@ define([
'/common/common-feedback.js', '/common/common-feedback.js',
'/customize/application_config.js', '/customize/application_config.js',
'/bower_components/chainpad/chainpad.dist.js', '/bower_components/chainpad/chainpad.dist.js',
'/common/test.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
@ -30,7 +31,8 @@ define([
Thumb, Thumb,
Feedback, Feedback,
AppConfig, AppConfig,
ChainPad) ChainPad,
Test)
{ {
var SaveAs = window.saveAs; var SaveAs = window.saveAs;
@ -383,6 +385,10 @@ 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());
}
if (!AppConfig.displayCreationScreen) { return; } if (!AppConfig.displayCreationScreen) { return; }
if (common.getMetadataMgr().getPrivateData().isNewFile) { if (common.getMetadataMgr().getPrivateData().isNewFile) {
common.getPadCreationScreen(waitFor()); common.getPadCreationScreen(waitFor());

@ -24,6 +24,7 @@ define([
var Notifier; var Notifier;
var Utils = {}; var Utils = {};
var AppConfig; var AppConfig;
var Test;
nThen(function (waitFor) { nThen(function (waitFor) {
// Load #2, the loading screen is up so grab whatever you need... // Load #2, the loading screen is up so grab whatever you need...
@ -45,9 +46,10 @@ define([
'/customize/application_config.js', '/customize/application_config.js',
'/common/outer/network-config.js', '/common/outer/network-config.js',
'/bower_components/netflux-websocket/netflux-client.js', '/bower_components/netflux-websocket/netflux-client.js',
'/common/test.js',
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
_FilePicker, _Messaging, _Notifier, _Hash, _Util, _Realtime, _FilePicker, _Messaging, _Notifier, _Hash, _Util, _Realtime,
_Constants, _Feedback, _LocalStore, _AppConfig, NetConfig, Netflux) { _Constants, _Feedback, _LocalStore, _AppConfig, NetConfig, Netflux, _Test) {
CpNfOuter = _CpNfOuter; CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad; Cryptpad = _Cryptpad;
Crypto = _Crypto; Crypto = _Crypto;
@ -63,6 +65,7 @@ define([
Utils.Feedback = _Feedback; Utils.Feedback = _Feedback;
Utils.LocalStore = _LocalStore; Utils.LocalStore = _LocalStore;
AppConfig = _AppConfig; AppConfig = _AppConfig;
Test = _Test;
if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) { if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) {
console.log("New version, flushing cache"); console.log("New version, flushing cache");
@ -208,6 +211,8 @@ define([
sframeChan.event('EV_LOGOUT'); sframeChan.event('EV_LOGOUT');
}); });
Test.registerOuter(sframeChan);
// Put in the following function the RPC queries that should also work in filepicker // Put in the following function the RPC queries that should also work in filepicker
var addCommonRpc = function (sframeChan) { var addCommonRpc = function (sframeChan) {
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) { sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {

@ -1,7 +1,7 @@
define([], function () { define([], function () {
var out = function () { }; var out = function () { };
out.passed = out.failed = out; out.passed = out.failed = out;
if (window.location.hash.indexOf("?test=test") > -1) { if (window.location.hash.indexOf("test=auto") > -1) {
var cpt = window.__CRYPTPAD_TEST__ = { var cpt = window.__CRYPTPAD_TEST__ = {
data: [], data: [],
getData: function () { getData: function () {
@ -68,8 +68,43 @@ define([], function () {
error: { message: e.message, stack: e.stack } error: { message: e.message, stack: e.stack }
}); });
}; };
out.registerInner = function (sframeChan) {
sframeChan.whenReg('EV_TESTDATA', function () {
cpt.data.forEach(function (x) { sframeChan.fire('EV_TESTDATA', x); });
// 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.
cpt = window.__CRYPTPAD_TEST__ = {
data: {
push: function (elem) {
sframeChan.fire('EV_TESTDATA', elem);
}
},
getData: function () {
throw new Error('getData should never be called from the inside');
}
};
});
};
out.registerOuter = function (sframeChan) {
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); });
};
} else if (window.location.hash.indexOf("test=manual") > -1) {
out = function (f) { f(); };
out.testing = true;
out.passed = function () {
window.alert("Test passed");
};
out.failed = function (reason) {
window.alert("Test failed [" + reason + "]");
};
out.registerInner = function () { };
out.registerOuter = function () { };
} else { } else {
out.testing = false; out.testing = false;
out.registerInner = function () { };
out.registerOuter = function () { };
} }
return out; return out;
}); });

@ -57,7 +57,6 @@ define([
var logMeIn = function (result) { var logMeIn = function (result) {
if (Test.testing) { if (Test.testing) {
Test.passed(); Test.passed();
window.alert("Test passed!");
return; return;
} }
LocalStore.setUserHash(result.userHash); LocalStore.setUserHash(result.userHash);

Loading…
Cancel
Save