From 966d8bd6956e2c12dfef25606cbd4198dc2d0a4b Mon Sep 17 00:00:00 2001
From: Andy Balaam <andy.balaam@matrix.org>
Date: Mon, 2 Oct 2023 13:51:56 +0100
Subject: [PATCH] Ensure the bot has joined the correct room before we start
 the test (#11693)

---
 cypress/e2e/read-receipts/editing-messages.spec.ts  | 2 ++
 cypress/e2e/read-receipts/high-level.spec.ts        | 2 ++
 cypress/e2e/read-receipts/missing-referents.spec.ts | 2 ++
 cypress/e2e/read-receipts/new-messages.spec.ts      | 2 ++
 cypress/e2e/read-receipts/reactions.spec.ts         | 2 ++
 cypress/e2e/read-receipts/redactions.spec.ts        | 2 ++
 6 files changed, 12 insertions(+)

diff --git a/cypress/e2e/read-receipts/editing-messages.spec.ts b/cypress/e2e/read-receipts/editing-messages.spec.ts
index b2d9c0e8eb..bf0ab0a940 100644
--- a/cypress/e2e/read-receipts/editing-messages.spec.ts
+++ b/cypress/e2e/read-receipts/editing-messages.spec.ts
@@ -103,10 +103,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });
diff --git a/cypress/e2e/read-receipts/high-level.spec.ts b/cypress/e2e/read-receipts/high-level.spec.ts
index bcce3b3d44..82683a1028 100644
--- a/cypress/e2e/read-receipts/high-level.spec.ts
+++ b/cypress/e2e/read-receipts/high-level.spec.ts
@@ -111,10 +111,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });
diff --git a/cypress/e2e/read-receipts/missing-referents.spec.ts b/cypress/e2e/read-receipts/missing-referents.spec.ts
index db27760ff9..35929a72f4 100644
--- a/cypress/e2e/read-receipts/missing-referents.spec.ts
+++ b/cypress/e2e/read-receipts/missing-referents.spec.ts
@@ -81,10 +81,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });
diff --git a/cypress/e2e/read-receipts/new-messages.spec.ts b/cypress/e2e/read-receipts/new-messages.spec.ts
index 66d9f75bef..eea82740d7 100644
--- a/cypress/e2e/read-receipts/new-messages.spec.ts
+++ b/cypress/e2e/read-receipts/new-messages.spec.ts
@@ -109,10 +109,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });
diff --git a/cypress/e2e/read-receipts/reactions.spec.ts b/cypress/e2e/read-receipts/reactions.spec.ts
index 818bf8f7ef..dca06f9d77 100644
--- a/cypress/e2e/read-receipts/reactions.spec.ts
+++ b/cypress/e2e/read-receipts/reactions.spec.ts
@@ -99,10 +99,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });
diff --git a/cypress/e2e/read-receipts/redactions.spec.ts b/cypress/e2e/read-receipts/redactions.spec.ts
index 9dfdbbbf3d..b201453f10 100644
--- a/cypress/e2e/read-receipts/redactions.spec.ts
+++ b/cypress/e2e/read-receipts/redactions.spec.ts
@@ -114,10 +114,12 @@ describe("Read receipts", () => {
                 // Invite the bot to both rooms
                 cy.inviteUser(alphaRoomId, bot.getUserId());
                 cy.viewRoomById(alphaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
 
                 cy.inviteUser(betaRoomId, bot.getUserId());
                 cy.viewRoomById(betaRoomId);
+                cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
                 cy.findByText(botName + " joined the room").should("exist");
             });
     });