Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update Cypress test files under support/ directory - use Cypress Testing Library #10619

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/support/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Cypress.Commands.add("getComposer", (isRightPanel?: boolean): Chainable<JQuery>

Cypress.Commands.add("openMessageComposerOptions", (isRightPanel?: boolean): Chainable<JQuery> => {
cy.getComposer(isRightPanel).within(() => {
cy.get('[aria-label="More options"]').click();
cy.findByRole("button", { name: "More options" }).click();
});
return cy.get(".mx_MessageComposer_Menu");
});
Expand Down
14 changes: 7 additions & 7 deletions cypress/support/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ Cypress.Commands.add(
);

Cypress.Commands.add("openUserMenu", (): Chainable<JQuery<HTMLElement>> => {
cy.get('[aria-label="User menu"]').click();
cy.findByRole("button", { name: "User menu" }).click();
return cy.get(".mx_ContextualMenu");
});

Cypress.Commands.add("openUserSettings", (tab?: string): Chainable<JQuery<HTMLElement>> => {
cy.openUserMenu().within(() => {
cy.get('[aria-label="All settings"]').click();
cy.findByRole("menuitem", { name: "All settings" }).click();
});
return cy.get(".mx_UserSettingsDialog").within(() => {
if (tab) {
Expand All @@ -141,9 +141,9 @@ Cypress.Commands.add("openUserSettings", (tab?: string): Chainable<JQuery<HTMLEl
});

Cypress.Commands.add("openRoomSettings", (tab?: string): Chainable<JQuery<HTMLElement>> => {
cy.get(".mx_RoomHeader_name").click();
cy.findByRole("button", { name: "Room options" }).click();
cy.get(".mx_RoomTile_contextMenu").within(() => {
cy.get('[aria-label="Settings"]').click();
cy.findByRole("menuitem", { name: "Settings" }).click();
});
return cy.get(".mx_RoomSettingsDialog").within(() => {
if (tab) {
Expand All @@ -159,15 +159,15 @@ Cypress.Commands.add("switchTab", (tab: string): Chainable<JQuery<HTMLElement>>
});

Cypress.Commands.add("closeDialog", (): Chainable<JQuery<HTMLElement>> => {
return cy.get('[aria-label="Close dialog"]').click();
return cy.findByRole("button", { name: "Close dialog" }).click();
});

Cypress.Commands.add("joinBeta", (name: string): Chainable<JQuery<HTMLElement>> => {
return cy
.contains(".mx_BetaCard_title", name)
.closest(".mx_BetaCard")
.within(() => {
return cy.get(".mx_BetaCard_buttons").contains("Join the beta").click();
return cy.get(".mx_BetaCard_buttons").findByRole("button", { name: "Join the beta" }).click();
});
});

Expand All @@ -176,7 +176,7 @@ Cypress.Commands.add("leaveBeta", (name: string): Chainable<JQuery<HTMLElement>>
.contains(".mx_BetaCard_title", name)
.closest(".mx_BetaCard")
.within(() => {
return cy.get(".mx_BetaCard_buttons").contains("Leave the beta").click();
return cy.get(".mx_BetaCard_buttons").findByRole("button", { name: "Leave the beta" }).click();
});
});

Expand Down
4 changes: 2 additions & 2 deletions cypress/support/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ declare global {
}

Cypress.Commands.add("viewRoomByName", (name: string): Chainable<JQuery<HTMLElement>> => {
return cy.get(`.mx_RoomTile[aria-label="${name}"]`).click();
return cy.findByRole("treeitem", { name: name }).should("have.class", "mx_RoomTile").click();
});

Cypress.Commands.add("getSpacePanelButton", (name: string): Chainable<JQuery<HTMLElement>> => {
return cy.get(`.mx_SpaceButton[aria-label="${name}"]`);
return cy.findByRole("button", { name: name }).should("have.class", "mx_SpaceButton");
});

Cypress.Commands.add("viewSpaceByName", (name: string): Chainable<JQuery<HTMLElement>> => {
Expand Down