From d65374f7f9feb599a478cc7a092ee73af63665aa Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 9 Dec 2016 10:31:26 +0000 Subject: [PATCH 1/2] Make the 'loading' tests work in isolation The 'loading' tests only worked when run with the other tests and failed if you just ran the file by itself, because the skin was loading in the 'joining' tests, but not here. --- test/app-tests/loading.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 892ba852..1c6211d4 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -16,6 +16,8 @@ limitations under the License. /* loading.js: test the myriad paths we have for loading the application */ +import 'skin-sdk'; + import React from 'react'; import ReactDOM from 'react-dom'; import ReactTestUtils from 'react-addons-test-utils'; From 67cf4230ac3bfbe4355539c34ad0f5aa9df8e2a9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 9 Dec 2016 14:27:41 +0000 Subject: [PATCH 2/2] Fix broken tests Promises are now not being resolved within the same tick, so give another tick for the UI to update after all the HTTP calls have flushed through. This is fairly terrible, but I can't immediately see a better way of doing this. --- test/app-tests/loading.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 1c6211d4..03a4d11e 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -154,6 +154,9 @@ describe('loading:', function () { }).respond(403, "Guest access is disabled"); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // we expect a single component ReactTestUtils.findRenderedComponentWithType( @@ -177,6 +180,9 @@ describe('loading:', function () { }).respond(403, "Guest access is disabled"); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // we expect a single component let login = ReactTestUtils.findRenderedComponentWithType( @@ -191,6 +197,9 @@ describe('loading:', function () { }); login.onPasswordLogin("user", "pass") return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // we expect a spinner ReactTestUtils.findRenderedComponentWithType( @@ -200,6 +209,9 @@ describe('loading:', function () { httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' }); httpBackend.when('GET', '/sync').respond(200, {}); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // once the sync completes, we should have a room view httpBackend.verifyNoOutstandingExpectation(); @@ -287,6 +299,9 @@ describe('loading:', function () { }); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // now we should have a spinner with a logout link assertAtSyncingSpinner(matrixChat); @@ -322,6 +337,9 @@ describe('loading:', function () { }); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // now we should have a spinner with a logout link assertAtSyncingSpinner(matrixChat); @@ -358,12 +376,18 @@ describe('loading:', function () { }); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // now we should have a spinner with a logout link assertAtSyncingSpinner(matrixChat); httpBackend.when('GET', '/sync').respond(200, {}); return httpBackend.flush(); + }).then(() => { + // Wait for another trip around the event loop for the UI to update + return q.delay(1); }).then(() => { // once the sync completes, we should have a room view httpBackend.verifyNoOutstandingExpectation();