diff --git a/customize.dist/src/less2/pages/page-checkup.less b/customize.dist/src/less2/pages/page-checkup.less index 2839ec9ea..2a05600c7 100644 --- a/customize.dist/src/less2/pages/page-checkup.less +++ b/customize.dist/src/less2/pages/page-checkup.less @@ -20,6 +20,12 @@ html, body { padding-top: 15px; } + .pending { + border: 1px solid white; + .fa { + margin-right: 20px; + } + } .success { border: 1px solid green; } diff --git a/www/assert/assertions.js b/www/assert/assertions.js index 8ea0a2638..a1f6944fb 100644 --- a/www/assert/assertions.js +++ b/www/assert/assertions.js @@ -21,8 +21,10 @@ define([], function () { }); }; - assert.run = function (cb) { + assert.run = function (cb, progress) { + progress = progress || function () {}; var count = ASSERTS.length; + var total = ASSERTS.length; var done = function (err) { count--; if (err) { failMessages.push(err); } @@ -38,6 +40,7 @@ define([], function () { ASSERTS.forEach(function (f, index) { f(function (err) { //console.log("test " + index); + progress(index, total); done(err, index); }, index); }); diff --git a/www/checkup/index.html b/www/checkup/index.html index 164793466..04a9502d3 100644 --- a/www/checkup/index.html +++ b/www/checkup/index.html @@ -6,5 +6,6 @@ +
diff --git a/www/checkup/main.js b/www/checkup/main.js index 3caed1a84..5a6630c6f 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -11,12 +11,15 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/common/pinpad.js', - + '/common/outer/network-config.js', + '/bower_components/netflux-websocket/netflux-client.js', '/bower_components/tweetnacl/nacl-fast.min.js', + 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/customize/src/less2/pages/page-checkup.less', ], function ($, ApiConfig, Assertions, h, Messages, DomReady, - nThen, SFCommonO, Login, Hash, Util, Pinpad) { + nThen, SFCommonO, Login, Hash, Util, Pinpad, + NetConfig, Netflux) { var assert = Assertions(); var trimSlashes = function (s) { @@ -77,7 +80,28 @@ define([ }); }, _alert("Sandbox domain is not available")); - // Write/ready access to /block/ + // Test Websocket + var evWSError = Util.mkEvent(true); + assert(function (cb) { + var ws = new WebSocket(NetConfig.getWebsocketURL()); + var to = setTimeout(function () { + console.error('Websocket TIMEOUT'); + evWSError.fire(); + cb('TIMEOUT (5 seconds)'); + }, 5000); + ws.onopen = function () { + clearTimeout(to); + cb(true); + }; + ws.onerror = function (err) { + clearTimeout(to); + console.error('Websocket error', err); + evWSError.fire(); + cb('WebSocket error: check your console'); + }; + }, _alert("Websocket is not available")); + + // Test login block assert(function (cb) { var bytes = new Uint8Array(Login.requiredBytes); @@ -101,6 +125,11 @@ define([ exists = true; })); }).nThen(function (waitFor) { + // If WebSockets aren't working, don't wait forever here + evWSError.reg(function () { + waitFor.abort(); + cb("No WebSocket (test number 6)"); + }); // Create proxy Login.loadUserObject(opt, waitFor(function (err, rt) { if (err) { @@ -167,7 +196,7 @@ define([ cb(true); }); - }, _alert("Login Block is not working (write/read/remove)")); + }, _alert("Login block is not working (write/read/remove)")); var row = function (cells) { return h('tr', cells.map(function (cell) { @@ -185,6 +214,8 @@ define([ ]); }; + var completed = 0; + var $progress = $('#cp-progress'); assert.run(function (state) { var errors = state.errors; var failed = errors.length; @@ -206,6 +237,17 @@ define([ h('div.failures', errors.map(failureReport)), ]); + $progress.remove(); $('body').prepend(report); + }, function (i, total) { + console.log('test '+ i +' completed'); + completed++; + Messages.assert_numberOfTestsCompleted = "{0} / {1} tests completed."; + $progress.html('').append(h('div.report.pending.summary', [ + h('p', [ + h('i.fa.fa-spinner.fa-pulse'), + h('span', Messages._getKey('assert_numberOfTestsCompleted', [completed, total])) + ]) + ])); }); });