mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 22:58:08 +00:00
## Summary Add Playwright E2E tests covering core keyboard shortcut actions. ## Changes - **What**: 7 new E2E tests in `browser_tests/tests/keyboardShortcutActions.spec.ts` covering: - Ctrl+Z undoes the last graph change - Ctrl+Shift+Z redoes after undo - Ctrl+S opens save dialog - Ctrl+, opens settings dialog - Escape closes settings dialog - Delete key removes selected nodes - Ctrl+A selects all nodes ## Review Focus - Tests use `expect.poll()` for async graph state assertions - `@keyboard` tag for selective test runs - Uses `comfyPage.nodeOps` and `comfyPage.menu.topbar` helpers ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11210-test-add-E2E-tests-for-keyboard-shortcut-actions-3416d73d3650812eafd5e789cf8463a6) by [Unito](https://www.unito.io)
114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Keyboard shortcut actions', { tag: '@keyboard' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.Workflow.WorkflowTabsPosition',
|
|
'Topbar'
|
|
)
|
|
await comfyPage.setup()
|
|
})
|
|
|
|
test('Ctrl+Z undoes the last graph change', async ({ comfyPage }) => {
|
|
const initialNodeCount = await comfyPage.nodeOps.getNodeCount()
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const node = window.LiteGraph!.createNode('Note')
|
|
window.app!.graph!.add(node)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount + 1)
|
|
|
|
await comfyPage.canvas.click()
|
|
await comfyPage.page.keyboard.press('ControlOrMeta+z')
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount)
|
|
})
|
|
|
|
test('Ctrl+Shift+Z redoes after undo', async ({ comfyPage }) => {
|
|
const initialNodeCount = await comfyPage.nodeOps.getNodeCount()
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const node = window.LiteGraph!.createNode('Note')
|
|
window.app!.graph!.add(node)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.canvas.click()
|
|
await comfyPage.page.keyboard.press('ControlOrMeta+z')
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount)
|
|
|
|
await comfyPage.page.keyboard.press('ControlOrMeta+Shift+z')
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount + 1)
|
|
})
|
|
|
|
test('Ctrl+S opens save dialog', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click()
|
|
await comfyPage.page.keyboard.press('ControlOrMeta+s')
|
|
|
|
const saveDialog = comfyPage.menu.topbar.getSaveDialog()
|
|
await expect(saveDialog).toBeVisible()
|
|
})
|
|
|
|
test('Ctrl+, opens settings dialog', async ({ comfyPage }) => {
|
|
await comfyPage.page.keyboard.down('ControlOrMeta')
|
|
await comfyPage.page.keyboard.press(',')
|
|
await comfyPage.page.keyboard.up('ControlOrMeta')
|
|
|
|
const settingsDialog = comfyPage.page.getByTestId('settings-dialog')
|
|
await expect(settingsDialog).toBeVisible()
|
|
})
|
|
|
|
test('Escape closes settings dialog', async ({ comfyPage }) => {
|
|
await comfyPage.page.keyboard.down('ControlOrMeta')
|
|
await comfyPage.page.keyboard.press(',')
|
|
await comfyPage.page.keyboard.up('ControlOrMeta')
|
|
|
|
const settingsDialog = comfyPage.page.getByTestId('settings-dialog')
|
|
await expect(settingsDialog).toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Escape')
|
|
await expect(settingsDialog).toBeHidden()
|
|
})
|
|
|
|
test('Delete key removes selected nodes', async ({ comfyPage }) => {
|
|
const initialNodeCount = await comfyPage.nodeOps.getNodeCount()
|
|
expect(initialNodeCount, 'Default graph should have nodes').toBeGreaterThan(
|
|
0
|
|
)
|
|
|
|
await comfyPage.nodeOps.selectNodes(['KSampler'])
|
|
await comfyPage.page.keyboard.press('Delete')
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBeLessThan(initialNodeCount)
|
|
})
|
|
|
|
test('Ctrl+A selects all nodes', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click()
|
|
await comfyPage.page.keyboard.press('ControlOrMeta+a')
|
|
|
|
const totalNodes = await comfyPage.nodeOps.getNodeCount()
|
|
const selectedNodes = await comfyPage.page.evaluate(() =>
|
|
window.app!.canvas?.selected_nodes
|
|
? Object.keys(window.app!.canvas.selected_nodes).length
|
|
: 0
|
|
)
|
|
|
|
expect(selectedNodes).toBe(totalNodes)
|
|
})
|
|
})
|