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" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import {
|
import {
|
||||||
assertRead,
|
assertRead,
|
||||||
|
@ -32,22 +31,18 @@ import {
|
||||||
MessageContentSpec,
|
MessageContentSpec,
|
||||||
MessageFinder,
|
MessageFinder,
|
||||||
openThread,
|
openThread,
|
||||||
|
ReadReceiptSetup,
|
||||||
saveAndReload,
|
saveAndReload,
|
||||||
sendMessageAsClient,
|
sendMessageAsClient,
|
||||||
} from "./read-receipts-utils";
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function editOf(originalMessage: string, newMessage: string): MessageContentSpec {
|
function editOf(originalMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.editOf(originalMessage, newMessage);
|
return messageFinder.editOf(originalMessage, newMessage);
|
||||||
|
@ -81,36 +76,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
|
@ -123,7 +89,7 @@ describe("Read receipts", () => {
|
||||||
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room1 = roomAlpha;
|
const room1 = roomAlpha;
|
||||||
|
|
|
@ -18,7 +18,6 @@ limitations under the License.
|
||||||
|
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import {
|
import {
|
||||||
assertMessageLoaded,
|
assertMessageLoaded,
|
||||||
|
@ -40,22 +39,18 @@ import {
|
||||||
openThread,
|
openThread,
|
||||||
openThreadList,
|
openThreadList,
|
||||||
pageUp,
|
pageUp,
|
||||||
|
ReadReceiptSetup,
|
||||||
saveAndReload,
|
saveAndReload,
|
||||||
sendMessageAsClient,
|
sendMessageAsClient,
|
||||||
} from "./read-receipts-utils";
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.threadedOff(rootMessage, newMessage);
|
return messageFinder.threadedOff(rootMessage, newMessage);
|
||||||
|
@ -89,36 +84,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
|
@ -131,7 +97,7 @@ describe("Read receipts", () => {
|
||||||
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room1 = roomAlpha;
|
const room1 = roomAlpha;
|
||||||
|
|
|
@ -18,22 +18,23 @@ limitations under the License.
|
||||||
|
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import { goTo, Message, MessageContentSpec, MessageFinder, sendMessageAsClient } from "./read-receipts-utils";
|
import {
|
||||||
|
goTo,
|
||||||
|
Message,
|
||||||
|
MessageContentSpec,
|
||||||
|
MessageFinder,
|
||||||
|
ReadReceiptSetup,
|
||||||
|
sendMessageAsClient,
|
||||||
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.threadedOff(rootMessage, newMessage);
|
return messageFinder.threadedOff(rootMessage, newMessage);
|
||||||
|
@ -59,36 +60,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +69,7 @@ describe("Read receipts", () => {
|
||||||
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room1 = roomAlpha;
|
const room1 = roomAlpha;
|
||||||
|
|
|
@ -18,7 +18,6 @@ limitations under the License.
|
||||||
|
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import {
|
import {
|
||||||
assertRead,
|
assertRead,
|
||||||
|
@ -27,6 +26,7 @@ import {
|
||||||
assertUnreadLessThan,
|
assertUnreadLessThan,
|
||||||
assertUnreadThread,
|
assertUnreadThread,
|
||||||
backToThreadsList,
|
backToThreadsList,
|
||||||
|
ReadReceiptSetup,
|
||||||
goTo,
|
goTo,
|
||||||
many,
|
many,
|
||||||
markAsRead,
|
markAsRead,
|
||||||
|
@ -39,17 +39,12 @@ import {
|
||||||
} from "./read-receipts-utils";
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function replyTo(targetMessage: string, newMessage: string): MessageContentSpec {
|
function replyTo(targetMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.replyTo(targetMessage, newMessage);
|
return messageFinder.replyTo(targetMessage, newMessage);
|
||||||
|
@ -87,36 +82,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
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`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,6 @@ limitations under the License.
|
||||||
|
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import {
|
import {
|
||||||
assertRead,
|
assertRead,
|
||||||
|
@ -32,22 +31,18 @@ import {
|
||||||
MessageContentSpec,
|
MessageContentSpec,
|
||||||
MessageFinder,
|
MessageFinder,
|
||||||
openThread,
|
openThread,
|
||||||
|
ReadReceiptSetup,
|
||||||
saveAndReload,
|
saveAndReload,
|
||||||
sendMessageAsClient,
|
sendMessageAsClient,
|
||||||
} from "./read-receipts-utils";
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
function threadedOff(rootMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.threadedOff(rootMessage, newMessage);
|
return messageFinder.threadedOff(rootMessage, newMessage);
|
||||||
|
@ -77,36 +72,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
|
@ -119,7 +85,7 @@ describe("Read receipts", () => {
|
||||||
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room1 = roomAlpha;
|
const room1 = roomAlpha;
|
||||||
|
|
|
@ -15,8 +15,67 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { MatrixClient, MatrixEvent, Room, IndexedDBStore } from "matrix-js-sdk/src/matrix";
|
import type { MatrixClient, MatrixEvent, Room, IndexedDBStore } from "matrix-js-sdk/src/matrix";
|
||||||
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import Chainable = Cypress.Chainable;
|
import Chainable = Cypress.Chainable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up for a read receipt test:
|
||||||
|
* - Create a user with the supplied name
|
||||||
|
* - As that user, create two rooms with the supplied names
|
||||||
|
* - Create a bot with the supplied name
|
||||||
|
* - Invite the bot to both rooms and ensure that it has joined
|
||||||
|
*/
|
||||||
|
export class ReadReceiptSetup {
|
||||||
|
roomAlpha: string;
|
||||||
|
roomBeta: string;
|
||||||
|
alphaRoomId: string;
|
||||||
|
betaRoomId: string;
|
||||||
|
bot: MatrixClient;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
homeserver: HomeserverInstance,
|
||||||
|
userName: string,
|
||||||
|
botName: string,
|
||||||
|
roomAlpha: string,
|
||||||
|
roomBeta: string,
|
||||||
|
) {
|
||||||
|
this.roomAlpha = roomAlpha;
|
||||||
|
this.roomBeta = roomBeta;
|
||||||
|
|
||||||
|
// Create a user
|
||||||
|
cy.initTestUser(homeserver, userName)
|
||||||
|
// Create 2 rooms
|
||||||
|
.then(() => {
|
||||||
|
cy.createRoom({ name: roomAlpha }).then((createdRoomId) => {
|
||||||
|
this.alphaRoomId = createdRoomId;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
cy.createRoom({ name: roomBeta }).then((createdRoomId) => {
|
||||||
|
this.betaRoomId = createdRoomId;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
// Create a bot
|
||||||
|
.then(() => {
|
||||||
|
cy.getBot(homeserver, { displayName: botName }).then((botClient) => {
|
||||||
|
this.bot = botClient;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
// Invite the bot to both rooms
|
||||||
|
.then(() => {
|
||||||
|
cy.inviteUser(this.alphaRoomId, this.bot.getUserId());
|
||||||
|
cy.viewRoomById(this.alphaRoomId);
|
||||||
|
cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomAlpha).should("exist"));
|
||||||
|
cy.findByText(botName + " joined the room").should("exist");
|
||||||
|
|
||||||
|
cy.inviteUser(this.betaRoomId, this.bot.getUserId());
|
||||||
|
cy.viewRoomById(this.betaRoomId);
|
||||||
|
cy.get(".mx_LegacyRoomHeader").within(() => cy.findByTitle(roomBeta).should("exist"));
|
||||||
|
cy.findByText(botName + " joined the room").should("exist");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility that is able to find messages based on their content, by looking
|
* A utility that is able to find messages based on their content, by looking
|
||||||
* inside the `timeline` objects in the object model.
|
* inside the `timeline` objects in the object model.
|
||||||
|
|
|
@ -18,7 +18,6 @@ limitations under the License.
|
||||||
|
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
||||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||||
import {
|
import {
|
||||||
assertRead,
|
assertRead,
|
||||||
|
@ -35,22 +34,18 @@ import {
|
||||||
MessageContentSpec,
|
MessageContentSpec,
|
||||||
MessageFinder,
|
MessageFinder,
|
||||||
openThread,
|
openThread,
|
||||||
|
ReadReceiptSetup,
|
||||||
saveAndReload,
|
saveAndReload,
|
||||||
sendMessageAsClient,
|
sendMessageAsClient,
|
||||||
} from "./read-receipts-utils";
|
} from "./read-receipts-utils";
|
||||||
|
|
||||||
describe("Read receipts", () => {
|
describe("Read receipts", () => {
|
||||||
const userName = "Mae";
|
|
||||||
const botName = "Other User";
|
|
||||||
const roomAlpha = "Room Alpha";
|
const roomAlpha = "Room Alpha";
|
||||||
const roomBeta = "Room Beta";
|
const roomBeta = "Room Beta";
|
||||||
|
|
||||||
let homeserver: HomeserverInstance;
|
let homeserver: HomeserverInstance;
|
||||||
let betaRoomId: string;
|
|
||||||
let alphaRoomId: string;
|
|
||||||
let bot: MatrixClient | undefined;
|
|
||||||
|
|
||||||
let messageFinder: MessageFinder;
|
let messageFinder: MessageFinder;
|
||||||
|
let testSetup: ReadReceiptSetup;
|
||||||
|
|
||||||
function editOf(originalMessage: string, newMessage: string): MessageContentSpec {
|
function editOf(originalMessage: string, newMessage: string): MessageContentSpec {
|
||||||
return messageFinder.editOf(originalMessage, newMessage);
|
return messageFinder.editOf(originalMessage, newMessage);
|
||||||
|
@ -92,36 +87,7 @@ describe("Read receipts", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
messageFinder = new MessageFinder();
|
messageFinder = new MessageFinder();
|
||||||
|
testSetup = new ReadReceiptSetup(homeserver, "Mae", "Other User", roomAlpha, roomBeta);
|
||||||
// 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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
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`
|
* @param messages - the list of messages to send, these can be strings or implementations of MessageSpec like `editOf`
|
||||||
*/
|
*/
|
||||||
function receiveMessages(room: string, messages: Message[]) {
|
function receiveMessages(room: string, messages: Message[]) {
|
||||||
sendMessageAsClient(bot, room, messages);
|
sendMessageAsClient(testSetup.bot, room, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room1 = roomAlpha;
|
const room1 = roomAlpha;
|
||||||
|
|
Loading…
Reference in a new issue