Fix a flaky test
Depending on timing, the first `httpBackend.flush()` could end up just flushing a '/presence' call rather than the initial sync. The fix to that is simply to not set the expectation on /presence. While we're there, split out the flushes of /publicRooms and /thirdparty/protocols, so that we can be sure that they happen. There is probably still a bunch of flakiness there, but this should fix one particular instance.
This commit is contained in:
parent
15accf33f5
commit
593e101521
1 changed files with 14 additions and 5 deletions
|
@ -72,14 +72,13 @@ describe('joining a room', function () {
|
||||||
var ROOM_ALIAS = '#alias:localhost';
|
var ROOM_ALIAS = '#alias:localhost';
|
||||||
var ROOM_ID = '!id:localhost';
|
var ROOM_ID = '!id:localhost';
|
||||||
|
|
||||||
httpBackend.when('PUT', '/presence/'+encodeURIComponent(USER_ID)+'/status')
|
|
||||||
.respond(200, {});
|
|
||||||
httpBackend.when('GET', '/pushrules').respond(200, {});
|
httpBackend.when('GET', '/pushrules').respond(200, {});
|
||||||
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
||||||
httpBackend.when('GET', '/sync').respond(200, {});
|
httpBackend.when('GET', '/sync').respond(200, {});
|
||||||
httpBackend.when('POST', '/publicRooms').respond(200, {chunk: []});
|
|
||||||
httpBackend.when('GET', '/thirdparty/protocols').respond(200, {});
|
// note that we deliberately do *not* set an expectation for a
|
||||||
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
|
// presence update - setting one makes the first httpBackend.flush
|
||||||
|
// return before the first /sync arrives.
|
||||||
|
|
||||||
// start with a logged-in client
|
// start with a logged-in client
|
||||||
localStorage.setItem("mx_hs_url", HS_URL );
|
localStorage.setItem("mx_hs_url", HS_URL );
|
||||||
|
@ -94,9 +93,18 @@ describe('joining a room', function () {
|
||||||
matrixChat._setPage(PageTypes.RoomDirectory);
|
matrixChat._setPage(PageTypes.RoomDirectory);
|
||||||
|
|
||||||
var roomView;
|
var roomView;
|
||||||
|
|
||||||
// wait for /sync to happen
|
// wait for /sync to happen
|
||||||
return q.delay(1).then(() => {
|
return q.delay(1).then(() => {
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
|
}).then(() => {
|
||||||
|
// wait for the directory requests
|
||||||
|
httpBackend.when('POST', '/publicRooms').respond(200, {chunk: []});
|
||||||
|
httpBackend.when('GET', '/thirdparty/protocols').respond(200, {});
|
||||||
|
return q.all([
|
||||||
|
httpBackend.flush('/publicRooms'),
|
||||||
|
httpBackend.flush('/thirdparty/protocols'),
|
||||||
|
]);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
var roomDir = ReactTestUtils.findRenderedComponentWithType(
|
var roomDir = ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, RoomDirectory);
|
matrixChat, RoomDirectory);
|
||||||
|
@ -110,6 +118,7 @@ describe('joining a room', function () {
|
||||||
|
|
||||||
// that should create a roomview which will start a peek; wait
|
// that should create a roomview which will start a peek; wait
|
||||||
// for the peek.
|
// for the peek.
|
||||||
|
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
|
||||||
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
||||||
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
|
|
Loading…
Reference in a new issue