From ffa9e989b07bf8e4ed0c2da9f6f771ef5104e33b Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 14 Dec 2022 17:37:28 +1300 Subject: [PATCH 1/5] switching dm rooms without loader regression test --- cypress/e2e/room/room.spec.ts | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 cypress/e2e/room/room.spec.ts diff --git a/cypress/e2e/room/room.spec.ts b/cypress/e2e/room/room.spec.ts new file mode 100644 index 00000000000..15931e1013d --- /dev/null +++ b/cypress/e2e/room/room.spec.ts @@ -0,0 +1,82 @@ +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/// + +import { SynapseInstance } from "../../plugins/synapsedocker"; +import { MatrixClient } from "../../global"; +import { EventType } from "matrix-js-sdk/src/matrix"; + +describe("Room Directory", () => { + let synapse: SynapseInstance; + + beforeEach(() => { + cy.startSynapse("default").then((data) => { + synapse = data; + + cy.initTestUser(synapse, "Alice"); + }); + }); + + afterEach(() => { + cy.stopSynapse(synapse); + }); + + it("should switch between existing dm rooms without a loader", () => { + let clientUserId; + cy.getClient().then((cli) => { + clientUserId = cli.getUserId(); + }); + let bobClient: MatrixClient; + let charlieClient: MatrixClient; + cy.getBot(synapse, { + displayName: "Bob", + }).then((bob) => { + bobClient = bob; + }); + + cy.getBot(synapse, { + displayName: "Charlie", + }).then((charlie) => { + charlieClient = charlie; + }); + + // create dms with bob and charlie + cy.getClient().then(async (cli) => { + const bobRoom = await cli.createRoom({ is_direct: true }); + const charlieRoom = await cli.createRoom({ is_direct: true }); + await cli.invite(bobRoom.room_id, bobClient.getUserId()); + await cli.invite(charlieRoom.room_id, charlieClient.getUserId()); + await cli.setAccountData(EventType.Direct, { + [bobClient.getUserId()]: [bobRoom.room_id], + [charlieClient.getUserId()]: [charlieRoom.room_id], + }); + }); + + cy.viewRoomByName("Bob"); + + // short timeout because loader is only visible for short period + // we want to make sure it is never displayed when switching these rooms + cy.get(".mx_RoomPreviewBar_spinnerTitle", { timeout: 1 }).should("not.exist"); + // confirm the room was loaded + cy.contains("Bob joined the room").should("exist"); + + cy.viewRoomByName("Charlie"); + cy.get(".mx_RoomPreviewBar_spinnerTitle", { timeout: 1 }).should("not.exist"); + // confirm the room was loaded + cy.contains("Charlie joined the room").should("exist"); + }); +}); From 4859233c2cc0f0eff397a1d5fb025cb2fec98560 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 14 Dec 2022 17:47:02 +1300 Subject: [PATCH 2/5] lint --- cypress/e2e/room/room.spec.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/room/room.spec.ts b/cypress/e2e/room/room.spec.ts index 15931e1013d..c76005d0522 100644 --- a/cypress/e2e/room/room.spec.ts +++ b/cypress/e2e/room/room.spec.ts @@ -16,9 +16,10 @@ limitations under the License. /// +import { EventType } from "matrix-js-sdk/src/matrix"; + import { SynapseInstance } from "../../plugins/synapsedocker"; import { MatrixClient } from "../../global"; -import { EventType } from "matrix-js-sdk/src/matrix"; describe("Room Directory", () => { let synapse: SynapseInstance; @@ -36,10 +37,6 @@ describe("Room Directory", () => { }); it("should switch between existing dm rooms without a loader", () => { - let clientUserId; - cy.getClient().then((cli) => { - clientUserId = cli.getUserId(); - }); let bobClient: MatrixClient; let charlieClient: MatrixClient; cy.getBot(synapse, { From 9ccdc21f775b3bcde29eaddda0cb61df05f800e3 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 14 Dec 2022 18:58:35 +1300 Subject: [PATCH 3/5] more specific js-sdk import --- cypress/e2e/room/room.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/room/room.spec.ts b/cypress/e2e/room/room.spec.ts index c76005d0522..47074939501 100644 --- a/cypress/e2e/room/room.spec.ts +++ b/cypress/e2e/room/room.spec.ts @@ -16,7 +16,7 @@ limitations under the License. /// -import { EventType } from "matrix-js-sdk/src/matrix"; +import { EventType } from "matrix-js-sdk/src/@types/event"; import { SynapseInstance } from "../../plugins/synapsedocker"; import { MatrixClient } from "../../global"; From 816c13d9a7a96dc40dced92299b0961234bbeeba Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 14 Dec 2022 19:08:32 +1300 Subject: [PATCH 4/5] add wait for room list to settle before asserting --- cypress/e2e/room/room.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cypress/e2e/room/room.spec.ts b/cypress/e2e/room/room.spec.ts index 47074939501..6832ff063a8 100644 --- a/cypress/e2e/room/room.spec.ts +++ b/cypress/e2e/room/room.spec.ts @@ -63,6 +63,8 @@ describe("Room Directory", () => { }); }); + cy.wait(250); // let the room list settle + cy.viewRoomByName("Bob"); // short timeout because loader is only visible for short period From a46683fc831393e80a189dbd61380456db8b9b8f Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 14 Dec 2022 19:30:05 +1300 Subject: [PATCH 5/5] dont use js-sdk enum --- cypress/e2e/room/room.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/room/room.spec.ts b/cypress/e2e/room/room.spec.ts index 6832ff063a8..1d094751663 100644 --- a/cypress/e2e/room/room.spec.ts +++ b/cypress/e2e/room/room.spec.ts @@ -57,7 +57,7 @@ describe("Room Directory", () => { const charlieRoom = await cli.createRoom({ is_direct: true }); await cli.invite(bobRoom.room_id, bobClient.getUserId()); await cli.invite(charlieRoom.room_id, charlieClient.getUserId()); - await cli.setAccountData(EventType.Direct, { + await cli.setAccountData("m.direct" as EventType, { [bobClient.getUserId()]: [bobRoom.room_id], [charlieClient.getUserId()]: [charlieRoom.room_id], });