Upgrade the testing framework to allow multiple tests
This commit is contained in:
@@ -9,10 +9,12 @@ define([
|
|||||||
'/common/tippy.min.js',
|
'/common/tippy.min.js',
|
||||||
'/customize/pages.js',
|
'/customize/pages.js',
|
||||||
'/common/hyperscript.js',
|
'/common/hyperscript.js',
|
||||||
|
'/common/test.js',
|
||||||
|
|
||||||
'/bower_components/bootstrap-tokenfield/dist/bootstrap-tokenfield.js',
|
'/bower_components/bootstrap-tokenfield/dist/bootstrap-tokenfield.js',
|
||||||
'css!/common/tippy.css',
|
'css!/common/tippy.css',
|
||||||
], function ($, Messages, Util, Hash, Notifier, AppConfig,
|
], function ($, Messages, Util, Hash, Notifier, AppConfig,
|
||||||
Alertify, Tippy, Pages, h) {
|
Alertify, Tippy, Pages, h, Test) {
|
||||||
var UI = {};
|
var UI = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -449,6 +451,10 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
UI.removeLoadingScreen = function (cb) {
|
UI.removeLoadingScreen = function (cb) {
|
||||||
|
// Release the test blocker, hopefully every test has been registered.
|
||||||
|
// This test is created in sframe-boot2.js
|
||||||
|
if (Test.__ASYNC_BLOCKER__) { Test.__ASYNC_BLOCKER__.pass(); }
|
||||||
|
|
||||||
$('#' + LOADING).fadeOut(750, cb);
|
$('#' + LOADING).fadeOut(750, cb);
|
||||||
var $tip = $('#cp-loading-tip').css('top', '')
|
var $tip = $('#cp-loading-tip').css('top', '')
|
||||||
// loading.less sets transition-delay: $wait-time
|
// loading.less sets transition-delay: $wait-time
|
||||||
|
|||||||
@@ -74,6 +74,15 @@ define([
|
|||||||
var contentContainer = options.contentContainer ||
|
var contentContainer = options.contentContainer ||
|
||||||
(function () { throw new Error("contentContainer must be specified"); }());
|
(function () { throw new Error("contentContainer must be specified"); }());
|
||||||
|
|
||||||
|
Test(function (t) {
|
||||||
|
console.log("Here is the test");
|
||||||
|
evOnReady.reg(function () {
|
||||||
|
cpNfInner.chainpad.onSettle(function () {
|
||||||
|
console.log("The test has passed")
|
||||||
|
t.pass();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var titleRecommender = function () { return false; };
|
var titleRecommender = function () { return false; };
|
||||||
var contentGetter = function () { return UNINITIALIZED; };
|
var contentGetter = function () { return UNINITIALIZED; };
|
||||||
@@ -294,12 +303,6 @@ define([
|
|||||||
if (newPad && !AppConfig.displayCreationScreen) {
|
if (newPad && !AppConfig.displayCreationScreen) {
|
||||||
common.openTemplatePicker();
|
common.openTemplatePicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(function () {
|
|
||||||
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);
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// This is stage 1, it can be changed but you must bump the version of the project.
|
// This is stage 1, it can be changed but you must bump the version of the project.
|
||||||
// Note: This must only be loaded from inside of a sandbox-iframe.
|
// Note: This must only be loaded from inside of a sandbox-iframe.
|
||||||
define(['/common/requireconfig.js'], function (RequireConfig) {
|
define([
|
||||||
|
'/common/requireconfig.js',
|
||||||
|
'/common/test.js'
|
||||||
|
], function (RequireConfig, Test) {
|
||||||
require.config(RequireConfig());
|
require.config(RequireConfig());
|
||||||
|
|
||||||
// most of CryptPad breaks if you don't support isArray
|
// most of CryptPad breaks if you don't support isArray
|
||||||
@@ -23,5 +26,10 @@ define(['/common/requireconfig.js'], function (RequireConfig) {
|
|||||||
|
|
||||||
window.CRYPTPAD_INSIDE = true;
|
window.CRYPTPAD_INSIDE = true;
|
||||||
|
|
||||||
|
// This test is for keeping the testing infrastructure operating
|
||||||
|
// until all tests have been registered.
|
||||||
|
// This test is completed in common-interface.js
|
||||||
|
Test(function (t) { Test.__ASYNC_BLOCKER__ = t; });
|
||||||
|
|
||||||
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
|
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
|
||||||
});
|
});
|
||||||
|
|||||||
+33
-1
@@ -1,6 +1,38 @@
|
|||||||
define([], function () {
|
define([], function () {
|
||||||
if (window.__CRYPTPAD_TEST_OBJ_) { return window.__CRYPTPAD_TEST_OBJ_; }
|
if (window.__CRYPTPAD_TEST_OBJ_) { return window.__CRYPTPAD_TEST_OBJ_; }
|
||||||
var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) { if (out.testing) { f(); } };
|
|
||||||
|
var locks = [];
|
||||||
|
var tests = [];
|
||||||
|
var failed = false;
|
||||||
|
var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) {
|
||||||
|
if (!out.testing) { return; }
|
||||||
|
tests.push(f);
|
||||||
|
var runLock = function (lock) {
|
||||||
|
lock(function () { setTimeout(function () { runLock(locks.shift()); }); });
|
||||||
|
};
|
||||||
|
f({
|
||||||
|
pass: function () {
|
||||||
|
if (failed) { return; }
|
||||||
|
var i = tests.indexOf(f);
|
||||||
|
if (i === -1) {
|
||||||
|
throw new Error("Pass called on an unknown test (called multiple times?)");
|
||||||
|
}
|
||||||
|
tests.splice(i, 1);
|
||||||
|
if (!tests.length) { out.passed(); }
|
||||||
|
},
|
||||||
|
fail: function (reason) {
|
||||||
|
failed = true;
|
||||||
|
out.failed(reason);
|
||||||
|
},
|
||||||
|
lock: function (f) {
|
||||||
|
locks.push(f);
|
||||||
|
if (locks.length === 1) {
|
||||||
|
runLock(locks.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
out.passed = out.failed = out;
|
out.passed = out.failed = out;
|
||||||
var enableAuto = function () {
|
var enableAuto = function () {
|
||||||
console.log("Enable auto testing 1 " + window.origin);
|
console.log("Enable auto testing 1 " + window.origin);
|
||||||
|
|||||||
Reference in New Issue
Block a user