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

Commit

Permalink
Use Cypress Testing Library - editing.spec.ts (#10480)
Browse files Browse the repository at this point in the history
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
  • Loading branch information
luixxiul authored Apr 3, 2023
1 parent 6f1a3af commit 4ed6e39
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions cypress/e2e/editing/editing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ describe("Editing", () => {

// Edit "Message"
const editLastMessage = (edit: string) => {
cy.get(".mx_EventTile_last").realHover();
cy.get(".mx_EventTile_last .mx_MessageActionBar_optionsButton", { timeout: 1000 })
.should("exist")
.realHover()
.get('.mx_EventTile_last [aria-label="Edit"]')
.click({ force: false });
cy.get(".mx_EventTile_last").realHover().findButton("Edit").click();
cy.get(".mx_BasicMessageComposer_input").type(`{selectAll}{del}${edit}{enter}`);
};

Expand All @@ -67,11 +62,7 @@ describe("Editing", () => {

const clickButtonViewSource = () => {
// Assert that "View Source" button is rendered and click it
cy.get(".mx_EventTile .mx_EventTile_line")
.realHover()
.contains(".mx_AccessibleButton", "View Source")
.should("exist")
.click();
cy.get(".mx_EventTile .mx_EventTile_line").realHover().findButton("View Source").click();
};

beforeEach(() => {
Expand All @@ -93,7 +84,7 @@ describe("Editing", () => {
it("should render and interact with the message edit history dialog", () => {
// Click the "Remove" button on the message edit history dialog
const clickButtonRemove = () => {
cy.get(".mx_EventTile_line").realHover().contains(".mx_AccessibleButton", "Remove").click({ force: false });
cy.get(".mx_EventTile_line").realHover().findButton("Remove").click();
};

cy.visit("/#/room/" + roomId);
Expand Down Expand Up @@ -250,10 +241,7 @@ describe("Editing", () => {
// Assert that the edited message is rendered
cy.get(".mx_MessageEditHistoryDialog li:nth-child(2)").within(() => {
// Assert that "Remove" button for the original message is rendered
cy.get(".mx_EventTile .mx_EventTile_line")
.realHover()
.contains(".mx_AccessibleButton", "Remove")
.should("exist");
cy.get(".mx_EventTile .mx_EventTile_line").realHover().findButton("Remove");

clickButtonViewSource();
});
Expand Down Expand Up @@ -283,11 +271,11 @@ describe("Editing", () => {
sendEvent(roomId);

// Edit message
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => {
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
cy.checkA11y();
cy.get(".mx_BasicMessageComposer_input").type("Foo{backspace}{backspace}{backspace}{enter}");
cy.checkA11y();
cy.contains(".mx_RoomView_body .mx_EventTile", "Message").within(() => {
cy.get(".mx_EventTile_line").realHover().findButton("Edit").click().checkA11y();
cy.get(".mx_EventTile_line .mx_BasicMessageComposer_input")
.type("Foo{backspace}{backspace}{backspace}{enter}")
.checkA11y();
});
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "Message");

Expand Down

0 comments on commit 4ed6e39

Please sign in to comment.