1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-12-01 03:23:30 +03:00

Add cy.viewRoomById command (#11317)

... and use it to fix a racy composer test.

Fixes https://github.com/vector-im/element-web/issues/25527
This commit is contained in:
Richard van der Hoff
2023-07-25 22:55:13 +01:00
committed by GitHub
parent c57a4cb090
commit a47ee92094
2 changed files with 28 additions and 18 deletions

View File

@@ -36,10 +36,8 @@ describe("Composer", () => {
describe("CIDER", () => {
beforeEach(() => {
cy.initTestUser(homeserver, "Janet").then(() => {
cy.createRoom({ name: "Composing Room" });
});
cy.viewRoomByName("Composing Room");
cy.initTestUser(homeserver, "Janet");
cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId));
});
it("sends a message when you click send or press Enter", () => {
@@ -113,10 +111,8 @@ describe("Composer", () => {
describe("Rich text editor", () => {
beforeEach(() => {
cy.enableLabsFeature("feature_wysiwyg_composer");
cy.initTestUser(homeserver, "Janet").then(() => {
cy.createRoom({ name: "Composing Room" });
});
cy.viewRoomByName("Composing Room");
cy.initTestUser(homeserver, "Janet");
cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId));
});
describe("Commands", () => {
@@ -188,7 +184,7 @@ describe("Composer", () => {
describe("Plain text mode", () => {
it("autocomplete behaviour tests", () => {
// Setup a private room so we have another user to mention
// Set up a private room so we have another user to mention
const otherUserName = "Bob";
let bobClient: MatrixClient;
cy.getBot(homeserver, {
@@ -197,15 +193,16 @@ describe("Composer", () => {
bobClient = bob;
});
// create DM with bob
cy.getClient().then(async (cli) => {
const bobRoom = await cli.createRoom({ is_direct: true });
await cli.invite(bobRoom.room_id, bobClient.getUserId());
await cli.setAccountData("m.direct" as EventType, {
[bobClient.getUserId()]: [bobRoom.room_id],
});
});
cy.viewRoomByName("Bob");
cy.getClient()
.then(async (cli) => {
const bobRoom = await cli.createRoom({ is_direct: true });
await cli.invite(bobRoom.room_id, bobClient.getUserId());
await cli.setAccountData("m.direct" as EventType, {
[bobClient.getUserId()]: [bobRoom.room_id],
});
return bobRoom.room_id;
})
.then((bobRoomId) => cy.viewRoomById(bobRoomId));
// Select plain text mode after composer is ready
cy.get("div[contenteditable=true]").should("exist");