From 29d304942321ed713d126d8557046c51d6811eaa Mon Sep 17 00:00:00 2001 From: schiwaa Date: Tue, 11 Feb 2025 21:51:51 +0100 Subject: [PATCH] bypass uncaught exceptions during login --- frontend-e2e/cypress/e2e/experimental.cy.js | 11 ++++++++++- frontend-e2e/cypress/support/commands.js | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend-e2e/cypress/e2e/experimental.cy.js b/frontend-e2e/cypress/e2e/experimental.cy.js index cf40ab2..e865b0b 100644 --- a/frontend-e2e/cypress/e2e/experimental.cy.js +++ b/frontend-e2e/cypress/e2e/experimental.cy.js @@ -19,6 +19,14 @@ describe('login and logout with authentication modal, captcha v3 and fetch(POST) cy.log('LOGIN:') cy.log("Cypress.browser.isHeaded? " + Cypress.browser.isHeaded); + if (Cypress.browser.isHeadless){ + // Sign-in with google recaptcha v3 in headless mode --> "TypeError: Cannot read properties of null (reading 'message')" + Cypress.on('uncaught:exception', (err) => { + if (err.message.includes('Cannot read properties of null')) { + return false + } + }) + } cy.contains('header a', 'Sign in').click(); cy.get('#loginEmail').wait(500).type(admin.username, { delay: 50 }); cy.get('#loginPassword').wait(500).type(admin.password, { delay: 50 }); @@ -39,7 +47,8 @@ describe('login and logout with authentication modal, captcha v3 and fetch(POST) // some fetch(POST) for headless mode describe('addStemma and deleteStemma with login, passes in headless mode despite fetch(POST)', () => { - it('passes in headless mode local and on github. passes in local headed mode. with original guest config', {}, () => { + // it('passes in headless mode local and on github. passes in local headed mode. with original guest config', { retries: 5 }, () => { + it('passes in headless mode local and on github. passes in local headed mode. with original guest config', () => { cy.loginViaUi(admin); const tradition = test_traditions.find(trad => trad.title.startsWith('John verse')); cy.log('tradition.title: ' + tradition.title); diff --git a/frontend-e2e/cypress/support/commands.js b/frontend-e2e/cypress/support/commands.js index 9de6d9b..0322dd0 100644 --- a/frontend-e2e/cypress/support/commands.js +++ b/frontend-e2e/cypress/support/commands.js @@ -26,6 +26,14 @@ // Login via user interface Cypress.Commands.add('loginViaUi', (userObj) => { + if (Cypress.browser.isHeadless){ + // Sign-in with google recaptcha v3 in headless mode --> "TypeError: Cannot read properties of null (reading 'message')" + Cypress.on('uncaught:exception', (err) => { + if (err.message.includes('Cannot read properties of null')) { + return false + } + }) + } cy.log("Cypress.browser.isHeaded? " + Cypress.browser.isHeaded); cy.contains('header a', 'Sign in').click(); cy.get('#loginEmail').wait(500).type(userObj.username, { delay: 50 });