Files
nextcloud-server-mirror/tests/playwright/support/utils/password-confirmation.ts
Ferdinand Thiessen 9fc19ac7f5 test: migrate appstore tests to PlayWright
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-06-10 09:49:04 +02:00

35 lines
1.1 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { Page } from '@playwright/test'
/**
* Handle the password confirmation dialog if it appears
*
* @param page - The Playwright page object
* @param password - The password to enter (default: 'admin')
*/
export async function handlePasswordConfirmation(page: Page, password = 'admin') {
const dialog = page.locator('.modal-container:has-text("Authentication required")')
try {
// Check if the dialog exists within a short timeout
const dialogVisible = await dialog.isVisible({ timeout: 500 }).catch(() => false)
if (dialogVisible) {
// Fill the password field
await dialog.locator('input[type="password"]').fill(password)
// Click the confirm button
await dialog.getByRole('button', { name: 'Confirm' }).click()
// Wait for the dialog to disappear
await dialog.waitFor({ state: 'hidden' })
}
} catch (error) {
// Dialog didn't appear, which is fine - some operations might not require confirmation
}
}