diff --git a/src/components/structures/HomePage.js b/src/components/structures/HomePage.js index 615877fd..8c62a2bc 100644 --- a/src/components/structures/HomePage.js +++ b/src/components/structures/HomePage.js @@ -62,7 +62,7 @@ module.exports = React.createClass({ { method: "GET", url: src }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { - console.log(error); + console.log(err); this.setState({ page: "Couldn't load home page" }); } diff --git a/test/app-tests/joining.js b/test/app-tests/joining.js index 7aaaaec8..ce7ef541 100644 --- a/test/app-tests/joining.js +++ b/test/app-tests/joining.js @@ -88,13 +88,13 @@ describe('joining a room', function () { var mc = ( {throw new Error("unimplemented");}} + initialScreenAfterLogin={{ + screen: 'directory', + }} /> ); matrixChat = ReactDOM.render(mc, parentDiv); - // switch to the Directory - matrixChat._setPage(PageTypes.RoomDirectory); - var roomView; // wait for /sync to happen. This may take some time, as the client @@ -138,7 +138,11 @@ describe('joining a room', function () { httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID }); httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync") .respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'}); - return httpBackend.flush(); + + return q.all([ + httpBackend.flush('/directory/room/'+encodeURIComponent(ROOM_ALIAS)), + httpBackend.flush('/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync"), + ]); }).then(() => { httpBackend.verifyNoOutstandingExpectation(); @@ -146,30 +150,20 @@ describe('joining a room', function () { roomView = ReactTestUtils.findRenderedComponentWithType( matrixChat, RoomView); - var previewBar = ReactTestUtils.findRenderedComponentWithType( + const previewBar = ReactTestUtils.findRenderedComponentWithType( roomView, RoomPreviewBar); - var joinLink = ReactTestUtils.findRenderedDOMComponentWithTag( + const joinLink = ReactTestUtils.findRenderedDOMComponentWithTag( previewBar, 'a'); ReactTestUtils.Simulate.click(joinLink); - // that will fire off a request to check our displayname, followed by a - // join request - httpBackend.when('GET', '/profile/'+encodeURIComponent(USER_ID)) - .respond(200, {displayname: 'boris'}); - httpBackend.when('POST', '/join/'+encodeURIComponent(ROOM_ALIAS)) + httpBackend.when('POST', '/join/'+encodeURIComponent(ROOM_ID)) .respond(200, {room_id: ROOM_ID}); - return httpBackend.flush(); }).then(() => { // wait for the join request to be made return q.delay(1); }).then(() => { - // flush it through - return httpBackend.flush(); - }).then(() => { - httpBackend.verifyNoOutstandingExpectation(); - // the roomview should now be loading expect(roomView.state.room).toBe(null); expect(roomView.state.joining).toBe(true); @@ -178,6 +172,14 @@ describe('joining a room', function () { ReactTestUtils.findRenderedDOMComponentWithClass( roomView, "mx_Spinner"); + // flush it through + return httpBackend.flush('/join/'+encodeURIComponent(ROOM_ID)); + }).then(() => { + httpBackend.verifyNoOutstandingExpectation(); + + // We've joined, expect this to false + expect(roomView.state.joining).toBe(false); + // now send the room down the /sync pipe httpBackend.when('GET', '/sync'). respond(200, { @@ -197,7 +199,6 @@ describe('joining a room', function () { }).then(() => { // now the room should have loaded expect(roomView.state.room).toExist(); - expect(roomView.state.joining).toBe(false); }).done(done, done); }); }); diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 484b1dc2..281e1bb7 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -122,7 +122,7 @@ describe('loading:', function () { function routeUrl(location, matrixChat) { console.log(Date.now() + ` routing URL '${location}'`); const s = getScreenFromLocation(location); - console.log("Showing screen "+ s); + console.log("Showing screen ", s); matrixChat.showScreen(s.screen, s.params); } @@ -193,14 +193,12 @@ 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(() => { - // we expect a single component + // 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) {