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>
144 lines
4.3 KiB
TypeScript
144 lines
4.3 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyApp } from '@/scripts/app'
|
|
import { NodeBadgeMode } from '@/types/nodeSource'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Node Badge', { tag: ['@screenshot', '@smoke', '@node'] }, () => {
|
|
test('Can add badge', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge.png')
|
|
})
|
|
|
|
test('Can add multiple badges', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [
|
|
new LGraphBadge({ text: 'Test Badge 1' }),
|
|
new LGraphBadge({ text: 'Test Badge 2' })
|
|
]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-multiple.png')
|
|
})
|
|
|
|
test('Can add badge left-side', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
// @ts-expect-error - Enum value
|
|
node.badgePosition = 'top-left'
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-left.png')
|
|
})
|
|
})
|
|
|
|
test.describe(
|
|
'Node source badge',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
Object.values(NodeBadgeMode).forEach(async (mode) => {
|
|
test(`Shows node badges (${mode})`, async ({ comfyPage }) => {
|
|
// Execution error workflow has both custom node and core node.
|
|
await comfyPage.workflow.loadWorkflow('nodes/execution_error')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeSourceBadgeMode',
|
|
mode
|
|
)
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
mode
|
|
)
|
|
await expect
|
|
.poll(
|
|
() =>
|
|
comfyPage.settings.getSetting('Comfy.NodeBadge.NodeIdBadgeMode'),
|
|
{ message: 'NodeIdBadgeMode setting should be applied' }
|
|
)
|
|
.toBe(mode)
|
|
await comfyPage.canvasOps.resetView()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
`node-badge-${mode}.png`
|
|
)
|
|
})
|
|
})
|
|
}
|
|
)
|
|
|
|
test.describe(
|
|
'Node badge color',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
test('Can show node badge with unknown color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'unknown')
|
|
await expect
|
|
.poll(() => comfyPage.settings.getSetting('Comfy.ColorPalette'), {
|
|
message: 'ColorPalette setting should be applied'
|
|
})
|
|
.toBe('unknown')
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-unknown-color-palette.png'
|
|
)
|
|
})
|
|
|
|
test('Can show node badge with light color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'light')
|
|
await expect
|
|
.poll(() => comfyPage.settings.getSetting('Comfy.ColorPalette'), {
|
|
message: 'ColorPalette setting should be applied'
|
|
})
|
|
.toBe('light')
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-light-color-palette.png'
|
|
)
|
|
})
|
|
}
|
|
)
|