More test resilience
Give the tests more than one chance for the roomview to load.
This commit is contained in:
parent
597705716b
commit
fe64b04339
|
@ -209,14 +209,11 @@ describe('loading:', function () {
|
||||||
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, {});
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
|
||||||
// Wait for another trip around the event loop for the UI to update
|
|
||||||
return q.delay(1);
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// once the sync completes, we should have a room view
|
// once the sync completes, we should have a room view
|
||||||
|
return awaitRoomView(matrixChat);
|
||||||
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
|
||||||
matrixChat, sdk.getComponent('structures.RoomView'));
|
|
||||||
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
||||||
|
|
||||||
// and the localstorage should have been updated
|
// and the localstorage should have been updated
|
||||||
|
@ -269,9 +266,9 @@ describe('loading:', function () {
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// once the sync completes, we should have a room view
|
// once the sync completes, we should have a room view
|
||||||
|
return awaitRoomView(matrixChat);
|
||||||
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
|
||||||
matrixChat, sdk.getComponent('structures.RoomView'));
|
|
||||||
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
||||||
}).done(done, done);
|
}).done(done, done);
|
||||||
|
|
||||||
|
@ -370,14 +367,11 @@ describe('loading:', function () {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.when('GET', '/sync').respond(200, {});
|
httpBackend.when('GET', '/sync').respond(200, {});
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
|
||||||
// Wait for another trip around the event loop for the UI to update
|
|
||||||
return q.delay(1);
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// once the sync completes, we should have a room view
|
// once the sync completes, we should have a room view
|
||||||
|
return awaitRoomView(matrixChat);
|
||||||
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
|
||||||
matrixChat, sdk.getComponent('structures.RoomView'));
|
|
||||||
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
||||||
}).done(done, done);
|
}).done(done, done);
|
||||||
});
|
});
|
||||||
|
@ -469,3 +463,30 @@ function assertAtSyncingSpinner(matrixChat) {
|
||||||
matrixChat, 'a');
|
matrixChat, 'a');
|
||||||
expect(logoutLink.text).toEqual("Logout");
|
expect(logoutLink.text).toEqual("Logout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
||||||
|
if (retryLimit === undefined) {
|
||||||
|
retryLimit = 5;
|
||||||
|
}
|
||||||
|
if (retryCount === undefined) {
|
||||||
|
retryCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matrixChat.state.ready) {
|
||||||
|
console.log(Date.now() + " Awaiting room view: not ready yet.");
|
||||||
|
if (retryCount >= retryLimit) {
|
||||||
|
throw new Error("MatrixChat still not ready after " +
|
||||||
|
retryCount + " tries");
|
||||||
|
}
|
||||||
|
return q.delay(0).then(() => {
|
||||||
|
return awaitRoomView(matrixChat, retryLimit, retryCount + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(Date.now() + " Awaiting room view: now ready.");
|
||||||
|
|
||||||
|
// state looks good, check the rendered output
|
||||||
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
matrixChat, sdk.getComponent('structures.RoomView'));
|
||||||
|
return q();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue