From ab647b231d53599583dd0b767e61ea0f273e4b1f Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Fri, 6 Oct 2023 11:06:38 +0200 Subject: [PATCH] fix: Flaky mfa e2e tests (no-changelog) (#7192) Github issue / Community forum post (link here to close automatically): --- cypress/e2e/27-two-factor-authentication.cy.ts | 7 ++++--- cypress/pages/settings-personal.ts | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/27-two-factor-authentication.cy.ts b/cypress/e2e/27-two-factor-authentication.cy.ts index 8d710939efaec..5e93909331f41 100644 --- a/cypress/e2e/27-two-factor-authentication.cy.ts +++ b/cypress/e2e/27-two-factor-authentication.cy.ts @@ -35,9 +35,10 @@ describe('Two-factor authentication', () => { expect(err.message).to.include('Not logged in'); return false; }); + cy.intercept('GET', '/rest/mfa/qr').as('getMfaQrCode'); }); - it.skip('Should be able to login with MFA token', () => { + it('Should be able to login with MFA token', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); @@ -47,7 +48,7 @@ describe('Two-factor authentication', () => { mainSidebar.actions.signout(); }); - it.skip('Should be able to login with recovery code', () => { + it('Should be able to login with recovery code', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); @@ -56,7 +57,7 @@ describe('Two-factor authentication', () => { mainSidebar.actions.signout(); }); - it.skip('Should be able to disable MFA in account', () => { + it('Should be able to disable MFA in account', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); diff --git a/cypress/pages/settings-personal.ts b/cypress/pages/settings-personal.ts index 06fd218daa69d..79cf58c752da3 100644 --- a/cypress/pages/settings-personal.ts +++ b/cypress/pages/settings-personal.ts @@ -60,11 +60,14 @@ export class PersonalSettingsPage extends BasePage { enableMfa: () => { cy.visit(this.url); this.getters.enableMfaButton().click(); + cy.wait('@getMfaQrCode'); + mfaSetupModal.getters.copySecretToClipboardButton().should('be.visible'); mfaSetupModal.getters.copySecretToClipboardButton().realClick(); cy.readClipboard().then((secret) => { const token = generateOTPToken(secret); mfaSetupModal.getters.tokenInput().type(token); + mfaSetupModal.getters.downloadRecoveryCodesButton().should('be.visible'); mfaSetupModal.getters.downloadRecoveryCodesButton().click(); mfaSetupModal.getters.saveButton().click(); });