From 54bec393bf1768e63bc29a74b8d3cd186ce097bc Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Mon, 30 Dec 2024 20:54:54 +0000 Subject: [PATCH] fix: recursive loggin in upon failed login attempt --- cypress/support/commands.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 00faa58..ab552eb 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -53,7 +53,15 @@ Cypress.Commands.add('login', (path) => { cy.get('input[name="password"]').type('Abc12345678'); cy.get('button[type="submit"]').click(); cy.wait('@sessionCheck').its('response.statusCode').should('equal', 200); + + // Sometimes the page hangs after logging in. + // If this happens we reload the page and log in again. cy.reload(); + cy.get('body').then(($b) => { + if ($b.text().includes('Log in to your Strapi account')) { + cy.login(); + } + }); } // Register if ($body.text().includes('Credentials are only used to authenticate in Strapi')) {