Use Cypress Testing Library - editing.spec.ts (#10480)

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
pull/28217/head
Suguru Hirahara 2023-04-03 13:06:58 +09:00 committed by GitHub
parent 6f1a3af895
commit 4ed6e39067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 21 deletions

View File

@ -46,12 +46,7 @@ describe("Editing", () => {
// Edit "Message" // Edit "Message"
const editLastMessage = (edit: string) => { const editLastMessage = (edit: string) => {
cy.get(".mx_EventTile_last").realHover(); cy.get(".mx_EventTile_last").realHover().findButton("Edit").click();
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_BasicMessageComposer_input").type(`{selectAll}{del}${edit}{enter}`); cy.get(".mx_BasicMessageComposer_input").type(`{selectAll}{del}${edit}{enter}`);
}; };
@ -67,11 +62,7 @@ describe("Editing", () => {
const clickButtonViewSource = () => { const clickButtonViewSource = () => {
// Assert that "View Source" button is rendered and click it // Assert that "View Source" button is rendered and click it
cy.get(".mx_EventTile .mx_EventTile_line") cy.get(".mx_EventTile .mx_EventTile_line").realHover().findButton("View Source").click();
.realHover()
.contains(".mx_AccessibleButton", "View Source")
.should("exist")
.click();
}; };
beforeEach(() => { beforeEach(() => {
@ -93,7 +84,7 @@ describe("Editing", () => {
it("should render and interact with the message edit history dialog", () => { it("should render and interact with the message edit history dialog", () => {
// Click the "Remove" button on the message edit history dialog // Click the "Remove" button on the message edit history dialog
const clickButtonRemove = () => { 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); cy.visit("/#/room/" + roomId);
@ -250,10 +241,7 @@ describe("Editing", () => {
// Assert that the edited message is rendered // Assert that the edited message is rendered
cy.get(".mx_MessageEditHistoryDialog li:nth-child(2)").within(() => { cy.get(".mx_MessageEditHistoryDialog li:nth-child(2)").within(() => {
// Assert that "Remove" button for the original message is rendered // Assert that "Remove" button for the original message is rendered
cy.get(".mx_EventTile .mx_EventTile_line") cy.get(".mx_EventTile .mx_EventTile_line").realHover().findButton("Remove");
.realHover()
.contains(".mx_AccessibleButton", "Remove")
.should("exist");
clickButtonViewSource(); clickButtonViewSource();
}); });
@ -283,11 +271,11 @@ describe("Editing", () => {
sendEvent(roomId); sendEvent(roomId);
// Edit message // Edit message
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => { cy.contains(".mx_RoomView_body .mx_EventTile", "Message").within(() => {
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover cy.get(".mx_EventTile_line").realHover().findButton("Edit").click().checkA11y();
cy.checkA11y(); cy.get(".mx_EventTile_line .mx_BasicMessageComposer_input")
cy.get(".mx_BasicMessageComposer_input").type("Foo{backspace}{backspace}{backspace}{enter}"); .type("Foo{backspace}{backspace}{backspace}{enter}")
cy.checkA11y(); .checkA11y();
}); });
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "Message"); cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "Message");