Files
ComfyUI_frontend/browser_tests/tests/userSelectView.spec.ts
snomiao 8564c0b4bf fix: improve error handling in Playwright tests
- Remove unnecessary .catch(() => {}) in userSelectView test that was
  hiding potential failures
- Add explanatory comments for legitimate .catch(() => {}) usage in
  cleanup blocks of linkInteraction tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 08:52:49 +00:00

60 lines
2.0 KiB
TypeScript

import { expect } from '@playwright/test'
import { userSelectPageFixture as test } from '../fixtures/UserSelectPage'
/**
* Expects ComfyUI backend to be launched with `--multi-user` flag.
*/
test.describe('User Select View', () => {
test.beforeEach(async ({ userSelectPage, page }) => {
await page.goto(userSelectPage.url)
await page.evaluate(() => {
localStorage.clear()
sessionStorage.clear()
})
})
test('Redirects to user select view if no user is logged in', async ({
userSelectPage,
page
}) => {
await page.goto(userSelectPage.url)
await expect(userSelectPage.container).toBeVisible()
expect(page.url()).toBe(userSelectPage.selectionUrl)
})
test('Can create new user', async ({ userSelectPage, page }) => {
const randomUser = `test-user-${Math.random().toString(36).substring(2, 7)}`
await page.goto(userSelectPage.url)
await expect(page).toHaveURL(userSelectPage.selectionUrl)
await userSelectPage.newUserInput.fill(randomUser)
await userSelectPage.nextButton.click()
await expect(page).toHaveURL(userSelectPage.url)
})
test('Can choose existing user', async ({ userSelectPage, page }) => {
await page.goto(userSelectPage.url)
await expect(page).toHaveURL(userSelectPage.selectionUrl)
await userSelectPage.existingUserSelect.click()
const dropdownList = page.locator('.p-select-list')
await expect(dropdownList).toBeVisible()
// Try to click first option if it exists
const firstOption = page.locator('.p-select-list .p-select-option').first()
await firstOption.waitFor({ state: 'visible', timeout: 5000 })
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, { timeout: 15000 })
})
})