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>
152 lines
5.0 KiB
TypeScript
152 lines
5.0 KiB
TypeScript
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Node search box V2', { tag: '@node' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
await comfyPage.settings.setSetting('Comfy.NodeSearchBoxImpl', 'default')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.LinkRelease.Action',
|
|
'search box'
|
|
)
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.LinkRelease.ActionShift',
|
|
'search box'
|
|
)
|
|
await comfyPage.searchBoxV2.reload(comfyPage)
|
|
})
|
|
|
|
test('Can open search and add node', async ({ comfyPage }) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
await searchBoxV2.input.fill('KSampler')
|
|
await expect(searchBoxV2.results.first()).toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
await expect(searchBoxV2.input).not.toBeVisible()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount + 1)
|
|
})
|
|
|
|
test('Can add first default result with Enter', async ({ comfyPage }) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
// Default results should be visible without typing
|
|
await expect(searchBoxV2.results.first()).toBeVisible()
|
|
|
|
// Enter should add the first (selected) result
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
await expect(searchBoxV2.input).not.toBeVisible()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount + 1)
|
|
})
|
|
|
|
test.describe('Category navigation', () => {
|
|
test('Favorites shows only bookmarked nodes', async ({ comfyPage }) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
await comfyPage.settings.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [
|
|
'KSampler'
|
|
])
|
|
await searchBoxV2.reload(comfyPage)
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
await searchBoxV2.categoryButton('favorites').click()
|
|
|
|
await expect(searchBoxV2.results).toHaveCount(1)
|
|
await expect(searchBoxV2.results.first()).toContainText('KSampler')
|
|
})
|
|
|
|
test('Category filters results to matching nodes', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
await searchBoxV2.categoryButton('sampling').click()
|
|
|
|
await expect(searchBoxV2.results.first()).toBeVisible()
|
|
await expect.poll(() => searchBoxV2.results.count()).toBeGreaterThan(0)
|
|
})
|
|
})
|
|
|
|
test.describe('Filter workflow', () => {
|
|
test('Can filter by input type via filter bar', async ({ comfyPage }) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
// Click "Input" filter chip in the filter bar
|
|
await searchBoxV2.filterBarButton('Input').click()
|
|
|
|
// Filter options should appear
|
|
await expect(searchBoxV2.filterOptions.first()).toBeVisible()
|
|
|
|
// Type to narrow and select MODEL
|
|
await searchBoxV2.input.fill('MODEL')
|
|
await searchBoxV2.filterOptions
|
|
.filter({ hasText: 'MODEL' })
|
|
.first()
|
|
.click()
|
|
|
|
// Filter chip should appear and results should be filtered
|
|
await expect(
|
|
searchBoxV2.dialog.getByText('Input:', { exact: false }).locator('..')
|
|
).toContainText('MODEL')
|
|
await expect(searchBoxV2.results.first()).toBeVisible()
|
|
})
|
|
})
|
|
|
|
test.describe('Keyboard navigation', () => {
|
|
test('Can navigate and select with keyboard', async ({ comfyPage }) => {
|
|
const { searchBoxV2 } = comfyPage
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
await comfyPage.canvasOps.doubleClick()
|
|
await expect(searchBoxV2.input).toBeVisible()
|
|
|
|
await searchBoxV2.input.fill('KSampler')
|
|
const results = searchBoxV2.results
|
|
await expect(results.first()).toBeVisible()
|
|
|
|
// First result selected by default
|
|
await expect(results.first()).toHaveAttribute('aria-selected', 'true')
|
|
|
|
// ArrowDown moves selection
|
|
await comfyPage.page.keyboard.press('ArrowDown')
|
|
await expect(results.nth(1)).toHaveAttribute('aria-selected', 'true')
|
|
await expect(results.first()).toHaveAttribute('aria-selected', 'false')
|
|
|
|
// ArrowUp moves back
|
|
await comfyPage.page.keyboard.press('ArrowUp')
|
|
await expect(results.first()).toHaveAttribute('aria-selected', 'true')
|
|
|
|
// Enter selects and adds node
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
await expect(searchBoxV2.input).not.toBeVisible()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount + 1)
|
|
})
|
|
})
|
|
})
|