From 533fd1cb6f382a4f441d5c920d84c6c3c4cd3776 Mon Sep 17 00:00:00 2001 From: snomiao Date: Wed, 24 Sep 2025 16:39:14 +0000 Subject: [PATCH] fix: flaky test 'Can choose existing user' in userSelectView.spec.ts --- browser_tests/tests/userSelectView.spec.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/browser_tests/tests/userSelectView.spec.ts b/browser_tests/tests/userSelectView.spec.ts index 38b1a2317..0f52f551e 100644 --- a/browser_tests/tests/userSelectView.spec.ts +++ b/browser_tests/tests/userSelectView.spec.ts @@ -35,9 +35,27 @@ test.describe('User Select View', () => { test('Can choose existing user', async ({ userSelectPage, page }) => { await page.goto(userSelectPage.url) await expect(page).toHaveURL(userSelectPage.selectionUrl) + await userSelectPage.existingUserSelect.click() - await page.locator('.p-select-list .p-select-option').first().click() + + const dropdownList = page.locator('.p-select-list') + await expect(dropdownList).toBeVisible() + + // Wait for dropdown to populate + await page.waitForTimeout(500) + + // Try to click first option if it exists + const firstOption = page.locator('.p-select-list .p-select-option').first() + + if (await firstOption.count() > 0) { + await firstOption.click() + } else { + // No options available - close dropdown and use new user input + await page.keyboard.press('Escape') + await userSelectPage.newUserInput.fill(`test-user-${Date.now()}`) + } + await userSelectPage.nextButton.click() - await expect(page).toHaveURL(userSelectPage.url) + await expect(page).toHaveURL(userSelectPage.url, { timeout: 15000 }) }) })