From 1fcd462660a7d82bf4b610ba14f2bac3f73b5205 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 13 Jun 2017 14:45:05 +0100 Subject: [PATCH 1/2] Tweak tests to match updates to matrixchat Mostly this is just making it look at the `view` state rather than the individual boolean flags. One other tweak merits explanation: we now implement the initial couldn't-register-as-guest login with an explicit switch to the LOGIN view, which means that the URL gets updated to #/login. --- test/app-tests/loading.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index a323a262..ed1875e0 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -29,6 +29,7 @@ import jssdk from 'matrix-js-sdk'; import sdk from 'matrix-react-sdk'; import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; import * as languageHandler from 'matrix-react-sdk/lib/languageHandler'; +import {VIEWS} from 'matrix-react-sdk/lib/components/structures/MatrixChat'; import * as test_utils from '../test-utils'; import MockHttpBackend from '../mock-request'; @@ -153,8 +154,8 @@ describe('loading:', function () { .check((r) => {syncRequest = r;}) .respond(200, response); - console.log("waiting for /sync"); for (let attempts = 10; attempts > 0; attempts--) { + console.log(Date.now() + " waiting for /sync"); if (syncRequest) { return syncRequest; } @@ -184,7 +185,7 @@ describe('loading:', function () { // we expect a single component following session load ReactTestUtils.findRenderedComponentWithType( matrixChat, sdk.getComponent('structures.login.Login')); - expect(windowLocation.hash).toEqual(""); + expect(windowLocation.hash).toEqual("#/login"); }).done(done, done); }); @@ -360,6 +361,9 @@ describe('loading:', function () { loadApp({ uriFragment: "#/login", }); + + // give the UI a chance to display + return q.delay(50); }); it('shows a login view', function() { @@ -589,7 +593,8 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) { retryCount = 0; } - if (matrixChat.state.loading || matrixChat.state.loggingIn) { + if (matrixChat.state.view === VIEWS.LOADING || + matrixChat.state.view === VIEWS.LOGGING_IN) { console.log(Date.now() + " Awaiting sync spinner: still loading."); if (retryCount >= retryLimit) { throw new Error("MatrixChat still not loaded after " + @@ -628,8 +633,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) { retryCount = 0; } - if (matrixChat.state.loading || - !(matrixChat.state.loggedIn && matrixChat.state.ready)) { + if (matrixChat.state.view !== VIEWS.LOGGED_IN || !matrixChat.state.ready) { console.log(Date.now() + " Awaiting room view: not ready yet."); if (retryCount >= retryLimit) { throw new Error("MatrixChat still not ready after " + From f5b2a92e840ecf630818a59c502733de15de59af Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 15 Jun 2017 18:17:00 +0100 Subject: [PATCH 2/2] Give the login panel a bit longer to appear --- test/app-tests/loading.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index ed1875e0..e660c91e 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -180,7 +180,7 @@ describe('loading:', function () { return httpBackend.flush(); }).then(() => { // Wait for another trip around the event loop for the UI to update - return q.delay(1); + return q.delay(10); }).then(() => { // we expect a single component following session load ReactTestUtils.findRenderedComponentWithType( @@ -206,7 +206,7 @@ describe('loading:', function () { return httpBackend.flush(); }).then(() => { // Wait for another trip around the event loop for the UI to update - return q.delay(1); + return q.delay(10); }).then(() => { return completeLogin(matrixChat); }).then(() => {