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>
93 lines
3.0 KiB
TypeScript
93 lines
3.0 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe(
|
|
'Subgraph node positions after draft reload',
|
|
{ tag: ['@subgraph'] },
|
|
() => {
|
|
test('Node positions are preserved after draft reload with subgraph auto-entry', async ({
|
|
comfyPage
|
|
}) => {
|
|
test.setTimeout(30000)
|
|
|
|
// Enable workflow persistence explicitly
|
|
await comfyPage.settings.setSetting('Comfy.Workflow.Persist', true)
|
|
|
|
// Load a workflow containing a subgraph
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
|
|
// Enter the subgraph programmatically (fixture node is too small for UI click)
|
|
await comfyPage.page.evaluate(() => {
|
|
const sg = [...window.app!.rootGraph.subgraphs.values()][0]
|
|
if (sg) window.app!.canvas.setGraph(sg)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await expect.poll(() => comfyPage.subgraph.isInSubgraph()).toBe(true)
|
|
|
|
const positionsBefore = await comfyPage.page.evaluate(() => {
|
|
const sg = [...window.app!.rootGraph.subgraphs.values()][0]
|
|
return sg.nodes.map((n) => ({
|
|
id: n.id,
|
|
x: n.pos[0],
|
|
y: n.pos[1]
|
|
}))
|
|
})
|
|
|
|
await expect
|
|
.poll(async () => {
|
|
const positions = await comfyPage.page.evaluate(() => {
|
|
const sg = [...window.app!.rootGraph.subgraphs.values()][0]
|
|
return sg.nodes.map((n) => ({
|
|
id: n.id,
|
|
x: n.pos[0],
|
|
y: n.pos[1]
|
|
}))
|
|
})
|
|
return positions.length
|
|
})
|
|
.toBeGreaterThan(0)
|
|
|
|
// Wait for the debounced draft persistence to flush to localStorage
|
|
await comfyPage.workflow.waitForDraftPersisted()
|
|
|
|
// Reload the page (draft auto-loads with hash preserved)
|
|
await comfyPage.page.reload({ waitUntil: 'networkidle' })
|
|
await comfyPage.page.waitForFunction(
|
|
() => window.app && window.app.extensionManager
|
|
)
|
|
await comfyPage.page.waitForSelector('.p-blockui-mask', {
|
|
state: 'hidden'
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
// Wait for subgraph auto-entry via hash navigation
|
|
await expect
|
|
.poll(() => comfyPage.subgraph.isInSubgraph(), { timeout: 10000 })
|
|
.toBe(true)
|
|
|
|
// Verify all internal node positions are preserved
|
|
for (const before of positionsBefore) {
|
|
await expect
|
|
.poll(async () => {
|
|
const positionsNow = await comfyPage.page.evaluate(() => {
|
|
const sg = [...window.app!.rootGraph.subgraphs.values()][0]
|
|
return sg.nodes.map((n) => ({
|
|
id: n.id,
|
|
x: n.pos[0],
|
|
y: n.pos[1]
|
|
}))
|
|
})
|
|
const after = positionsNow.find((n) => n.id === before.id)
|
|
if (!after) return null
|
|
return { x: after.x, y: after.y }
|
|
})
|
|
.toMatchObject({
|
|
x: expect.closeTo(before.x, 0),
|
|
y: expect.closeTo(before.y, 0)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
)
|