mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +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>
63 lines
2.4 KiB
TypeScript
63 lines
2.4 KiB
TypeScript
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
import type { WorkspaceStore } from '@e2e/types/globals'
|
|
|
|
test.describe(
|
|
'Change Tracker - isLoadingGraph guard',
|
|
{ tag: '@workflow' },
|
|
() => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.workflow.setupWorkflowsDirectory({})
|
|
})
|
|
|
|
test('Prevents checkState from corrupting workflow state during tab switch', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Tab 0: default workflow (7 nodes)
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(7)
|
|
|
|
// Save tab 0 so it has a unique name for tab switching
|
|
await comfyPage.menu.topbar.saveWorkflow('workflow-a')
|
|
|
|
// Register an extension that forces checkState during graph loading.
|
|
// This simulates the bug scenario where a user clicks during graph loading
|
|
// which triggers a checkState call on the wrong graph, corrupting the activeState.
|
|
await comfyPage.page.evaluate(() => {
|
|
window.app!.registerExtension({
|
|
name: 'TestCheckStateDuringLoad',
|
|
afterConfigureGraph() {
|
|
const workflow = (window.app!.extensionManager as WorkspaceStore)
|
|
.workflow.activeWorkflow
|
|
if (!workflow) throw new Error('No workflow found')
|
|
// Bypass the guard to reproduce the corruption bug:
|
|
// ; (workflow.changeTracker.constructor as unknown as { isLoadingGraph: boolean }).isLoadingGraph = false
|
|
|
|
// Simulate the user clicking during graph loading
|
|
workflow.changeTracker.checkState()
|
|
}
|
|
})
|
|
})
|
|
|
|
// Create tab 1: blank workflow (0 nodes)
|
|
await comfyPage.menu.topbar.triggerTopbarCommand(['New'])
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0)
|
|
|
|
// Switch back to tab 0 (workflow-a).
|
|
const tab0 = comfyPage.menu.topbar.getWorkflowTab('workflow-a')
|
|
await tab0.click()
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(7)
|
|
|
|
// switch to blank tab and back to verify no corruption
|
|
const tab1 = comfyPage.menu.topbar.getWorkflowTab('Unsaved Workflow')
|
|
await tab1.click()
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0)
|
|
|
|
// switch again and verify no corruption
|
|
await tab0.click()
|
|
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(7)
|
|
})
|
|
}
|
|
)
|