mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Adds `await expect(locator).toBeVisible()` before `.click()` calls across 104 test and fixture files (431 assertions). Gives immediate, descriptive failures instead of generic actionability timeouts. Skips force clicks, canvas/mouse coordinate clicks, custom click methods, catch chains, and toPass retry blocks. Updates FLAKE_PREVENTION_RULES.md with the new rule.
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
import type { Locator, Page } from '@playwright/test'
|
|
|
|
export class ToastHelper {
|
|
constructor(private readonly page: Page) {}
|
|
|
|
get visibleToasts(): Locator {
|
|
return this.page.locator('.p-toast-message:visible')
|
|
}
|
|
|
|
async getToastErrorCount(): Promise<number> {
|
|
return await this.page
|
|
.locator('.p-toast-message.p-toast-message-error')
|
|
.count()
|
|
}
|
|
|
|
async getVisibleToastCount(): Promise<number> {
|
|
return await this.visibleToasts.count()
|
|
}
|
|
|
|
async closeToasts(requireCount = 0): Promise<void> {
|
|
if (requireCount) {
|
|
await this.visibleToasts
|
|
.nth(requireCount - 1)
|
|
.waitFor({ state: 'visible' })
|
|
}
|
|
|
|
// Clear all toasts
|
|
const toastCloseButtons = await this.page
|
|
.locator('.p-toast-close-button')
|
|
.all()
|
|
for (const button of toastCloseButtons) {
|
|
await expect(button).toBeVisible()
|
|
await button.click()
|
|
}
|
|
|
|
// Assert all toasts are closed
|
|
await expect(this.visibleToasts).toHaveCount(0, { timeout: 1000 })
|
|
}
|
|
}
|