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>
141 lines
4.3 KiB
TypeScript
141 lines
4.3 KiB
TypeScript
import type { Page } from '@playwright/test'
|
|
|
|
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
import {
|
|
interceptClipboardWrite,
|
|
getClipboardText
|
|
} from '@e2e/helpers/clipboardSpy'
|
|
|
|
async function triggerConfigureError(
|
|
comfyPage: ComfyPage,
|
|
message = 'Error on configure!'
|
|
) {
|
|
await comfyPage.page.evaluate((msg: string) => {
|
|
const graph = window.graph!
|
|
;(graph as { configure: () => void }).configure = () => {
|
|
throw new Error(msg)
|
|
}
|
|
}, message)
|
|
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
|
|
return comfyPage.page.getByTestId(TestIds.dialogs.errorDialog)
|
|
}
|
|
|
|
async function waitForPopupNavigation(page: Page, action: () => Promise<void>) {
|
|
const popupPromise = page.waitForEvent('popup')
|
|
await action()
|
|
const popup = await popupPromise
|
|
await popup.waitForLoadState()
|
|
return popup
|
|
}
|
|
|
|
test.describe('Error dialog', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test('Should display an error dialog when graph configure fails', async ({
|
|
comfyPage
|
|
}) => {
|
|
const errorDialog = await triggerConfigureError(comfyPage)
|
|
await expect(errorDialog).toBeVisible()
|
|
})
|
|
|
|
test('Should display an error dialog when prompt execution fails', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.page.evaluate(async () => {
|
|
const app = window.app!
|
|
app.api.queuePrompt = () => {
|
|
throw new Error('Error on queuePrompt!')
|
|
}
|
|
await app.queuePrompt(0)
|
|
})
|
|
const errorDialog = comfyPage.page.getByTestId(TestIds.dialogs.errorDialog)
|
|
await expect(errorDialog).toBeVisible()
|
|
})
|
|
|
|
test('Should display error message body', async ({ comfyPage }) => {
|
|
const errorDialog = await triggerConfigureError(
|
|
comfyPage,
|
|
'Test error message body'
|
|
)
|
|
await expect(errorDialog).toBeVisible()
|
|
await expect(errorDialog).toContainText('Test error message body')
|
|
})
|
|
|
|
test('Should show report section when "Show Report" is clicked', async ({
|
|
comfyPage
|
|
}) => {
|
|
const errorDialog = await triggerConfigureError(comfyPage)
|
|
await expect(errorDialog).toBeVisible()
|
|
await expect(errorDialog.locator('pre')).not.toBeVisible()
|
|
|
|
await errorDialog.getByTestId(TestIds.dialogs.errorDialogShowReport).click()
|
|
|
|
const reportPre = errorDialog.locator('pre')
|
|
await expect(reportPre).toBeVisible()
|
|
await expect(reportPre).toHaveText(/\S/)
|
|
await expect(
|
|
errorDialog.getByTestId(TestIds.dialogs.errorDialogShowReport)
|
|
).not.toBeVisible()
|
|
})
|
|
|
|
test('Should copy report to clipboard when "Copy to Clipboard" is clicked', async ({
|
|
comfyPage
|
|
}) => {
|
|
const errorDialog = await triggerConfigureError(comfyPage)
|
|
await expect(errorDialog).toBeVisible()
|
|
|
|
await errorDialog.getByTestId(TestIds.dialogs.errorDialogShowReport).click()
|
|
await expect(errorDialog.locator('pre')).toBeVisible()
|
|
|
|
await interceptClipboardWrite(comfyPage.page)
|
|
|
|
await errorDialog.getByTestId(TestIds.dialogs.errorDialogCopyReport).click()
|
|
|
|
const reportText = await errorDialog.locator('pre').textContent()
|
|
await expect
|
|
.poll(async () => await getClipboardText(comfyPage.page))
|
|
.toBe(reportText)
|
|
})
|
|
|
|
test('Should open GitHub issues search when "Find Issues" is clicked', async ({
|
|
comfyPage
|
|
}) => {
|
|
const errorDialog = await triggerConfigureError(comfyPage)
|
|
await expect(errorDialog).toBeVisible()
|
|
|
|
const popup = await waitForPopupNavigation(comfyPage.page, () =>
|
|
errorDialog.getByTestId(TestIds.dialogs.errorDialogFindIssues).click()
|
|
)
|
|
|
|
const url = new URL(popup.url())
|
|
expect(url.hostname).toBe('github.com')
|
|
expect(url.pathname).toContain('/issues')
|
|
|
|
await popup.close()
|
|
})
|
|
|
|
test('Should open contact support when "Help Fix This" is clicked', async ({
|
|
comfyPage
|
|
}) => {
|
|
const errorDialog = await triggerConfigureError(comfyPage)
|
|
await expect(errorDialog).toBeVisible()
|
|
|
|
const popup = await waitForPopupNavigation(comfyPage.page, () =>
|
|
errorDialog.getByTestId(TestIds.dialogs.errorDialogContactSupport).click()
|
|
)
|
|
|
|
const url = new URL(popup.url())
|
|
expect(url.hostname).toBe('support.comfy.org')
|
|
|
|
await popup.close()
|
|
})
|
|
})
|