mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
## Summary
Harden 98 E2E spec files and 8 fixtures/helpers for deterministic CI
runs by replacing race-prone patterns with retry-safe alternatives.
No source code changes -- only `browser_tests/` is touched.
## Changes
- **E2E spec hardening** (98 spec files, 6 fixtures, 2 helpers):
| Fix class | Sites | Examples |
|-----------|-------|---------:|
| `expect(await ...)` -> `expect.poll()` | ~153 | interaction,
defaultKeybindings, workflows, featureFlags |
| `const x = await loc.count(); expect(x)` -> `toHaveCount()` | ~19 |
menu, linkInteraction, assets, bottomPanelShortcuts |
| `nextFrame()` -> `waitForHidden()` after menu clicks | ~22 |
contextMenu, rightClickMenu, subgraphHelper |
| Redundant `nextFrame()` removed | many | defaultKeybindings, minimap,
builderSaveFlow |
| `expect(async () => { ... }).toPass()` retry blocks | 5 | interaction
(graphdialog dismiss guard) |
| `force:true` removed from `BaseDialog.close()` | 1 | BaseDialog
fixture |
| ContextMenu `waitForHidden` simplified (check-then-act race removed) |
1 | ContextMenu fixture |
| Non-deterministic node order -> proximity-based selection | 1 |
interaction (toggle dom widget) |
| Tight poll timeout (250ms) -> >=2000ms | 2 | templates |
- **Helper improvements**: Exposed locator getters on
`ComfyPage.domWidgets`, `ToastHelper.toastErrors`, and
`WorkflowsSidebarTab.activeWorkflowLabel` so callers can use retrying
assertions (`toHaveCount()`, `toHaveText()`) directly.
- **Flake pattern catalog**: Added section 7 table to
`browser_tests/FLAKE_PREVENTION_RULES.md` documenting 8 pattern classes
for reviewers and future authors.
- **Docs**: Fixed bad examples in `browser_tests/README.md` to use
`expect.poll()`.
- **Breaking**: None
- **Dependencies**: None
## Review Focus
- All fixes follow the rules in
`browser_tests/FLAKE_PREVENTION_RULES.md`
- No behavioral changes to tests -- only timing/retry strategy is
updated
- The `ContextMenu.waitForHidden` simplification removes a
swallowed-error anti-pattern; both locators now use direct `waitFor({
state: 'hidden' })`
---------
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: github-actions <github-actions@github.com>
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe(
|
|
'Image paste priority over stale node metadata',
|
|
{ tag: ['@node'] },
|
|
() => {
|
|
test('Should not paste copied node when a LoadImage node is selected and clipboard has stale node metadata', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('nodes/load_image_with_ksampler')
|
|
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(2)
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
// Copy the KSampler node (puts data-metadata in clipboard)
|
|
const ksamplerNodes =
|
|
await comfyPage.nodeOps.getNodeRefsByType('KSampler')
|
|
await ksamplerNodes[0].copy()
|
|
|
|
// Select the LoadImage node
|
|
const loadImageNodes =
|
|
await comfyPage.nodeOps.getNodeRefsByType('LoadImage')
|
|
await loadImageNodes[0].click('title')
|
|
|
|
// Simulate pasting when clipboard has stale node metadata (text/html
|
|
// with data-metadata) but no image file items. This replicates the bug
|
|
// scenario: user copied a node, then copied a web image (which replaces
|
|
// clipboard files but may leave stale text/html with node metadata).
|
|
await comfyPage.page.evaluate(() => {
|
|
const nodeData = { nodes: [{ type: 'KSampler', id: 99 }] }
|
|
const base64 = btoa(JSON.stringify(nodeData))
|
|
const html =
|
|
'<meta charset="utf-8"><div><span data-metadata="' +
|
|
base64 +
|
|
'"></span></div><span style="white-space:pre-wrap;">Text</span>'
|
|
|
|
const dataTransfer = new DataTransfer()
|
|
dataTransfer.setData('text/html', html)
|
|
|
|
const event = new ClipboardEvent('paste', {
|
|
clipboardData: dataTransfer,
|
|
bubbles: true,
|
|
cancelable: true
|
|
})
|
|
document.dispatchEvent(event)
|
|
})
|
|
|
|
await comfyPage.nextFrame()
|
|
|
|
// Node count should remain the same — stale node metadata should NOT
|
|
// be deserialized when a media node is selected.
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount)
|
|
})
|
|
}
|
|
)
|