Share code for room initialisation between read receipt tests
This commit is contained in:
parent
966d8bd695
commit
ff1057fb0a
7 changed files with 90 additions and 229 deletions
|
@ -18,7 +18,6 @@ limitations under the License.
|
|||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||
import {
|
||||
assertRead,
|
||||
|
@ -27,6 +26,7 @@ import {
|
|||
assertUnreadLessThan,
|
||||
assertUnreadThread,
|
||||
backToThreadsList,
|
||||
ReadReceiptSetup,
|
||||
goTo,
|
||||
many,
|
||||
markAsRead,
|
||||
|
@ -39,17 +39,12 @@ import {
|
|||
} from "./read-receipts-utils";
|
||||
|
||||
describe("Read receipts", () => {
|
||||
const userName = "Mae";
|
||||
const botName = "Other User";
|
||||
const roomAlpha = "Room Alpha";
|
||||
const roomBeta = "Room Beta";
|
||||
|
||||
let homeserver: HomeserverInstance;
|
||||
let betaRoomId: string;
|
||||
let alphaRoomId: string;
|
||||
let bot: MatrixClient | undefined;
|
||||
|
||||
let messageFinder: MessageFinder;
|
||||
let testSetup: ReadReceiptSetup;
|
||||
|
||||
function replyTo(targetMessage: string, newMessage: string): MessageContentSpec {
|
||||
return messageFinder.replyTo(targetMessage, newMessage);
|
||||
|
@ -87,36 +82,7 @@ describe("Read receipts", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
messageFinder = new MessageFinder();
|
||||
|
||||
// Create 2 rooms: Alpha & Beta. We join the bot to both of them
|
||||
cy.initTestUser(homeserver, userName)
|
||||
.then(() => {
|
||||
cy.createRoom({ name: roomAlpha }).then((createdRoomId) => {
|
||||
alphaRoomId = createdRoomId;
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
cy.createRoom({ name: roomBeta }).then((createdRoomId) => {
|
||||
betaRoomId = createdRoomId;
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
cy.getBot(homeserver, { displayName: botName }).then((botClient) => {
|
||||
bot = botClient;
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
// 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");
|
||||
});
|
||||
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
|
@ -129,7 +95,7 @@ describe("Read receipts", () => {
|
|||
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||
*/
|
||||
function receiveMessages(room: string, messages: Message[]) {
|
||||
sendMessageAsClient(bot, room, messages);
|
||||
sendMessageAsClient(testSetup.bot, room, messages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue