File tree Expand file tree Collapse file tree
tests/playwright/support/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import type { Page } from '@playwright/test'
77
8+ import { expect } from '@playwright/test'
9+
810/**
911 * Handle the password confirmation dialog if it appears
1012 *
@@ -14,21 +16,13 @@ import type { Page } from '@playwright/test'
1416export async function handlePasswordConfirmation ( page : Page , password = 'admin' ) {
1517 const dialog = page . locator ( '.modal-container:has-text("Authentication required")' )
1618
17- try {
18- // Check if the dialog exists within a short timeout
19- const dialogVisible = await dialog . isVisible ( { timeout : 500 } ) . catch ( ( ) => false )
20-
21- if ( dialogVisible ) {
22- // Fill the password field
19+ await expect ( dialog ) . toBeVisible ( { timeout : 500 } )
20+ . then ( async ( ) => {
2321 await dialog . locator ( 'input[type="password"]' ) . fill ( password )
24-
25- // Click the confirm button
2622 await dialog . getByRole ( 'button' , { name : 'Confirm' } ) . click ( )
27-
28- // Wait for the dialog to disappear
29- await dialog . waitFor ( { state : 'hidden' } )
30- }
31- } catch {
32- // Dialog didn't appear, which is fine - some operations might not require confirmation
33- }
23+ await expect ( dialog ) . toBeHidden ( )
24+ } )
25+ . catch ( ( ) => {
26+ // Dialog didn't appear — some operations don't require confirmation.
27+ } )
3428}
You can’t perform that action at this time.
0 commit comments