mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +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>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
|
|
test.describe(
|
|
'Mobile Baseline Snapshots',
|
|
{ tag: ['@mobile', '@screenshot'] },
|
|
() => {
|
|
test('@mobile empty canvas', async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.ConfirmClear', false)
|
|
await comfyPage.command.executeCommand('Comfy.ClearWorkflow')
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0)
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.canvas,
|
|
'mobile-empty-canvas.png'
|
|
)
|
|
})
|
|
|
|
test('@mobile default workflow', async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'mobile-default-workflow.png'
|
|
)
|
|
})
|
|
|
|
test('@mobile graph canvas toolbar visible', async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.Graph.CanvasMenu', true)
|
|
|
|
const minimapButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.toggleMinimapButton
|
|
)
|
|
await expect(minimapButton).toBeVisible()
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'mobile-graph-canvas-toolbar.png'
|
|
)
|
|
})
|
|
|
|
test('@mobile settings dialog', async ({ comfyPage }) => {
|
|
await comfyPage.settingDialog.open()
|
|
await comfyPage.expectScreenshot(
|
|
comfyPage.settingDialog.root,
|
|
'mobile-settings-dialog.png',
|
|
{
|
|
mask: [
|
|
comfyPage.settingDialog.root.getByTestId(
|
|
TestIds.user.currentUserIndicator
|
|
)
|
|
]
|
|
}
|
|
)
|
|
})
|
|
}
|
|
)
|