mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 13:59:28 +00:00
## Summary Complete the @e2e/ path alias migration started in #10735 by converting all 354 remaining relative imports and adding a lint rule to prevent backsliding. ## Changes - **What**: Migrate all relative imports in browser_tests/ to use `@e2e/` (intra-directory) and `@/` (src/ imports) path aliases. Add `no-restricted-imports` ESLint rule banning `./` and `../` imports in `browser_tests/**/*.ts`. Suppress pre-existing oxlint `no-eval` and `no-console` warnings exposed by touching those files. ## Review Focus - ESLint flat-config merging: the `@playwright/test` ban and relative-import ban are in two separate blocks to avoid last-match-wins collision with the `useI18n`/`useVirtualList` blocks higher in the config. - The `['./**', '../**']` glob patterns (not `['./*', '../*']`) are needed to catch multi-level relative paths like `../../../src/foo`. Follows up on #10735 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10958-test-migrate-browser_tests-to-e2e-path-alias-and-add-lint-rule-33c6d73d365081649d1be771eac986fd) by [Unito](https://www.unito.io) Co-authored-by: Amp <amp@ampcode.com>
140 lines
4.3 KiB
TypeScript
140 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()
|
|
const copiedText = await getClipboardText(comfyPage.page)
|
|
expect(copiedText).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()
|
|
})
|
|
})
|