mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 06:35:10 +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>
123 lines
4.2 KiB
TypeScript
123 lines
4.2 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import {
|
|
getPromotedWidgetNames,
|
|
getPromotedWidgetCountByName
|
|
} from '@e2e/fixtures/utils/promotedWidgets'
|
|
|
|
test.describe('Vue Nodes Image Preview', { tag: '@vue-nodes' }, () => {
|
|
async function loadImageOnNode(comfyPage: ComfyPage) {
|
|
await comfyPage.workflow.loadWorkflow('widgets/load_image_widget')
|
|
|
|
const loadImageNode = (
|
|
await comfyPage.nodeOps.getNodeRefsByType('LoadImage')
|
|
)[0]
|
|
const { x, y } = await loadImageNode.getPosition()
|
|
|
|
await comfyPage.dragDrop.dragAndDropFile('image64x64.webp', {
|
|
dropPosition: { x, y }
|
|
})
|
|
|
|
const nodeId = String(loadImageNode.id)
|
|
const imagePreview = comfyPage.vueNodes
|
|
.getNodeLocator(nodeId)
|
|
.locator('.image-preview')
|
|
|
|
await expect(imagePreview).toBeVisible()
|
|
await expect(imagePreview.locator('img')).toBeVisible({ timeout: 30_000 })
|
|
await expect(imagePreview).toContainText('x')
|
|
|
|
return {
|
|
imagePreview,
|
|
nodeId
|
|
}
|
|
}
|
|
|
|
test('opens mask editor from image preview button', async ({ comfyPage }) => {
|
|
const { imagePreview } = await loadImageOnNode(comfyPage)
|
|
|
|
await imagePreview.getByRole('region').hover()
|
|
await comfyPage.page.getByLabel('Edit or mask image').click()
|
|
|
|
await expect(comfyPage.page.locator('.mask-editor-dialog')).toBeVisible()
|
|
})
|
|
|
|
test('shows image context menu options', async ({ comfyPage }) => {
|
|
const { nodeId } = await loadImageOnNode(comfyPage)
|
|
|
|
await comfyPage.vueNodes.selectNode(nodeId)
|
|
const nodeHeader = comfyPage.vueNodes
|
|
.getNodeLocator(nodeId)
|
|
.locator('.lg-node-header')
|
|
await nodeHeader.click({ button: 'right' })
|
|
|
|
const contextMenu = comfyPage.page.locator('.p-contextmenu')
|
|
await expect(contextMenu).toBeVisible()
|
|
await expect(contextMenu.getByText('Open Image')).toBeVisible()
|
|
await expect(contextMenu.getByText('Copy Image')).toBeVisible()
|
|
await expect(contextMenu.getByText('Save Image')).toBeVisible()
|
|
await expect(contextMenu.getByText('Open in Mask Editor')).toBeVisible()
|
|
})
|
|
|
|
test(
|
|
'renders promoted image previews for each subgraph node',
|
|
{ tag: '@screenshot' },
|
|
async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-multiple-promoted-previews'
|
|
)
|
|
|
|
const firstSubgraphNode = comfyPage.vueNodes.getNodeLocator('7')
|
|
const secondSubgraphNode = comfyPage.vueNodes.getNodeLocator('8')
|
|
|
|
await expect(firstSubgraphNode).toBeVisible()
|
|
await expect(secondSubgraphNode).toBeVisible()
|
|
|
|
await expect
|
|
.poll(() => getPromotedWidgetNames(comfyPage, '7'))
|
|
.toEqual(['$$canvas-image-preview', '$$canvas-image-preview'])
|
|
await expect
|
|
.poll(() => getPromotedWidgetNames(comfyPage, '8'))
|
|
.toEqual(['$$canvas-image-preview'])
|
|
|
|
await expect
|
|
.poll(() =>
|
|
getPromotedWidgetCountByName(comfyPage, '7', '$$canvas-image-preview')
|
|
)
|
|
.toBe(2)
|
|
await expect
|
|
.poll(() =>
|
|
getPromotedWidgetCountByName(comfyPage, '8', '$$canvas-image-preview')
|
|
)
|
|
.toBe(1)
|
|
|
|
await expect(
|
|
firstSubgraphNode.locator('.lg-node-widgets')
|
|
).not.toContainText('$$canvas-image-preview')
|
|
await expect(
|
|
secondSubgraphNode.locator('.lg-node-widgets')
|
|
).not.toContainText('$$canvas-image-preview')
|
|
|
|
await comfyPage.command.executeCommand('Comfy.Canvas.FitView')
|
|
await comfyPage.command.executeCommand('Comfy.QueuePrompt')
|
|
|
|
const firstPreviewImages = firstSubgraphNode.locator('.image-preview img')
|
|
const secondPreviewImages =
|
|
secondSubgraphNode.locator('.image-preview img')
|
|
|
|
await expect(firstPreviewImages).toHaveCount(2, { timeout: 30_000 })
|
|
await expect(secondPreviewImages).toHaveCount(1, { timeout: 30_000 })
|
|
|
|
await expect(firstPreviewImages.first()).toBeVisible({ timeout: 30_000 })
|
|
await expect(firstPreviewImages.nth(1)).toBeVisible({ timeout: 30_000 })
|
|
await expect(secondPreviewImages.first()).toBeVisible({ timeout: 30_000 })
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'vue-node-multiple-promoted-previews.png'
|
|
)
|
|
}
|
|
)
|
|
})
|