mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-11 16:30:57 +00:00
*PR Created by the Glary-Bot Agent* --- ## Summary - Eliminates the confusing dual-helpers structure where `browser_tests/helpers/` and `browser_tests/fixtures/helpers/` coexisted one tier apart with overlapping purposes - Routes each file to its natural home based on what it actually *is*: page objects → `components/`, standalone utils → `utils/`, domain helper classes stay in `helpers/` - Adds an ESLint guard (`no-restricted-imports`) to prevent re-creating `browser_tests/helpers/` ## File Moves | File | From | To | Reason | |---|---|---|---| | `actionbar.ts` | `helpers/` | `fixtures/components/Actionbar.ts` | Page object class imported by ComfyPage | | `templates.ts` | `helpers/` | `fixtures/components/Templates.ts` | Page object class imported by ComfyPage | | `boundsUtils.ts` | `fixtures/helpers/` | `fixtures/utils/` | Pure function, not a helper class | | `mimeTypeUtil.ts` | `fixtures/helpers/` | `fixtures/utils/` | Pure function, not a helper class | | `builderTestUtils.ts` | `helpers/` | `fixtures/utils/` | Shared test setup functions | | `clipboardSpy.ts` | `helpers/` | `fixtures/utils/` | Page injection utility | | `fitToView.ts` | `helpers/` | `fixtures/utils/` | Canvas utility function | | `manageGroupNode.ts` | `helpers/` | `fixtures/utils/` | Litegraph interaction helper | | `painter.ts` | `helpers/` | `fixtures/utils/` | Test helper functions | | `perfReporter.ts` | `helpers/` | `fixtures/utils/` | Test infrastructure | | `promotedWidgets.ts` | `helpers/` | `fixtures/utils/` | Query helpers for specs | ## What Changed Beyond File Moves - **28 import statements** updated across test specs, fixtures, and infra files - **AGENTS.md** — directory tree diagram and architectural separation descriptions updated - **README.md** — "Leverage Existing Fixtures and Helpers" section updated - **`.claude/skills/perf-fix-with-proof/SKILL.md`** — perfReporter path reference updated - **`eslint.config.ts`** — added `@e2e/helpers/*` restricted import pattern to both spec and non-spec browser_tests rules ## Verification - `pnpm typecheck` — clean - `pnpm typecheck:browser` — clean - `pnpm lint` — 0 errors, 0 warnings - `pnpm format:check` — all files formatted - `pnpm knip` — clean - Pre-commit hooks passed full pipeline (oxfmt, oxlint, eslint, typecheck, typecheck:browser) ## Config Audit No changes needed to: `tsconfig.json` (`@e2e/*` alias covers all subdirs), `playwright.config.ts`, `vite.config.mts`, `knip.config.ts`, `.oxlintrc.json`, `nx.json` ## Manual Verification Note This is a pure structural refactoring (file moves + import updates) with zero behavioral or visual changes. The typecheck and lint passes confirm all imports resolve correctly. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11411-refactor-consolidate-browser_tests-helpers-into-fixtures-3476d73d3650816cb671ef7fa8433f66) by [Unito](https://www.unito.io) --------- Co-authored-by: glary-bot <glary-bot@comfy.org> Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com> Co-authored-by: DrJKL <DrJKL0424@gmail.com> Co-authored-by: Amp <amp@ampcode.com>
152 lines
4.7 KiB
TypeScript
152 lines
4.7 KiB
TypeScript
import { mergeTests } from '@playwright/test'
|
|
|
|
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
import {
|
|
LogsTerminalHelper,
|
|
logsTerminalFixture
|
|
} from '@e2e/fixtures/helpers/LogsTerminalHelper'
|
|
import { webSocketFixture } from '@e2e/fixtures/ws'
|
|
import {
|
|
getClipboardText,
|
|
interceptClipboardWrite
|
|
} from '@e2e/fixtures/utils/clipboardSpy'
|
|
|
|
const test = mergeTests(comfyPageFixture, logsTerminalFixture, webSocketFixture)
|
|
|
|
test.describe('Bottom Panel Logs', { tag: '@ui' }, () => {
|
|
test.describe('panel', () => {
|
|
test.beforeEach(async ({ logsTerminal }) => {
|
|
await logsTerminal.mockSubscribeLogs()
|
|
await logsTerminal.mockRawLogs([])
|
|
})
|
|
|
|
test('opens to Logs tab via toggle button', async ({ comfyPage }) => {
|
|
await expect(comfyPage.bottomPanel.root).toBeHidden()
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.logs.tab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toBeVisible()
|
|
})
|
|
|
|
test('closes via toggle button', async ({ comfyPage }) => {
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.root).toBeVisible()
|
|
|
|
await comfyPage.bottomPanel.toggleButton.click()
|
|
await expect(comfyPage.bottomPanel.root).toBeHidden()
|
|
})
|
|
|
|
test('switches from shortcuts to Logs tab', async ({ comfyPage }) => {
|
|
await comfyPage.bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(comfyPage.bottomPanel.shortcuts.essentialsTab).toBeVisible()
|
|
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.logs.tab).toBeVisible()
|
|
await expect(comfyPage.bottomPanel.shortcuts.essentialsTab).toBeHidden()
|
|
})
|
|
})
|
|
|
|
test.describe('terminal', () => {
|
|
test.beforeEach(async ({ logsTerminal }) => {
|
|
await logsTerminal.mockSubscribeLogs()
|
|
await logsTerminal.mockRawLogs([])
|
|
})
|
|
|
|
test('shows loading spinner while logs are loading', async ({
|
|
comfyPage,
|
|
logsTerminal
|
|
}) => {
|
|
const resolveRaw = await logsTerminal.mockRawLogsPending()
|
|
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.logs.loadingSpinner).toBeVisible()
|
|
|
|
resolveRaw()
|
|
await expect(comfyPage.bottomPanel.logs.loadingSpinner).toBeHidden()
|
|
})
|
|
|
|
test('renders initial log entries from the raw-logs API', async ({
|
|
comfyPage,
|
|
logsTerminal
|
|
}) => {
|
|
const logLine = 'Hello from ComfyUI backend!'
|
|
await logsTerminal.mockRawLogs([logLine])
|
|
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
|
|
await expect(comfyPage.bottomPanel.logs.xtermScreen).toBeVisible()
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toContainText(
|
|
logLine
|
|
)
|
|
})
|
|
|
|
test('appends log entries received via WebSocket', async ({
|
|
comfyPage,
|
|
getWebSocket
|
|
}) => {
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toBeVisible()
|
|
|
|
const ws = await getWebSocket()
|
|
const firstLine = 'First live log line'
|
|
const secondLine = 'Second live log line'
|
|
|
|
ws.send(LogsTerminalHelper.buildWsLogFrame([firstLine]))
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toContainText(
|
|
firstLine
|
|
)
|
|
|
|
ws.send(LogsTerminalHelper.buildWsLogFrame([secondLine]))
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toContainText(
|
|
firstLine
|
|
)
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toContainText(
|
|
secondLine
|
|
)
|
|
})
|
|
|
|
test('copy button copies terminal contents to clipboard', async ({
|
|
comfyPage,
|
|
logsTerminal
|
|
}) => {
|
|
const logLine = 'Copy me to the clipboard'
|
|
await logsTerminal.mockRawLogs([logLine])
|
|
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toContainText(
|
|
logLine
|
|
)
|
|
|
|
await interceptClipboardWrite(comfyPage.page)
|
|
|
|
await comfyPage.bottomPanel.logs.terminalRoot.hover()
|
|
await expect(comfyPage.bottomPanel.logs.copyButton).toBeVisible()
|
|
await comfyPage.bottomPanel.logs.copyButton.click()
|
|
|
|
await expect
|
|
.poll(() => getClipboardText(comfyPage.page))
|
|
.toContain(logLine)
|
|
})
|
|
|
|
test('shows error message when raw-logs API fails', async ({
|
|
comfyPage,
|
|
logsTerminal
|
|
}) => {
|
|
await logsTerminal.mockRawLogsError()
|
|
|
|
await comfyPage.bottomPanel.toggleLogs()
|
|
|
|
await expect(comfyPage.bottomPanel.logs.errorMessage).toBeVisible()
|
|
await expect(comfyPage.bottomPanel.logs.errorMessage).toContainText(
|
|
'Unable to load logs'
|
|
)
|
|
await expect(comfyPage.bottomPanel.logs.terminalRoot).toBeHidden()
|
|
})
|
|
})
|
|
})
|