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,
|
||||
|
@ -35,22 +34,18 @@ import {
|
|||
MessageContentSpec,
|
||||
MessageFinder,
|
||||
openThread,
|
||||
ReadReceiptSetup,
|
||||
saveAndReload,
|
||||
sendMessageAsClient,
|
||||
} 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 editOf(originalMessage: string, newMessage: string): MessageContentSpec {
|
||||
return messageFinder.editOf(originalMessage, newMessage);
|
||||
|
@ -92,36 +87,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(() => {
|
||||
|
@ -134,7 +100,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);
|
||||
}
|
||||
|
||||
const room1 = roomAlpha;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue