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 nt = nThen;
[
//'/register/#?test=test',
'/assert/#?test=test',
// '/auth/#?test=test' // TODO(cjd): Not working on automatic tests, understand why.
'/register/#?test=auto',
//'/assert/#?test=auto',
'/auth/#?test=auto'
].forEach(function (path) {
if (failed) { return; }
var url = 'http://localhost:3000' + path;

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

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

@ -1,7 +1,7 @@
define([], function () {
var out = function () { };
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__ = {
data: [],
getData: function () {
@ -68,8 +68,43 @@ define([], function () {
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 {
out.testing = false;
out.registerInner = function () { };
out.registerOuter = function () { };
}
return out;
});

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

Loading…
Cancel
Save