From 1df0e540a3c19d019419c5a79e094b582be3a655 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 22 May 2024 18:33:19 +0100 Subject: [PATCH] Try to fix E2E test flake on Firefox --- tests/e2e/specs/userprofile.cy.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/e2e/specs/userprofile.cy.js b/tests/e2e/specs/userprofile.cy.js index 8f34aef24..74b05e26d 100644 --- a/tests/e2e/specs/userprofile.cy.js +++ b/tests/e2e/specs/userprofile.cy.js @@ -87,24 +87,25 @@ describe('User Profile', () => { it('Sets reduced animations mode', () => { const testMenu = (shouldAnimate) => { - let animationSpy cy.get('[data-c-interactive]:first') .click() .get('.c-mutation-menu').as('mutationMenu') .should('be.visible') .then(([$el]) => { - animationSpy = cy.spy($el, 'animate') - }) - // Close menu: - .get('noscript').click({ force: true }) - .get('@mutationMenu') - .should('not.exist') - .then(() => { - if (shouldAnimate) { - expect(animationSpy).to.be.called - } else { - expect(animationSpy).not.to.be.called - } + const animationSpy = cy.spy($el, 'animate') + // Close menu (wait because animation might interfere with click outside on Firefox): + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(400) + cy.get('noscript').click({ force: true }) + .get('@mutationMenu') + .should('not.exist') + .then(() => { + if (shouldAnimate) { + expect(animationSpy).to.be.called + } else { + expect(animationSpy).not.to.be.called + } + }) }) }