mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-26 09:44:06 +00:00
Amp-Thread-ID: https://ampcode.com/threads/T-019bb3bd-f607-735a-b1a8-fce5fe4f0125 Co-authored-by: Amp <amp@ampcode.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Keybindings', () => {
|
|
test('Should execute command', async ({ comfyPage }) => {
|
|
await comfyPage.registerCommand('TestCommand', () => {
|
|
window.foo = true
|
|
})
|
|
|
|
await comfyPage.executeCommand('TestCommand')
|
|
expect(await comfyPage.page.evaluate(() => window.foo)).toBe(true)
|
|
})
|
|
|
|
test('Should execute async command', async ({ comfyPage }) => {
|
|
await comfyPage.registerCommand('TestCommand', async () => {
|
|
await new Promise<void>((resolve) =>
|
|
setTimeout(() => {
|
|
window.foo = true
|
|
resolve()
|
|
}, 5)
|
|
)
|
|
})
|
|
|
|
await comfyPage.executeCommand('TestCommand')
|
|
expect(await comfyPage.page.evaluate(() => window.foo)).toBe(true)
|
|
})
|
|
|
|
test('Should handle command errors', async ({ comfyPage }) => {
|
|
await comfyPage.registerCommand('TestCommand', () => {
|
|
throw new Error('Test error')
|
|
})
|
|
|
|
await comfyPage.executeCommand('TestCommand')
|
|
expect(await comfyPage.getToastErrorCount()).toBe(1)
|
|
})
|
|
|
|
test('Should handle async command errors', async ({ comfyPage }) => {
|
|
await comfyPage.registerCommand('TestCommand', async () => {
|
|
await new Promise<void>((_resolve, reject) =>
|
|
setTimeout(() => {
|
|
reject(new Error('Test error'))
|
|
}, 5)
|
|
)
|
|
})
|
|
|
|
await comfyPage.executeCommand('TestCommand')
|
|
expect(await comfyPage.getToastErrorCount()).toBe(1)
|
|
})
|
|
})
|