From 7c34d66bdea01cdf842191b560d83a3c322c95cc Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 23 May 2023 11:09:31 +0100 Subject: [PATCH] Cypress: workaround for EventTile being remounted (#10961) (Hopefully) fixes https://github.com/vector-im/element-web/issues/25417 --- cypress/e2e/audio-player/audio-player.spec.ts | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/cypress/e2e/audio-player/audio-player.spec.ts b/cypress/e2e/audio-player/audio-player.spec.ts index f46205a5ec7..a59fb64ab46 100644 --- a/cypress/e2e/audio-player/audio-player.spec.ts +++ b/cypress/e2e/audio-player/audio-player.spec.ts @@ -333,30 +333,33 @@ describe("Audio player", () => { // On a thread cy.get(".mx_ThreadView").within(() => { - cy.get(".mx_EventTile_last") - .within(() => { - // Assert that the player is correctly rendered on a thread - cy.get(".mx_EventTile_mediaLine .mx_MAudioBody .mx_AudioPlayer_container").within(() => { - // Assert that the counter is zero before clicking the play button - cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist"); - - // Find and click "Play" button, the wait is to make the test less flaky - cy.findByRole("button", { name: "Play" }).should("exist"); - cy.wait(500).findByRole("button", { name: "Play" }).click(); - - // Assert that "Pause" button can be found - cy.findByRole("button", { name: "Pause" }).should("exist"); - - // Assert that the timer is reset when the audio file finished playing - cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist"); - - // Assert that "Play" button can be found - cy.findByRole("button", { name: "Play" }).should("exist").should("not.have.attr", "disabled"); - }); - }) - .realHover() - .findByRole("button", { name: "Reply" }) - .click(); // Find and click "Reply" button + cy.get(".mx_EventTile_last").within(() => { + // Assert that the player is correctly rendered on a thread + cy.get(".mx_EventTile_mediaLine .mx_MAudioBody .mx_AudioPlayer_container").within(() => { + // Assert that the counter is zero before clicking the play button + cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist"); + + // Find and click "Play" button, the wait is to make the test less flaky + cy.findByRole("button", { name: "Play" }).should("exist"); + cy.wait(500).findByRole("button", { name: "Play" }).click(); + + // Assert that "Pause" button can be found + cy.findByRole("button", { name: "Pause" }).should("exist"); + + // Assert that the timer is reset when the audio file finished playing + cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist"); + + // Assert that "Play" button can be found + cy.findByRole("button", { name: "Play" }).should("exist").should("not.have.attr", "disabled"); + }); + }); + + // Find and click "Reply" button + // + // Calling cy.get(".mx_EventTile_last") again here is a workaround for + // https://github.com/matrix-org/matrix-js-sdk/issues/3394: the event tile may have been re-mounted while + // the audio was playing. + cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Reply" }).click(); cy.get(".mx_MessageComposer--compact").within(() => { // Assert that the reply preview is rendered on the message composer