Skip to content

Commit fe8efc8

Browse files
committed
chore(playwright): Rewrite login handler to avoid race conditions
Assisted-by: ClaudeCode:claude-opus-4.6[1M] Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
1 parent fe12dc2 commit fe8efc8

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

tests/playwright/support/utils/password-confirmation.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import type { Page } from '@playwright/test'
77

8+
import { expect } from '@playwright/test'
9+
810
/**
911
* Handle the password confirmation dialog if it appears
1012
*
@@ -15,20 +17,11 @@ export async function handlePasswordConfirmation(page: Page, password = 'admin')
1517
const dialog = page.locator('.modal-container:has-text("Authentication required")')
1618

1719
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
23-
await dialog.locator('input[type="password"]').fill(password)
24-
25-
// Click the confirm button
26-
await dialog.getByRole('button', { name: 'Confirm' }).click()
27-
28-
// Wait for the dialog to disappear
29-
await dialog.waitFor({ state: 'hidden' })
30-
}
20+
await dialog.waitFor({state: 'visible', timeout: 500})
21+
await dialog.locator('input[type="password"]').fill(password)
22+
await dialog.getByRole('button', {name: 'Confirm'}).click()
23+
await dialog.waitFor({state: 'hidden'})
3124
} catch {
32-
// Dialog didn't appear, which is fine - some operations might not require confirmation
25+
// Dialog didn't appearsome operations don't require confirmation.
3326
}
3427
}

0 commit comments

Comments
 (0)