From 7899f7903fe222e0e990b376397747a24d3b6629 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 14 Mar 2025 12:41:26 +0100 Subject: [PATCH] test: fix intermitent e2e --- test/cypress/integration/outLogin/logout.spec.js | 11 ++++++++++- test/cypress/support/index.js | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/cypress/integration/outLogin/logout.spec.js b/test/cypress/integration/outLogin/logout.spec.js index 373f0cc93..b3583e4d3 100644 --- a/test/cypress/integration/outLogin/logout.spec.js +++ b/test/cypress/integration/outLogin/logout.spec.js @@ -24,12 +24,21 @@ describe('Logout', () => { }, }, statusMessage: 'AUTHORIZATION_REQUIRED', - }); + }).as('badRequest'); }); it('when token not exists', () => { + const exceptionHandler = (err) => { + if (err.code === 'AUTHORIZATION_REQUIRED') return; + }; + Cypress.on('uncaught:exception', exceptionHandler); + cy.get('.q-list').first().should('be.visible').click(); + cy.wait('@badRequest'); + cy.checkNotification('Authorization Required'); + + Cypress.off('uncaught:exception', exceptionHandler); }); }); }); diff --git a/test/cypress/support/index.js b/test/cypress/support/index.js index 87e869b6d..b0f0fb3b1 100644 --- a/test/cypress/support/index.js +++ b/test/cypress/support/index.js @@ -40,6 +40,11 @@ style.innerHTML = ` `; document.head.appendChild(style); +// FIXME: https://redmine.verdnatura.es/issues/8771 +Cypress.on('uncaught:exception', (err) => { + if (err.code === 'ERR_CANCELED') return false; +}); + const waitForApiReady = (url, maxRetries = 20, delay = 1000) => { let retries = 0;