mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary
Internalize `nextFrame()` calls into fixture/helper methods so spec
authors don't need to remember to call it after common operations.
`nextFrame()` waits for one `requestAnimationFrame` (~16ms) — an extra
call is always safe, making this a low-risk refactor.
## Changes
### Phase 1: `SettingsHelper.setSetting()`
`setSetting()` now calls `nextFrame()` internally. Removed 15 redundant
calls across 7 files.
### Phase 2: `CommandHelper.executeCommand()`
`executeCommand()` now calls `nextFrame()` internally. Removed 15
redundant calls across 7 files, including the now-redundant call in
`AppModeHelper.toggleAppMode()`.
### Phase 3: `WorkflowHelper.loadGraphData()`
New helper wraps `page.evaluate(loadGraphData)` + `nextFrame()`.
Migrated `SubgraphHelper.serializeAndReload()` and `groupNode.spec.ts`.
### Phase 4: `NodeReference` cleanup
Removed redundant `nextFrame()` from `copy()`, `convertToGroupNode()`,
`resizeNode()`, `dragTextEncodeNode2()`, and
`convertDefaultKSamplerToSubgraph()`. Removed 6 spec-level calls after
`node.click('title')`.
### Phase 5: `KeyboardHelper.press()` and `delete()`
New convenience methods that press a key and wait one frame. Converted
40 `canvas.press(key)` + `nextFrame()` pairs across 13 spec files.
### Phase 6: `ComfyPage.expectScreenshot()`
New helper combines `nextFrame()` + `toHaveScreenshot()`. Converted 45
pairs across 12 spec files.
## Total impact
- **~130 redundant `nextFrame()` calls eliminated** across ~35
spec/helper files
- **3 new helper methods** added (`loadGraphData`, `press`/`delete`,
`expectScreenshot`)
- **2 existing methods** enhanced (`setSetting`, `executeCommand`)
## What was NOT changed
- `performance.spec.ts` frame-counting loops (intentional)
- `ComfyMouse.ts` / `CanvasHelper.ts` (already internalized)
- `SubgraphHelper.packAllInteriorNodes()` (deliberate orchestration)
- Builder helpers (already internalized)
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-11166-refactor-internalize-nextFrame-into-fixture-helper-methods-33f6d73d3650817bb5f6fb46e396085e)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Amp <amp@ampcode.com>
244 lines
8.8 KiB
TypeScript
244 lines
8.8 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { NodeBadgeMode } from '@/types/nodeSource'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { DefaultGraphPositions } from '@e2e/fixtures/constants/defaultGraphPositions'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe(
|
|
'Canvas Right Click Menu',
|
|
{ tag: ['@screenshot', '@ui'] },
|
|
() => {
|
|
test('Can add node', async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.rightClick()
|
|
await expect(comfyPage.canvas).toHaveScreenshot('right-click-menu.png')
|
|
await comfyPage.page.getByText('Add Node').click()
|
|
await comfyPage.page.getByText('loaders').click()
|
|
await comfyPage.page.getByText('Load VAE').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'add-node-node-added.png'
|
|
)
|
|
})
|
|
|
|
test('Can add group', async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.rightClick()
|
|
await expect(comfyPage.canvas).toHaveScreenshot('right-click-menu.png')
|
|
await comfyPage.page.getByText('Add Group', { exact: true }).click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'add-group-group-added.png'
|
|
)
|
|
})
|
|
|
|
test('Can convert to group node', async ({ comfyPage }) => {
|
|
await comfyPage.nodeOps.selectNodes(['CLIP Text Encode (Prompt)'])
|
|
await expect(comfyPage.canvas).toHaveScreenshot('selected-2-nodes.png')
|
|
await comfyPage.canvasOps.rightClick()
|
|
await comfyPage.contextMenu.clickMenuItem(
|
|
'Convert to Group Node (Deprecated)'
|
|
)
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.nodeOps.promptDialogInput.fill('GroupNode2CLIP')
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
await comfyPage.nodeOps.promptDialogInput.waitFor({ state: 'hidden' })
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-node-group-node.png'
|
|
)
|
|
})
|
|
}
|
|
)
|
|
|
|
test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => {
|
|
test('Can open properties panel', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(comfyPage.canvas, 'right-click-node.png')
|
|
await comfyPage.page.getByText('Properties Panel').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-node-properties-panel.png'
|
|
)
|
|
})
|
|
|
|
test('Can collapse', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(comfyPage.canvas, 'right-click-node.png')
|
|
await comfyPage.page.getByText('Collapse').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-node-collapsed.png'
|
|
)
|
|
})
|
|
|
|
test('Can collapse (Node Badge)', async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeSourceBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.page.getByText('Collapse').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-node-collapsed-badge.png'
|
|
)
|
|
})
|
|
|
|
test('Can bypass', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(comfyPage.canvas, 'right-click-node.png')
|
|
await comfyPage.page.getByText('Bypass').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-node-bypassed.png'
|
|
)
|
|
})
|
|
|
|
test('Can pin and unpin', async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.Graph.AutoPanSpeed', 0)
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(comfyPage.canvas, 'right-click-node.png')
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Pin")').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.nextFrame()
|
|
|
|
// Get EmptyLatentImage node title position dynamically (for dragging)
|
|
const emptyLatentNode = await comfyPage.nodeOps.getNodeRefById(5)
|
|
const titlePos = await emptyLatentNode.getTitlePosition()
|
|
await comfyPage.canvasOps.dragAndDrop(titlePos, { x: 16, y: 16 })
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-pinned.png')
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-pinned-node.png'
|
|
)
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Unpin")').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'right-click-unpinned-node.png'
|
|
)
|
|
})
|
|
|
|
test('Can move after unpin', async ({ comfyPage }) => {
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Pin")').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Unpin")').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.nextFrame()
|
|
|
|
// Get EmptyLatentImage node title position dynamically (for dragging)
|
|
const emptyLatentNode = await comfyPage.nodeOps.getNodeRefById(5)
|
|
const titlePos = await emptyLatentNode.getTitlePosition()
|
|
await comfyPage.canvasOps.dragAndDrop(titlePos, { x: 200, y: 590 })
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'right-click-unpinned-node-moved.png'
|
|
)
|
|
})
|
|
|
|
test('Can pin/unpin selected nodes', async ({ comfyPage }) => {
|
|
await comfyPage.nodeOps.selectNodes(['CLIP Text Encode (Prompt)'])
|
|
await comfyPage.page.keyboard.down('Control')
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Pin")').click()
|
|
await comfyPage.page.keyboard.up('Control')
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'selected-nodes-pinned.png'
|
|
)
|
|
await comfyPage.canvas.click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick,
|
|
button: 'right'
|
|
})
|
|
await comfyPage.page.mouse.move(10, 10)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.page.locator('.litemenu-entry:has-text("Unpin")').click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'selected-nodes-unpinned.png'
|
|
)
|
|
})
|
|
|
|
test('Can clone pinned nodes', async ({ comfyPage }) => {
|
|
const nodeCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
const node = (await comfyPage.nodeOps.getFirstNodeRef())!
|
|
await node.clickContextMenuOption('Pin')
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await node.click('title', { button: 'right' })
|
|
await expect(
|
|
comfyPage.page.locator('.litemenu-entry:has-text("Unpin")')
|
|
).toBeAttached()
|
|
const cloneItem = comfyPage.page.locator(
|
|
'.litemenu-entry:has-text("Clone")'
|
|
)
|
|
await cloneItem.click()
|
|
await comfyPage.contextMenu.waitForHidden()
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(nodeCount + 1)
|
|
})
|
|
})
|