mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +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>
129 lines
4.1 KiB
TypeScript
129 lines
4.1 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Node library sidebar V2', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting('Comfy.NodeLibrary.NewDesign', true)
|
|
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
await tab.open()
|
|
})
|
|
|
|
test('Can switch between tabs', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
|
|
await tab.blueprintsTab.click()
|
|
await expect(tab.blueprintsTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'false')
|
|
|
|
await tab.allTab.click()
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.blueprintsTab).toHaveAttribute('aria-selected', 'false')
|
|
})
|
|
|
|
test('All tab displays node tree with folders', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.getFolder('sampling')).toBeVisible()
|
|
})
|
|
|
|
test('Can expand folder and see nodes in All tab', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible()
|
|
})
|
|
|
|
test('Search filters nodes in All tab', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.getNode('KSampler (Advanced)')).not.toBeVisible()
|
|
|
|
await tab.searchInput.fill('KSampler')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible({
|
|
timeout: 5000
|
|
})
|
|
await expect(tab.getNode('CLIPLoader')).not.toBeVisible()
|
|
})
|
|
|
|
test('Drag node to canvas adds it', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible()
|
|
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
await expect
|
|
.poll(
|
|
async () => await comfyPage.page.locator('#graph-canvas').boundingBox()
|
|
)
|
|
.toBeTruthy()
|
|
const canvasBoundingBox = (await comfyPage.page
|
|
.locator('#graph-canvas')
|
|
.boundingBox())!
|
|
const targetPosition = {
|
|
x: canvasBoundingBox.x + canvasBoundingBox.width / 2,
|
|
y: canvasBoundingBox.y + canvasBoundingBox.height / 2
|
|
}
|
|
|
|
const nodeLocator = tab.getNode('KSampler (Advanced)')
|
|
await nodeLocator.dragTo(comfyPage.page.locator('#graph-canvas'), {
|
|
targetPosition
|
|
})
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount + 1)
|
|
})
|
|
|
|
test('Right-click node shows context menu with bookmark option', async ({
|
|
comfyPage
|
|
}) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
const node = tab.getNode('KSampler (Advanced)')
|
|
await expect(node).toBeVisible()
|
|
|
|
await node.click({ button: 'right' })
|
|
|
|
const contextMenu = comfyPage.page.getByRole('menuitem', {
|
|
name: /Bookmark Node/
|
|
})
|
|
await expect(contextMenu).toBeVisible({ timeout: 3000 })
|
|
})
|
|
|
|
test('Search clear restores folder view', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.getFolder('sampling')).toBeVisible()
|
|
|
|
await tab.searchInput.fill('KSampler')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible({
|
|
timeout: 5000
|
|
})
|
|
|
|
await tab.searchInput.clear()
|
|
await tab.searchInput.press('Enter')
|
|
|
|
await expect(tab.getFolder('sampling')).toBeVisible({ timeout: 5000 })
|
|
})
|
|
|
|
test('Sort dropdown shows sorting options', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.sortButton.click()
|
|
|
|
// Reka UI DropdownMenuRadioItem renders with role="menuitemradio"
|
|
const options = comfyPage.page.getByRole('menuitemradio')
|
|
await expect(options.first()).toBeVisible({ timeout: 3000 })
|
|
await expect.poll(() => options.count()).toBeGreaterThanOrEqual(2)
|
|
})
|
|
})
|