From ed06219dcd6c1552dc25ed40234f1b70332ad033 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Mon, 15 May 2023 11:37:24 +0100 Subject: [PATCH] Fix cypress test in spotlight tests (#10884) Sometimes, when I ran these tests locally, they would fail. The problem appears to be that the join takes some time and can end up racing against the body of the test. The solution is to wait for the join to complete before proceeding. --- cypress/e2e/spotlight/spotlight.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/spotlight/spotlight.spec.ts b/cypress/e2e/spotlight/spotlight.spec.ts index 0d4c33926b..2aa98460b9 100644 --- a/cypress/e2e/spotlight/spotlight.spec.ts +++ b/cypress/e2e/spotlight/spotlight.spec.ts @@ -170,10 +170,9 @@ describe("Spotlight", () => { ) .then(() => cy.window({ log: false }).then(({ matrixcs: { Visibility } }) => { - cy.createRoom({ name: room1Name, visibility: Visibility.Public }).then((_room1Id) => { + cy.createRoom({ name: room1Name, visibility: Visibility.Public }).then(async (_room1Id) => { room1Id = _room1Id; - bot1.joinRoom(room1Id); - cy.visit("/#/room/" + room1Id); + await bot1.joinRoom(room1Id); }); bot2.createRoom({ name: room2Name, visibility: Visibility.Public }).then( ({ room_id: _room2Id }) => { @@ -199,7 +198,10 @@ describe("Spotlight", () => { }); }), ) - .then(() => cy.get(".mx_RoomSublist_skeletonUI").should("not.exist")); + .then(() => { + cy.visit("/#/room/" + room1Id); + cy.get(".mx_RoomSublist_skeletonUI").should("not.exist"); + }); }); });