mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +00:00
Phase 2 of ComfyPage refactor: - Add ToastHelper, DragDropHelper, CommandHelper instances to ComfyPage - Remove migrated methods from ComfyPage (command, toast, dragDrop, workflow, canvasOps, nodeOps methods) - Update all test files to use new helper paths - Keep visibleToasts as passthrough getter for backward compatibility Amp-Thread-ID: https://ampcode.com/threads/T-019c1666-ed27-773c-976a-07cc805d7a6c Co-authored-by: Amp <amp@ampcode.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Keybindings', { tag: '@keyboard' }, () => {
|
|
test('Should execute command', async ({ comfyPage }) => {
|
|
await comfyPage.command.registerCommand('TestCommand', () => {
|
|
window['foo'] = true
|
|
})
|
|
|
|
await comfyPage.command.executeCommand('TestCommand')
|
|
expect(await comfyPage.page.evaluate(() => window['foo'])).toBe(true)
|
|
})
|
|
|
|
test('Should execute async command', async ({ comfyPage }) => {
|
|
await comfyPage.command.registerCommand('TestCommand', async () => {
|
|
await new Promise<void>((resolve) =>
|
|
setTimeout(() => {
|
|
window['foo'] = true
|
|
resolve()
|
|
}, 5)
|
|
)
|
|
})
|
|
|
|
await comfyPage.command.executeCommand('TestCommand')
|
|
expect(await comfyPage.page.evaluate(() => window['foo'])).toBe(true)
|
|
})
|
|
|
|
test('Should handle command errors', async ({ comfyPage }) => {
|
|
await comfyPage.command.registerCommand('TestCommand', () => {
|
|
throw new Error('Test error')
|
|
})
|
|
|
|
await comfyPage.command.executeCommand('TestCommand')
|
|
expect(await comfyPage.toast.getToastErrorCount()).toBe(1)
|
|
})
|
|
|
|
test('Should handle async command errors', async ({ comfyPage }) => {
|
|
await comfyPage.command.registerCommand('TestCommand', async () => {
|
|
await new Promise<void>((resolve, reject) =>
|
|
setTimeout(() => {
|
|
reject(new Error('Test error'))
|
|
}, 5)
|
|
)
|
|
})
|
|
|
|
await comfyPage.command.executeCommand('TestCommand')
|
|
expect(await comfyPage.toast.getToastErrorCount()).toBe(1)
|
|
})
|
|
})
|