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

Commit

Permalink
Update Cypress test files under support/ directory - use Cypress Te…
Browse files Browse the repository at this point in the history
…sting Library (#10619)

* Update support files - use Cypress Testing Library

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>

* Fix openMessageComposerOptions()

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>

---------

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
  • Loading branch information
luixxiul committed Apr 17, 2023
1 parent 56e4ae4 commit 4c0efc5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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

0 comments on commit 4c0efc5

Please sign in to comment.