From 15d0bd9271d69b2d39349c3f524360cf62dbafbc Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Jun 2017 15:54:45 +0100 Subject: [PATCH 1/2] Partially revert https://github.com/vector-im/riot-web/pull/4201 The q.delay is needed to make sure (or at least reasonably sure...) that the login component has appeared by that point. The done handler needs to be the error callback too otherwise failures result in timeouts rather than the actual failure. --- test/app-tests/loading.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 281e1bb7..b6e4324f 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -192,13 +192,15 @@ 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 following session load ReactTestUtils.findRenderedComponentWithType( matrixChat, sdk.getComponent('structures.login.Login')); expect(windowLocation.hash).toEqual(""); - done(); - }); + }).done(done, done); }); it('should follow the original link after successful login', function(done) { From 8e288e14bf8914ff4a977b3eaca8c10e3880cd27 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Jun 2017 15:59:24 +0100 Subject: [PATCH 2/2] Add more hacky q.delays To work around the fact that we now do more trips around the event loop to update view state (because of going vis the store). Also add comment saying how horrible this is. --- test/app-tests/joining.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/app-tests/joining.js b/test/app-tests/joining.js index ce7ef541..24a4ceed 100644 --- a/test/app-tests/joining.js +++ b/test/app-tests/joining.js @@ -163,6 +163,13 @@ describe('joining a room', function () { }).then(() => { // wait for the join request to be made return q.delay(1); + }).then(() => { + // and again, because the state update has to go to the store and + // then one dispatch within the store, then to the view + // XXX: This is *super flaky*: a better way would be to declare + // that we expect a certain state transition to happen, then wait + // for that transition to occur. + return q.delay(1); }).then(() => { // the roomview should now be loading expect(roomView.state.room).toBe(null); @@ -177,6 +184,8 @@ describe('joining a room', function () { }).then(() => { httpBackend.verifyNoOutstandingExpectation(); + return q.delay(1); + }).then(() => { // We've joined, expect this to false expect(roomView.state.joining).toBe(false);