@@ -72,14 +72,13 @@ describe('joining a room', function () {
7272 var ROOM_ALIAS = '#alias:localhost' ;
7373 var ROOM_ID = '!id:localhost' ;
7474
75- httpBackend . when ( 'PUT' , '/presence/' + encodeURIComponent ( USER_ID ) + '/status' )
76- . respond ( 200 , { } ) ;
7775 httpBackend . when ( 'GET' , '/pushrules' ) . respond ( 200 , { } ) ;
7876 httpBackend . when ( 'POST' , '/filter' ) . respond ( 200 , { filter_id : 'fid' } ) ;
7977 httpBackend . when ( 'GET' , '/sync' ) . respond ( 200 , { } ) ;
80- httpBackend . when ( 'POST' , '/publicRooms' ) . respond ( 200 , { chunk : [ ] } ) ;
81- httpBackend . when ( 'GET' , '/thirdparty/protocols' ) . respond ( 200 , { } ) ;
82- httpBackend . when ( 'GET' , '/directory/room/' + encodeURIComponent ( ROOM_ALIAS ) ) . respond ( 200 , { room_id : ROOM_ID } ) ;
78+
79+ // note that we deliberately do *not* set an expectation for a
80+ // presence update - setting one makes the first httpBackend.flush
81+ // return before the first /sync arrives.
8382
8483 // start with a logged-in client
8584 localStorage . setItem ( "mx_hs_url" , HS_URL ) ;
@@ -94,9 +93,18 @@ describe('joining a room', function () {
9493 matrixChat . _setPage ( PageTypes . RoomDirectory ) ;
9594
9695 var roomView ;
96+
9797 // wait for /sync to happen
9898 return q . delay ( 1 ) . then ( ( ) => {
9999 return httpBackend . flush ( ) ;
100+ } ) . then ( ( ) => {
101+ // wait for the directory requests
102+ httpBackend . when ( 'POST' , '/publicRooms' ) . respond ( 200 , { chunk : [ ] } ) ;
103+ httpBackend . when ( 'GET' , '/thirdparty/protocols' ) . respond ( 200 , { } ) ;
104+ return q . all ( [
105+ httpBackend . flush ( '/publicRooms' ) ,
106+ httpBackend . flush ( '/thirdparty/protocols' ) ,
107+ ] ) ;
100108 } ) . then ( ( ) => {
101109 var roomDir = ReactTestUtils . findRenderedComponentWithType (
102110 matrixChat , RoomDirectory ) ;
@@ -110,6 +118,7 @@ describe('joining a room', function () {
110118
111119 // that should create a roomview which will start a peek; wait
112120 // for the peek.
121+ httpBackend . when ( 'GET' , '/directory/room/' + encodeURIComponent ( ROOM_ALIAS ) ) . respond ( 200 , { room_id : ROOM_ID } ) ;
113122 httpBackend . when ( 'GET' , '/rooms/' + encodeURIComponent ( ROOM_ID ) + "/initialSync" )
114123 . respond ( 401 , { errcode : 'M_GUEST_ACCESS_FORBIDDEN' } ) ;
115124 return httpBackend . flush ( ) ;
0 commit comments