mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-12 00:42:03 +00:00
## Summary Add 5 Playwright E2E tests covering topbar menu command interactions. ## Changes - **What**: New test file `browser_tests/tests/topbarMenuCommands.spec.ts` with 5 tests: - New command creates a new workflow tab - Edit > Undo undoes the last action - Edit > Redo restores an undone action - File > Save opens save dialog - View > Bottom Panel toggles bottom panel visibility ## Review Focus Tests use `triggerTopbarCommand()` for menu navigation and `expect.poll()` for async assertions. The "New" command is a top-level menu item (path `["New"]`), not nested under File. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11208-test-add-E2E-tests-for-topbar-menu-commands-3416d73d36508143afe5e67a98910f56) by [Unito](https://www.unito.io)
82 lines
2.6 KiB
TypeScript
82 lines
2.6 KiB
TypeScript
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Topbar menu commands', { tag: '@ui' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.Workflow.WorkflowTabsPosition',
|
|
'Topbar'
|
|
)
|
|
await comfyPage.setup()
|
|
})
|
|
|
|
test('New command creates a new workflow tab', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
|
|
await topbar.triggerTopbarCommand(['New'])
|
|
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
})
|
|
|
|
test('Edit > Undo undoes the last action', 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.menu.topbar.triggerTopbarCommand(['Edit', 'Undo'])
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount)
|
|
})
|
|
|
|
test('Edit > Redo restores an undone action', 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.menu.topbar.triggerTopbarCommand(['Edit', 'Undo'])
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount)
|
|
|
|
await comfyPage.menu.topbar.triggerTopbarCommand(['Edit', 'Redo'])
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeCount())
|
|
.toBe(initialNodeCount + 1)
|
|
})
|
|
|
|
test('File > Save opens save dialog', async ({ comfyPage }) => {
|
|
await comfyPage.menu.topbar.triggerTopbarCommand(['File', 'Save'])
|
|
|
|
const saveDialog = comfyPage.menu.topbar.getSaveDialog()
|
|
await expect(saveDialog).toBeVisible()
|
|
})
|
|
|
|
test('View > Bottom Panel toggles bottom panel', async ({ comfyPage }) => {
|
|
await expect(comfyPage.bottomPanel.root).toBeHidden()
|
|
|
|
await comfyPage.menu.topbar.triggerTopbarCommand(['View', 'Bottom Panel'])
|
|
await expect(comfyPage.bottomPanel.root).toBeVisible()
|
|
|
|
await comfyPage.menu.topbar.triggerTopbarCommand(['View', 'Bottom Panel'])
|
|
await expect(comfyPage.bottomPanel.root).toBeHidden()
|
|
})
|
|
})
|