From 199f8bd4f4ca0882f6b24806f43774cad81449ea Mon Sep 17 00:00:00 2001 From: Peter Ringelmann Date: Wed, 13 May 2026 17:53:22 +0200 Subject: [PATCH] test(e2e): backport handlePasswordConfirmation helper Signed-off-by: Peter Ringelmann --- cypress/e2e/core-utils.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cypress/e2e/core-utils.ts b/cypress/e2e/core-utils.ts index d0fd049e8b0..c01ee05a61e 100644 --- a/cypress/e2e/core-utils.ts +++ b/cypress/e2e/core-utils.ts @@ -10,6 +10,32 @@ export function getUnifiedSearchModal() { return cy.get('#unified-search') } +/** + * Handle the confirm password dialog (if needed) + * + * @param adminPassword The admin password for the dialog + */ +export function handlePasswordConfirmation(adminPassword = 'admin') { + const handleModal = (context: Cypress.Chainable) => { + return context.contains('.modal-container', 'Authentication required') + .if() + .within(() => { + cy.get('input[type="password"]') + .type(adminPassword) + cy.findByRole('button', { name: 'Confirm' }) + .click() + }) + } + + return cy.get('body') + .if() + .then(() => handleModal(cy.get('body'))) + .else() + // Handle if inside a cy.within + .root().closest('body') + .then(($body) => handleModal(cy.wrap($body))) +} + /** * Open the unified search modal */