diff --git a/test/app-tests/joining.js b/test/app-tests/joining.js index 30ef70db..c5646732 100644 --- a/test/app-tests/joining.js +++ b/test/app-tests/joining.js @@ -23,6 +23,7 @@ var jssdk = require('matrix-js-sdk'); var sdk = require('matrix-react-sdk'); var peg = require('matrix-react-sdk/lib/MatrixClientPeg'); var dis = require('matrix-react-sdk/lib/dispatcher'); +var PageTypes = require('matrix-react-sdk/lib/PageTypes'); var MatrixChat = sdk.getComponent('structures.MatrixChat'); var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar'); @@ -90,9 +91,7 @@ describe('joining a room', function () { matrixChat = ReactDOM.render(mc, parentDiv); // switch to the Directory - dis.dispatch({ - action: 'view_room_directory', - }); + matrixChat._setPage(PageTypes.RoomDirectory); var roomView; // wait for /sync to happen diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index ef555830..22daa395 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -104,6 +104,23 @@ describe('loading:', function () { } } + // Parse the given window.location and return parameters that can be used when calling + // MatrixChat.showScreen(screen, params) + function getScreenFromLocation(location) { + const fragparts = parseQsFromFragment(location); + return { + screen: fragparts.location.substring(1), + params: fragparts.params, + } + } + + function routeUrl(location, matrixChat) { + console.log(Date.now() + "Routing URL " + location); + const s = getScreenFromLocation(location); + console.log("Showing screen", s); + matrixChat.showScreen(s.screen, s.params); + } + const MatrixChat = sdk.getComponent('structures.MatrixChat'); const fragParts = parseQsFromFragment(windowLocation); var params = parseQs(windowLocation); @@ -118,16 +135,10 @@ describe('loading:', function () { startingFragmentQueryParams={fragParts.params} enableGuest={true} onLoadCompleted={loadCompleteDefer.resolve} + initialScreenAfterLogin={getScreenFromLocation(windowLocation)} />, parentDiv ); - function routeUrl(location, matrixChat) { - console.log(Date.now() + " Routing URL "+location); - var fragparts = parseQsFromFragment(location); - matrixChat.showScreen(fragparts.location.substring(1), - fragparts.params); - } - // pause for a cycle, then simulate the window.onload handler window.setTimeout(() => { console.log(Date.now() + " simulating window.onload"); @@ -476,7 +487,8 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) { retryCount = 0; } - if (!matrixChat.state.ready) { + if (matrixChat.state.loading || + !(matrixChat.state.loggedIn && matrixChat.state.ready)) { console.log(Date.now() + " Awaiting room view: not ready yet."); if (retryCount >= retryLimit) { throw new Error("MatrixChat still not ready after " +