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>
149 lines
4.8 KiB
TypeScript
149 lines
4.8 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Sidebar splitter width independence', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting('Comfy.Sidebar.UnifiedWidth', true)
|
|
await comfyPage.settings.setSetting('Comfy.NodeLibrary.NewDesign', false)
|
|
})
|
|
|
|
async function dismissToasts(comfyPage: ComfyPage) {
|
|
const buttons = await comfyPage.page.locator('.p-toast-close-button').all()
|
|
for (const btn of buttons) {
|
|
await btn.click({ timeout: 2000 }).catch(() => {})
|
|
}
|
|
// Brief wait for animations
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
async function dragGutter(comfyPage: ComfyPage, deltaX: number) {
|
|
const gutter = comfyPage.page
|
|
.locator('.p-splitter-gutter:not(.hidden)')
|
|
.first()
|
|
await expect(gutter).toBeVisible()
|
|
await expect.poll(() => gutter.boundingBox()).not.toBeNull()
|
|
const box = (await gutter.boundingBox())!
|
|
const centerX = box.x + box.width / 2
|
|
const centerY = box.y + box.height / 2
|
|
await comfyPage.page.mouse.move(centerX, centerY)
|
|
await comfyPage.page.mouse.down()
|
|
await comfyPage.page.mouse.move(centerX + deltaX, centerY, { steps: 10 })
|
|
await comfyPage.page.mouse.up()
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
async function openSidebarAt(
|
|
comfyPage: ComfyPage,
|
|
location: 'left' | 'right'
|
|
) {
|
|
await comfyPage.settings.setSetting('Comfy.Sidebar.Location', location)
|
|
await comfyPage.nextFrame()
|
|
await dismissToasts(comfyPage)
|
|
await comfyPage.menu.nodeLibraryTab.open()
|
|
}
|
|
|
|
test('left and right sidebars use separate localStorage keys', async ({
|
|
comfyPage
|
|
}) => {
|
|
// Open sidebar on the left and resize it
|
|
await openSidebarAt(comfyPage, 'left')
|
|
await dragGutter(comfyPage, 100)
|
|
|
|
// Read the sidebar panel width after resize
|
|
const leftSidebar = comfyPage.page.locator('.side-bar-panel').first()
|
|
const leftWidth = (await leftSidebar.boundingBox())!.width
|
|
|
|
// Close sidebar, switch to right, open again
|
|
await comfyPage.menu.nodeLibraryTab.close()
|
|
await openSidebarAt(comfyPage, 'right')
|
|
|
|
// Right sidebar should use its default width, not the left's resized width
|
|
const rightSidebar = comfyPage.page.locator('.side-bar-panel').first()
|
|
await expect(rightSidebar).toBeVisible()
|
|
|
|
// The right sidebar should NOT match the left's resized width.
|
|
// We dragged the left sidebar 100px wider, so there should be a noticeable
|
|
// difference between the left (resized) and right (default) widths.
|
|
await expect
|
|
.poll(async () => {
|
|
const b = await rightSidebar.boundingBox()
|
|
return b ? Math.abs(b.width - leftWidth) : -1
|
|
})
|
|
.toBeGreaterThan(50)
|
|
})
|
|
|
|
test('localStorage keys include sidebar location', async ({ comfyPage }) => {
|
|
// Open sidebar on the left and resize
|
|
await openSidebarAt(comfyPage, 'left')
|
|
await dragGutter(comfyPage, 50)
|
|
|
|
// Left-only sidebar should use the legacy key (no location suffix)
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() => localStorage.getItem('unified-sidebar'))
|
|
)
|
|
.not.toBeNull()
|
|
|
|
// Switch to right and resize
|
|
await comfyPage.menu.nodeLibraryTab.close()
|
|
await openSidebarAt(comfyPage, 'right')
|
|
await dragGutter(comfyPage, -50)
|
|
|
|
// Right sidebar should use a different key with location suffix
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() =>
|
|
localStorage.getItem('unified-sidebar-right')
|
|
)
|
|
)
|
|
.not.toBeNull()
|
|
|
|
// Both keys should exist independently
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() => localStorage.getItem('unified-sidebar'))
|
|
)
|
|
.not.toBeNull()
|
|
})
|
|
|
|
test('normalized panel sizes sum to approximately 100%', async ({
|
|
comfyPage
|
|
}) => {
|
|
await openSidebarAt(comfyPage, 'left')
|
|
await dragGutter(comfyPage, 80)
|
|
|
|
// Check that saved sizes sum to ~100%
|
|
const getSidebarSizes = () =>
|
|
comfyPage.page.evaluate(() => {
|
|
const raw = localStorage.getItem('unified-sidebar')
|
|
return raw ? (JSON.parse(raw) as number[]) : null
|
|
})
|
|
|
|
await expect
|
|
.poll(async () => {
|
|
const sizes = await getSidebarSizes()
|
|
return Array.isArray(sizes)
|
|
})
|
|
.toBe(true)
|
|
|
|
await expect
|
|
.poll(async () => {
|
|
const sizes = await getSidebarSizes()
|
|
if (!sizes) return 0
|
|
return sizes.reduce((a, b) => a + b, 0)
|
|
})
|
|
.toBeGreaterThan(99)
|
|
|
|
await expect
|
|
.poll(async () => {
|
|
const sizes = await getSidebarSizes()
|
|
if (!sizes) return Infinity
|
|
return sizes.reduce((a, b) => a + b, 0)
|
|
})
|
|
.toBeLessThanOrEqual(101)
|
|
})
|
|
})
|