From 05583e1747b86faf3a17f4b47666ea7354ebddd8 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 10 Mar 2022 15:49:55 +0000 Subject: [PATCH 1/2] Add mock to /versions API endpoint --- test/app-tests/joining-test.tsx | 1 - test/app-tests/loading-test.tsx | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/app-tests/joining-test.tsx b/test/app-tests/joining-test.tsx index 23f956f2d46..1ea411fec1e 100644 --- a/test/app-tests/joining-test.tsx +++ b/test/app-tests/joining-test.tsx @@ -77,7 +77,6 @@ describe('joining a room', function() { const ROOM_ALIAS = '#alias:localhost'; const ROOM_ID = '!id:localhost'; - httpBackend.when('GET', '/capabilities').respond(200, { capabilities : {} }); httpBackend.when('GET', '/pushrules').respond(200, {}); httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' }); diff --git a/test/app-tests/loading-test.tsx b/test/app-tests/loading-test.tsx index e86c83759f1..71a7ab2d4fa 100644 --- a/test/app-tests/loading-test.tsx +++ b/test/app-tests/loading-test.tsx @@ -313,7 +313,7 @@ describe('loading:', function() { }); it('shows the last known room by default', function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities: {} }); + httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp(); @@ -333,7 +333,7 @@ describe('loading:', function() { it('shows a home page by default if we have no joined rooms', function() { localStorage.removeItem("mx_last_room_id"); - httpBackend.when('GET', '/capabilities').respond(200, { capabilities : {} }); + httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp(); @@ -351,7 +351,7 @@ describe('loading:', function() { }); it('shows a room view if we followed a room link', function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities : {} }); + httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp({ @@ -425,7 +425,6 @@ describe('loading:', function() { describe('Guest auto-registration:', function() { it('shows a welcome page by default', function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities: {} }); loadApp(); @@ -457,7 +456,6 @@ describe('loading:', function() { }); it('uses the default homeserver to register with', function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities: {} }); loadApp(); @@ -493,7 +491,6 @@ describe('loading:', function() { }); it('shows a room view if we followed a room link', function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities: {} }); loadApp({ uriFragment: "#/room/!room:id", @@ -526,7 +523,6 @@ describe('loading:', function() { describe('Login as user', function() { beforeEach(function() { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities: {} }); // first we have to load the homepage loadApp(); @@ -674,7 +670,7 @@ describe('loading:', function() { // Wait for another trip around the event loop for the UI to update return sleep(1); }).then(() => { - httpBackend.when('GET', '/capabilities').respond(200, { capabilities : {} }); + httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); return expectAndAwaitSync().catch((e) => { throw new Error("Never got /sync after login: did the client start?"); From ac3b0e5e9b7024b98ba336dd1fc11d33aecae911 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Fri, 11 Mar 2022 08:44:33 +0000 Subject: [PATCH 2/2] make versions call expected for guests --- test/app-tests/loading-test.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/test/app-tests/loading-test.tsx b/test/app-tests/loading-test.tsx index 71a7ab2d4fa..068164dcee3 100644 --- a/test/app-tests/loading-test.tsx +++ b/test/app-tests/loading-test.tsx @@ -168,15 +168,15 @@ describe('loading:', function() { // returns a promise resolving to the received request async function expectAndAwaitSync(opts?) { let syncRequest = null; + httpBackend.when('GET', '/_matrix/client/versions') + .respond(200, { + "versions": ["r0.3.0"], + "unstable_features": { + "m.lazy_load_members": true + } + }); const isGuest = opts && opts.isGuest; if (!isGuest) { - httpBackend.when('GET', '/_matrix/client/versions') - .respond(200, { - "versions": ["r0.3.0"], - "unstable_features": { - "m.lazy_load_members": true - } - }); // the call to create the LL filter httpBackend.when('POST', '/filter').respond(200, { filter_id: 'llfid' }); } @@ -313,7 +313,6 @@ describe('loading:', function() { }); it('shows the last known room by default', function() { - httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp(); @@ -333,7 +332,6 @@ describe('loading:', function() { it('shows a home page by default if we have no joined rooms', function() { localStorage.removeItem("mx_last_room_id"); - httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp(); @@ -351,7 +349,6 @@ describe('loading:', function() { }); it('shows a room view if we followed a room link', function() { - httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); loadApp({ @@ -670,7 +667,6 @@ describe('loading:', function() { // Wait for another trip around the event loop for the UI to update return sleep(1); }).then(() => { - httpBackend.when('GET', '/versions').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {}); return expectAndAwaitSync().catch((e) => { throw new Error("Never got /sync after login: did the client start?");