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>
236 lines
7.5 KiB
TypeScript
236 lines
7.5 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
import type { Page } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { measureSelectionBounds } from '@e2e/fixtures/utils/boundsUtils'
|
|
import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils'
|
|
|
|
const SUBGRAPH_ID = '2'
|
|
const REGULAR_ID = '3'
|
|
const WORKFLOW = 'selection/subgraph-with-regular-node'
|
|
|
|
type Layout = { ref: [number, number]; target: [number, number] }
|
|
const LAYOUTS: Record<string, Layout> = {
|
|
'bottom-left': { ref: [200, 100], target: [150, 500] },
|
|
'bottom-right': { ref: [100, 100], target: [600, 500] }
|
|
}
|
|
|
|
type NodeType = 'subgraph' | 'regular'
|
|
type NodeState = 'expanded' | 'collapsed'
|
|
type Position = 'bottom-left' | 'bottom-right'
|
|
|
|
function getTargetId(type: NodeType): string {
|
|
return type === 'subgraph' ? SUBGRAPH_ID : REGULAR_ID
|
|
}
|
|
|
|
function getRefId(type: NodeType): string {
|
|
return type === 'subgraph' ? REGULAR_ID : SUBGRAPH_ID
|
|
}
|
|
|
|
async function toggleBypass(comfyPage: ComfyPage, nodeRef: NodeReference) {
|
|
await nodeRef.click('title')
|
|
await comfyPage.keyboard.bypass()
|
|
}
|
|
|
|
async function assertSelectionEncompassesNodes(
|
|
page: Page,
|
|
comfyPage: ComfyPage,
|
|
nodeIds: string[]
|
|
) {
|
|
await comfyPage.canvas.press('Control+a')
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getSelectedGraphNodesCount())
|
|
.toBe(2)
|
|
await comfyPage.nextFrame()
|
|
|
|
const result = await measureSelectionBounds(page, nodeIds)
|
|
expect(result.selectionBounds).not.toBeNull()
|
|
|
|
const sel = result.selectionBounds!
|
|
const selRight = sel.x + sel.w
|
|
const selBottom = sel.y + sel.h
|
|
|
|
for (const nodeId of nodeIds) {
|
|
const vis = result.nodeVisualBounds[nodeId]
|
|
expect(vis).toBeDefined()
|
|
|
|
expect(sel.x).toBeLessThanOrEqual(vis.x)
|
|
expect(selRight).toBeGreaterThanOrEqual(vis.x + vis.w)
|
|
expect(sel.y).toBeLessThanOrEqual(vis.y)
|
|
expect(selBottom).toBeGreaterThanOrEqual(vis.y + vis.h)
|
|
}
|
|
}
|
|
|
|
test.describe(
|
|
'Selection bounding box (Vue mode)',
|
|
{ tag: ['@canvas', '@node'] },
|
|
() => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
await comfyPage.workflow.loadWorkflow(WORKFLOW)
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
})
|
|
|
|
test.afterEach(async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.resetView()
|
|
})
|
|
|
|
const vueCases: ReadonlyArray<{
|
|
type: NodeType
|
|
state: NodeState
|
|
pos: Position
|
|
}> = [
|
|
{ type: 'subgraph', state: 'expanded', pos: 'bottom-left' },
|
|
{ type: 'subgraph', state: 'expanded', pos: 'bottom-right' },
|
|
{ type: 'subgraph', state: 'collapsed', pos: 'bottom-left' },
|
|
{ type: 'subgraph', state: 'collapsed', pos: 'bottom-right' },
|
|
{ type: 'regular', state: 'expanded', pos: 'bottom-left' },
|
|
{ type: 'regular', state: 'expanded', pos: 'bottom-right' },
|
|
{ type: 'regular', state: 'collapsed', pos: 'bottom-left' },
|
|
{ type: 'regular', state: 'collapsed', pos: 'bottom-right' }
|
|
]
|
|
|
|
for (const { type, state, pos } of vueCases) {
|
|
test(`${type} node (${state}) at ${pos}: selection bounds encompass node`, async ({
|
|
comfyPage
|
|
}) => {
|
|
const targetId = getTargetId(type)
|
|
const refId = getRefId(type)
|
|
|
|
await comfyPage.nodeOps.repositionNodes({
|
|
[refId]: LAYOUTS[pos].ref,
|
|
[targetId]: LAYOUTS[pos].target
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
await comfyPage.vueNodes.getNodeLocator(targetId).waitFor()
|
|
await comfyPage.vueNodes.getNodeLocator(refId).waitFor()
|
|
|
|
if (state === 'collapsed') {
|
|
const nodeRef = await comfyPage.nodeOps.getNodeRefById(targetId)
|
|
await nodeRef.toggleCollapse()
|
|
await expect.poll(() => nodeRef.isCollapsed()).toBe(true)
|
|
}
|
|
|
|
await assertSelectionEncompassesNodes(comfyPage.page, comfyPage, [
|
|
refId,
|
|
targetId
|
|
])
|
|
})
|
|
}
|
|
}
|
|
)
|
|
|
|
test.describe(
|
|
'Selection bounding box (Vue mode) — collapsed node bypass toggle',
|
|
{ tag: ['@canvas', '@node'] },
|
|
() => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
await comfyPage.workflow.loadWorkflow(WORKFLOW)
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
})
|
|
|
|
test.afterEach(async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.resetView()
|
|
})
|
|
|
|
test('collapsed node narrows bounding box when bypass is removed', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.nodeOps.repositionNodes({
|
|
[SUBGRAPH_ID]: LAYOUTS['bottom-right'].ref,
|
|
[REGULAR_ID]: LAYOUTS['bottom-right'].target
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
|
|
const nodeRef = await comfyPage.nodeOps.getNodeRefById(REGULAR_ID)
|
|
await toggleBypass(comfyPage, nodeRef)
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(true)
|
|
await nodeRef.toggleCollapse()
|
|
await expect.poll(() => nodeRef.isCollapsed()).toBe(true)
|
|
|
|
await toggleBypass(comfyPage, nodeRef)
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(false)
|
|
await comfyPage.nextFrame()
|
|
|
|
await assertSelectionEncompassesNodes(comfyPage.page, comfyPage, [
|
|
SUBGRAPH_ID,
|
|
REGULAR_ID
|
|
])
|
|
})
|
|
|
|
test('collapsed node widens bounding box when bypass is added', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.nodeOps.repositionNodes({
|
|
[SUBGRAPH_ID]: LAYOUTS['bottom-right'].ref,
|
|
[REGULAR_ID]: LAYOUTS['bottom-right'].target
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
|
|
const nodeRef = await comfyPage.nodeOps.getNodeRefById(REGULAR_ID)
|
|
await nodeRef.toggleCollapse()
|
|
await expect.poll(() => nodeRef.isCollapsed()).toBe(true)
|
|
|
|
await toggleBypass(comfyPage, nodeRef)
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(true)
|
|
await comfyPage.nextFrame()
|
|
|
|
await assertSelectionEncompassesNodes(comfyPage.page, comfyPage, [
|
|
SUBGRAPH_ID,
|
|
REGULAR_ID
|
|
])
|
|
})
|
|
}
|
|
)
|
|
|
|
test.describe(
|
|
'Selection bounding box (legacy mode)',
|
|
{ tag: ['@canvas', '@node'] },
|
|
() => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', false)
|
|
await comfyPage.workflow.loadWorkflow(WORKFLOW)
|
|
await comfyPage.nextFrame()
|
|
})
|
|
|
|
test.afterEach(async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.resetView()
|
|
})
|
|
|
|
const legacyCases: ReadonlyArray<{ state: NodeState; pos: Position }> = [
|
|
{ state: 'expanded', pos: 'bottom-left' },
|
|
{ state: 'expanded', pos: 'bottom-right' },
|
|
{ state: 'collapsed', pos: 'bottom-left' },
|
|
{ state: 'collapsed', pos: 'bottom-right' }
|
|
]
|
|
|
|
for (const { state, pos } of legacyCases) {
|
|
test(`legacy node (${state}) at ${pos}: selection bounds encompass node`, async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.nodeOps.repositionNodes({
|
|
[SUBGRAPH_ID]: LAYOUTS[pos].ref,
|
|
[REGULAR_ID]: LAYOUTS[pos].target
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
if (state === 'collapsed') {
|
|
const nodeRef = await comfyPage.nodeOps.getNodeRefById(REGULAR_ID)
|
|
await nodeRef.toggleCollapse()
|
|
await expect.poll(() => nodeRef.isCollapsed()).toBe(true)
|
|
}
|
|
|
|
await assertSelectionEncompassesNodes(comfyPage.page, comfyPage, [
|
|
SUBGRAPH_ID,
|
|
REGULAR_ID
|
|
])
|
|
})
|
|
}
|
|
}
|
|
)
|