mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-10 18:10:08 +00:00
Phase 1 of ComfyPage refactor - extract method groups into helpers: - New ToastHelper: toast error/visibility/close methods - New DragDropHelper: file and URL drag-and-drop methods - New CommandHelper: command execution and registration - Extended WorkflowHelper: undo/redo queue, modified state, export - Extended CanvasHelper: group position/drag, edge connect/disconnect - Extended NodeOperationsHelper: prompt dialog, node drag, widget adjust Amp-Thread-ID: https://ampcode.com/threads/T-019c165a-5aba-7582-9f2b-e5b2bba2783b Co-authored-by: Amp <amp@ampcode.com>
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
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 button.click()
|
|
}
|
|
|
|
// Wait for toasts to disappear
|
|
await this.visibleToasts
|
|
.first()
|
|
.waitFor({ state: 'hidden', timeout: 1000 })
|
|
.catch(() => {})
|
|
}
|
|
}
|