Skip to content

Commit c68a621

Browse files
committed
Fix tests for liveliness checks
1 parent 42be1d6 commit c68a621

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

test/app-tests/loading.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ describe('loading:', function() {
240240
uriFragment: "#/room/!room:id",
241241
});
242242

243+
// Pass the liveliness checks
244+
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
245+
httpBackend.when("GET", "/api/v1").respond(200, {});
246+
243247
Promise.delay(1).then(() => {
244248
// at this point, we're trying to do a guest registration;
245249
// we expect a spinner
@@ -277,6 +281,10 @@ describe('loading:', function() {
277281
uriFragment: "#/login",
278282
});
279283

284+
// Pass the liveliness checks
285+
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
286+
httpBackend.when("GET", "/api/v1").respond(200, {});
287+
280288
return awaitLoginComponent(matrixChat).then(() => {
281289
// we expect a single <Login> component
282290
ReactTestUtils.findRenderedComponentWithType(
@@ -285,8 +293,13 @@ describe('loading:', function() {
285293
// the only outstanding request should be a GET /login
286294
// (in particular there should be no /register request for
287295
// guest registration).
296+
const allowedRequests = [
297+
"/_matrix/client/r0/login",
298+
"/versions",
299+
"/api/v1",
300+
];
288301
for (const req of httpBackend.requests) {
289-
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) {
302+
if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
290303
continue;
291304
}
292305

@@ -387,6 +400,10 @@ describe('loading:', function() {
387400
});
388401

389402
it('shows a login view', function() {
403+
// Pass the liveliness checks
404+
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
405+
httpBackend.when("GET", "/api/v1").respond(200, {});
406+
390407
// we expect a single <Login> component
391408
ReactTestUtils.findRenderedComponentWithType(
392409
matrixChat, sdk.getComponent('structures.auth.Login'),
@@ -395,8 +412,13 @@ describe('loading:', function() {
395412
// the only outstanding request should be a GET /login
396413
// (in particular there should be no /register request for
397414
// guest registration, nor /sync, etc).
415+
const allowedRequests = [
416+
"/_matrix/client/r0/login",
417+
"/versions",
418+
"/api/v1",
419+
];
398420
for (const req of httpBackend.requests) {
399-
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) {
421+
if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
400422
continue;
401423
}
402424

@@ -405,6 +427,10 @@ describe('loading:', function() {
405427
});
406428

407429
it('shows the homepage after login', function() {
430+
// Pass the liveliness checks
431+
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
432+
httpBackend.when("GET", "/api/v1").respond(200, {});
433+
408434
return completeLogin(matrixChat).then(() => {
409435
// we should see a home page, even though we previously had
410436
// a stored mx_last_room_id

0 commit comments

Comments
 (0)