Skip to content

Commit

Permalink
Use leaveRoomWithSilentFail where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
estellecomment committed Nov 7, 2023
1 parent cdce65e commit 31884ef
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
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);
});
});
});
15 changes: 15 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,12 @@ Cypress.Commands.add("joinRoom", (roomIdOrAlias: string): Chainable<Room> => {
Cypress.Commands.add("leaveRoom", (roomId: string): Chainable<{}> => {
return cy.getClient().then((cli) => cli.leave(roomId));
});

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 31884ef

Please sign in to comment.