test(e2e): backport handlePasswordConfirmation helper

Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
This commit is contained in:
Peter Ringelmann 2026-05-13 17:53:22 +02:00
parent cab6c79b3c
commit 199f8bd4f4

View file

@ -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
*/