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>
151 lines
4.7 KiB
TypeScript
151 lines
4.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Workflow tabs', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.Workflow.WorkflowTabsPosition',
|
|
'Topbar'
|
|
)
|
|
await comfyPage.setup()
|
|
})
|
|
|
|
test('Default workflow tab is visible on load', async ({ comfyPage }) => {
|
|
await expect
|
|
.poll(() => comfyPage.menu.topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Creating a new workflow adds a tab', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual(
|
|
expect.arrayContaining([
|
|
expect.stringContaining('Unsaved Workflow (2)')
|
|
])
|
|
)
|
|
})
|
|
|
|
test('Switching tabs changes active workflow', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await expect(topbar.getActiveTab()).toContainText('Unsaved Workflow (2)')
|
|
|
|
await topbar.getTab(0).click()
|
|
await expect(topbar.getActiveTab()).toContainText('Unsaved Workflow')
|
|
await expect(topbar.getActiveTab()).not.toContainText('(2)')
|
|
})
|
|
|
|
test('Closing a tab removes it', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await topbar.closeWorkflowTab('Unsaved Workflow (2)')
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Right-clicking a tab shows context menu', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.getTab(0).click({ button: 'right' })
|
|
|
|
// Reka UI ContextMenuContent gets data-state="open" when active
|
|
const contextMenu = comfyPage.page.locator(
|
|
'[role="menu"][data-state="open"]'
|
|
)
|
|
await expect(contextMenu).toBeVisible({ timeout: 5000 })
|
|
|
|
await expect(
|
|
contextMenu.getByRole('menuitem', { name: /Close Tab/i }).first()
|
|
).toBeVisible()
|
|
await expect(
|
|
contextMenu.getByRole('menuitem', { name: /Save/i }).first()
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('Context menu Close Tab action removes the tab', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await topbar.getTab(1).click({ button: 'right' })
|
|
const contextMenu = comfyPage.page.locator(
|
|
'[role="menu"][data-state="open"]'
|
|
)
|
|
await expect(contextMenu).toBeVisible({ timeout: 5000 })
|
|
|
|
await contextMenu
|
|
.getByRole('menuitem', { name: /Close Tab/i })
|
|
.first()
|
|
.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
})
|
|
|
|
test('Closing the last tab creates a new default workflow', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
|
|
await topbar.closeWorkflowTab('Unsaved Workflow')
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Modified workflow shows unsaved indicator', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
// Modify the graph via litegraph API to trigger unsaved state
|
|
await comfyPage.page.evaluate(() => {
|
|
const graph = window.app?.graph
|
|
const node = window.LiteGraph?.createNode('Note')
|
|
if (graph && node) graph.add(node)
|
|
})
|
|
|
|
// WorkflowTab renders "•" when the workflow has unsaved changes
|
|
const activeTab = topbar.getActiveTab()
|
|
await expect(activeTab.locator('text=•')).toBeVisible({ timeout: 5000 })
|
|
})
|
|
|
|
test('Multiple tabs can be created, switched, and closed', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
// Create 2 additional tabs (3 total)
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(3)
|
|
|
|
// Switch to first tab
|
|
await topbar.getTab(0).click()
|
|
await expect
|
|
.poll(() => topbar.getActiveTabName())
|
|
.toContain('Unsaved Workflow')
|
|
|
|
// Close the middle tab
|
|
await topbar.closeWorkflowTab('Unsaved Workflow (2)')
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
})
|
|
})
|