Fix tests for liveliness checks

This commit is contained in:
Travis Ralston 2019-06-05 09:53:22 -06:00
parent 42be1d633c
commit c68a621a71

View file

@ -240,6 +240,10 @@ describe('loading:', function() {
uriFragment: "#/room/!room:id", uriFragment: "#/room/!room:id",
}); });
// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
httpBackend.when("GET", "/api/v1").respond(200, {});
Promise.delay(1).then(() => { Promise.delay(1).then(() => {
// at this point, we're trying to do a guest registration; // at this point, we're trying to do a guest registration;
// we expect a spinner // we expect a spinner
@ -277,6 +281,10 @@ describe('loading:', function() {
uriFragment: "#/login", uriFragment: "#/login",
}); });
// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
httpBackend.when("GET", "/api/v1").respond(200, {});
return awaitLoginComponent(matrixChat).then(() => { return awaitLoginComponent(matrixChat).then(() => {
// we expect a single <Login> component // we expect a single <Login> component
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
@ -285,8 +293,13 @@ describe('loading:', function() {
// the only outstanding request should be a GET /login // the only outstanding request should be a GET /login
// (in particular there should be no /register request for // (in particular there should be no /register request for
// guest registration). // guest registration).
const allowedRequests = [
"/_matrix/client/r0/login",
"/versions",
"/api/v1",
];
for (const req of httpBackend.requests) { for (const req of httpBackend.requests) {
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) { if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
continue; continue;
} }
@ -387,6 +400,10 @@ describe('loading:', function() {
}); });
it('shows a login view', function() { it('shows a login view', function() {
// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
httpBackend.when("GET", "/api/v1").respond(200, {});
// we expect a single <Login> component // we expect a single <Login> component
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.auth.Login'), matrixChat, sdk.getComponent('structures.auth.Login'),
@ -395,8 +412,13 @@ describe('loading:', function() {
// the only outstanding request should be a GET /login // the only outstanding request should be a GET /login
// (in particular there should be no /register request for // (in particular there should be no /register request for
// guest registration, nor /sync, etc). // guest registration, nor /sync, etc).
const allowedRequests = [
"/_matrix/client/r0/login",
"/versions",
"/api/v1",
];
for (const req of httpBackend.requests) { for (const req of httpBackend.requests) {
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) { if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
continue; continue;
} }
@ -405,6 +427,10 @@ describe('loading:', function() {
}); });
it('shows the homepage after login', function() { it('shows the homepage after login', function() {
// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
httpBackend.when("GET", "/api/v1").respond(200, {});
return completeLogin(matrixChat).then(() => { return completeLogin(matrixChat).then(() => {
// we should see a home page, even though we previously had // we should see a home page, even though we previously had
// a stored mx_last_room_id // a stored mx_last_room_id