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>
141 lines
4.2 KiB
TypeScript
141 lines
4.2 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
|
|
test.describe('Zoom Controls', { tag: '@canvas' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.Graph.CanvasMenu', true)
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.page.waitForFunction(() => window.app && window.app.canvas)
|
|
})
|
|
|
|
test('Default zoom is 100% and node has a size', async ({ comfyPage }) => {
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(
|
|
() => window.app!.graph.nodes[0]?.size?.[0] ?? 0
|
|
)
|
|
)
|
|
.toBeGreaterThan(0)
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(
|
|
() => window.app!.graph.nodes[0]?.size?.[1] ?? 0
|
|
)
|
|
)
|
|
.toBeGreaterThan(0)
|
|
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await expect(zoomButton).toContainText('100%')
|
|
|
|
await expect.poll(() => comfyPage.canvasOps.getScale()).toBeCloseTo(1.0, 1)
|
|
})
|
|
|
|
test('Zoom to fit reduces percentage', async ({ comfyPage }) => {
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const zoomToFit = comfyPage.page.getByTestId(TestIds.canvas.zoomToFitAction)
|
|
await expect(zoomToFit).toBeVisible()
|
|
await zoomToFit.click()
|
|
|
|
await expect.poll(() => comfyPage.canvasOps.getScale()).toBeLessThan(1.0)
|
|
|
|
await expect(zoomButton).not.toContainText('100%')
|
|
})
|
|
|
|
test('Zoom out reduces percentage', async ({ comfyPage }) => {
|
|
const initialScale = await comfyPage.canvasOps.getScale()
|
|
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const zoomOut = comfyPage.page.getByTestId(TestIds.canvas.zoomOutAction)
|
|
await zoomOut.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.canvasOps.getScale())
|
|
.toBeLessThan(initialScale)
|
|
})
|
|
|
|
test('Zoom out clamps at 10% minimum', async ({ comfyPage }) => {
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const zoomOut = comfyPage.page.getByTestId(TestIds.canvas.zoomOutAction)
|
|
for (let i = 0; i < 30; i++) {
|
|
await zoomOut.click()
|
|
}
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => comfyPage.canvasOps.getScale()).toBeCloseTo(0.1, 1)
|
|
|
|
await expect(zoomButton).toContainText('10%')
|
|
})
|
|
|
|
test('Manual percentage entry allows zoom in and zoom out', async ({
|
|
comfyPage
|
|
}) => {
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const input = comfyPage.page
|
|
.getByTestId(TestIds.canvas.zoomPercentageInput)
|
|
.locator('input')
|
|
await input.fill('100')
|
|
await input.press('Enter')
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => comfyPage.canvasOps.getScale()).toBeCloseTo(1.0, 1)
|
|
|
|
const zoomIn = comfyPage.page.getByTestId(TestIds.canvas.zoomInAction)
|
|
await zoomIn.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => comfyPage.canvasOps.getScale()).toBeGreaterThan(1.0)
|
|
const scaleAfterZoomIn = await comfyPage.canvasOps.getScale()
|
|
|
|
const zoomOut = comfyPage.page.getByTestId(TestIds.canvas.zoomOutAction)
|
|
await zoomOut.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.canvasOps.getScale())
|
|
.toBeLessThan(scaleAfterZoomIn)
|
|
})
|
|
|
|
test('Clicking zoom button toggles zoom controls visibility', async ({
|
|
comfyPage
|
|
}) => {
|
|
const zoomButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.zoomControlsButton
|
|
)
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const zoomToFit = comfyPage.page.getByTestId(TestIds.canvas.zoomToFitAction)
|
|
await expect(zoomToFit).toBeVisible()
|
|
|
|
await zoomButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect(zoomToFit).not.toBeVisible()
|
|
})
|
|
})
|