Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use flushAllExpected in joining test #4570

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 10 additions & 24 deletions test/app-tests/joining.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,17 @@ describe('joining a room', function () {
// wait for /sync to happen. This may take some time, as the client
// has to initialise indexeddb.
console.log("waiting for /sync");
let syncDone = false;
httpBackend.when('GET', '/sync')
.check((r) => {syncDone = true;})
.respond(200, {});
function awaitSync(attempts) {
if (syncDone) {
return Promise.resolve();
}
if (!attempts) {
throw new Error("Gave up waiting for /sync")
}
return httpBackend.flush().then(() => awaitSync(attempts-1));
}

return awaitSync(10).then(() => {
return httpBackend.flushAllExpected().then(() => {
// wait for the directory requests
httpBackend.when('POST', '/publicRooms').respond(200, {chunk: []});
httpBackend.when('GET', '/thirdparty/protocols').respond(200, {});
return Promise.all([
httpBackend.flush('/thirdparty/protocols'),
httpBackend.flush('/publicRooms'),
]);
return httpBackend.flushAllExpected();
}).then(() => {
console.log(`${Date.now()} App made requests for directory view; switching to a room.`);

var roomDir = ReactTestUtils.findRenderedComponentWithType(
matrixChat, RoomDirectory);

Expand All @@ -139,19 +127,17 @@ describe('joining a room', function () {
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});

return Promise.all([
httpBackend.flush('/directory/room/'+encodeURIComponent(ROOM_ALIAS), 1, 200),
httpBackend.flush('/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync", 1, 200),
]);
return httpBackend.flushAllExpected();
}).then(() => {
httpBackend.verifyNoOutstandingExpectation();
console.log(`${Date.now()} App made room preview request`);

return Promise.delay(1);
}).then(() => {
// we should now have a roomview, with a preview bar
// we should now have a roomview
roomView = ReactTestUtils.findRenderedComponentWithType(
matrixChat, RoomView);

// the preview bar may take a tick to be displayed
return Promise.delay(1);
}).then(() => {
const previewBar = ReactTestUtils.findRenderedComponentWithType(
roomView, RoomPreviewBar);

Expand Down