Skip to content

Commit

Permalink
Merge pull request #815 from tchapgouv/fix-leave-room-temporarily
Browse files Browse the repository at this point in the history
e2e : Use cy.leaveRoomSilently for rooms with externs (temporarily)
  • Loading branch information
estellecomment authored Nov 7, 2023
2 parents 0a54d6f + 9a2d982 commit 9280ea1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/content-scanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Content Scanner", () => {

const roomName = "test/" + today + "/content_scanner_" + RandomUtils.generateRandom(4);

RoomUtils.createPrivateWithExternalRoom(roomName).then(() => {
RoomUtils.createPrivateRoom(roomName).then(() => {
//open room
cy.get('[aria-label="' + roomName + '"]').click();
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/create-room/create-room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("Create Room", () => {
console.log("roomIdToCleanup", urlString.split("/#/room/")[1]);
const roomId = urlString.split("/#/room/")[1];
if (roomId) {
cy.leaveRoom(roomId);
cy.leaveRoomWithSilentFail(roomId);
// todo also forgetRoom to save resources.
} else {
console.error("Did not find roomId in url. Not cleaning up.");
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/room-access-settings/room-access-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("Check room access settings", () => {
cy.get(".mx_AccessibleButton").should("have.attr", "aria-disabled", "true");
});

cy.leaveRoom(roomId);
cy.leaveRoomWithSilentFail(roomId);
});
});

Expand All @@ -116,7 +116,7 @@ describe("Check room access settings", () => {
//assert room header is updated
cy.get(".tc_RoomHeader_external").should("exist");

cy.leaveRoom(roomId);
cy.leaveRoomWithSilentFail(roomId);
});
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/tchap-external-room-style.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Style of external rooms", () => {
cy.get(".mx_DecoratedRoomAvatar_icon_external"); // lock icon on room avatar
});

cy.leaveRoom(roomId);
cy.leaveRoomWithSilentFail(roomId);
});
});
});
16 changes: 16 additions & 0 deletions cypress/support/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ declare global {
* @param roomId the id of the room to invite to
*/
leaveRoom(roomId: string): Chainable<{}>;
/**
* :TCHAP: added this function
* Leave a room. If the leaving fails, log and carry on without crashing the test.
* @param roomId the id of the room to invite to
*/
leaveRoomWithSilentFail(roomId: string): Chainable<{}>;
}
}
}
Expand Down Expand Up @@ -239,3 +245,13 @@ Cypress.Commands.add("joinRoom", (roomIdOrAlias: string): Chainable<Room> => {
Cypress.Commands.add("leaveRoom", (roomId: string): Chainable<{}> => {
return cy.getClient().then((cli) => cli.leave(roomId));
});

// Needed until this is fixed : https://github.com/tchapgouv/synapse-manage-last-admin/issues/11
Cypress.Commands.add("leaveRoomWithSilentFail", (roomId: string): Chainable<{}> => {
return cy.getClient().then((cli) => {
return cli.leave(roomId).catch((err) => {
cy.log("COULD NOT LEAVE ROOM ! Continuing silently.", err);
return {};
});
});
});

0 comments on commit 9280ea1

Please sign in to comment.