mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary From the primordial entropy of 17 scattered spec files — a formless sprawl of mixed concerns and inconsistent naming — emerges a clean, domain-organized hierarchy. Order triumphs over chaos. ## Changes - **What**: Reorganize all subgraph E2E tests from 17 flat files in `browser_tests/tests/` into 10 domain-grouped files under `browser_tests/tests/subgraph/`. | File | Tests | Domain | |------|-------|--------| | `subgraphSlots` | 16 | I/O slot CRUD, rename, alignment, promoted slot position | | `subgraphPromotion` | 22 | Auto-promote, visibility, reactivity, context menu, cleanup | | `subgraphSerialization` | 16 | Hydration, round-trip, legacy formats, ID remapping | | `subgraphNavigation` | 10 | Breadcrumb, viewport, hotkeys, progress state | | `subgraphNested` | 9 | Configure order, duplicate names, pack values, stale proxies | | `subgraphLifecycle` | 7 | Source removal cleanup, pseudo-preview lifecycle | | `subgraphPromotionDom` | 6 | DOM widget persistence, cleanup, positioning | | `subgraphCrud` | 5 | Create, delete, copy, unpack | | `subgraphSearch` | 3 | Search aliases, description, persistence | | `subgraphOperations` | 2 | Copy/paste inside, undo/redo inside | Where once the monolith `subgraph.spec.ts` (856 lines) mixed slot CRUD with hotkeys, DOM widgets with navigation, and copy/paste with undo/redo — now each behavioral domain has its sovereign territory. Where once `subgraph-rename-dialog.spec.ts`, `subgraphInputSlotRename.spec.ts`, and `subgraph-promoted-slot-position.spec.ts` scattered rename concerns across three kingdoms — now they answer to one crown: `subgraphSlots.spec.ts`. Where once `kebab-case` and `camelCase` warred for dominion — now a single convention reigns. All 96 test cases preserved. Zero test logic changes. Purely structural. ## Review Focus - Verify no tests were lost in the consolidation - Confirm import paths all resolve correctly at the new depth (`../../fixtures/`) - The `import.meta.dirname` asset path in `subgraphSlots.spec.ts` (slot alignment test) updated for new directory depth ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10695-test-reorganize-subgraph-E2E-tests-into-domain-organized-directory-3326d73d36508197939be8825b69ea88) by [Unito](https://www.unito.io) Co-authored-by: Amp <amp@ampcode.com>
211 lines
7.0 KiB
TypeScript
211 lines
7.0 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../../fixtures/ComfyPage'
|
|
import { TestIds } from '../../fixtures/selectors'
|
|
import {
|
|
getPromotedWidgets,
|
|
getPseudoPreviewWidgets,
|
|
getNonPreviewPromotedWidgets
|
|
} from '../../helpers/promotedWidgets'
|
|
|
|
const domPreviewSelector = '.image-preview'
|
|
|
|
test.describe(
|
|
'Subgraph Lifecycle Edge Behaviors',
|
|
{ tag: ['@subgraph'] },
|
|
() => {
|
|
test.describe('Cleanup Behavior After Promoted Source Removal', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
})
|
|
|
|
test('Removing promoted source node inside subgraph cleans up exterior proxyWidgets', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-promoted-text-widget'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const initialWidgets = await getPromotedWidgets(comfyPage, '11')
|
|
expect(initialWidgets.length).toBeGreaterThan(0)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
await subgraphNode.navigateIntoSubgraph()
|
|
|
|
const clipNode = await comfyPage.nodeOps.getNodeRefById('10')
|
|
await clipNode.delete()
|
|
|
|
await comfyPage.subgraph.exitViaBreadcrumb()
|
|
|
|
await expect
|
|
.poll(async () => {
|
|
return await comfyPage.page.evaluate(() => {
|
|
const hostNode = window.app!.canvas.graph!.getNodeById('11')
|
|
const proxyWidgets = hostNode?.properties?.proxyWidgets
|
|
return {
|
|
proxyWidgetCount: Array.isArray(proxyWidgets)
|
|
? proxyWidgets.length
|
|
: 0,
|
|
firstWidgetType: hostNode?.widgets?.[0]?.type
|
|
}
|
|
})
|
|
})
|
|
.toEqual({
|
|
proxyWidgetCount: 0,
|
|
firstWidgetType: undefined
|
|
})
|
|
})
|
|
|
|
test('Promoted widget disappears from DOM after interior node deletion', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-promoted-text-widget'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const textarea = comfyPage.page.getByTestId(
|
|
TestIds.widgets.domWidgetTextarea
|
|
)
|
|
await expect(textarea).toBeVisible()
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
await subgraphNode.navigateIntoSubgraph()
|
|
|
|
const clipNode = await comfyPage.nodeOps.getNodeRefById('10')
|
|
await clipNode.delete()
|
|
|
|
await comfyPage.subgraph.exitViaBreadcrumb()
|
|
|
|
await expect(
|
|
comfyPage.page.getByTestId(TestIds.widgets.domWidgetTextarea)
|
|
).toHaveCount(0)
|
|
})
|
|
})
|
|
|
|
test.describe('Unpack/Remove Cleanup for Pseudo-Preview Targets', () => {
|
|
test('Pseudo-preview entries exist in proxyWidgets for preview subgraph', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-preview-node'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const pseudoWidgets = await getPseudoPreviewWidgets(comfyPage, '5')
|
|
expect(pseudoWidgets.length).toBeGreaterThan(0)
|
|
expect(
|
|
pseudoWidgets.some(([, name]) => name === '$$canvas-image-preview')
|
|
).toBe(true)
|
|
})
|
|
|
|
test('Non-preview widgets coexist with pseudo-preview entries', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-preview-node'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const pseudoWidgets = await getPseudoPreviewWidgets(comfyPage, '5')
|
|
const nonPreviewWidgets = await getNonPreviewPromotedWidgets(
|
|
comfyPage,
|
|
'5'
|
|
)
|
|
|
|
expect(pseudoWidgets.length).toBeGreaterThan(0)
|
|
expect(nonPreviewWidgets.length).toBeGreaterThan(0)
|
|
expect(
|
|
nonPreviewWidgets.some(([, name]) => name === 'filename_prefix')
|
|
).toBe(true)
|
|
})
|
|
|
|
test('Unpacking subgraph clears pseudo-preview entries from graph', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-preview-node'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const beforePseudo = await getPseudoPreviewWidgets(comfyPage, '5')
|
|
expect(beforePseudo.length).toBeGreaterThan(0)
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.graph!
|
|
const subgraphNode = graph.nodes.find((n) => n.isSubgraphNode())
|
|
if (!subgraphNode || !subgraphNode.isSubgraphNode()) return
|
|
graph.unpackSubgraph(subgraphNode)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
const subgraphNodeCount = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.graph!
|
|
return graph.nodes.filter((n) => n.isSubgraphNode()).length
|
|
})
|
|
expect(subgraphNodeCount).toBe(0)
|
|
|
|
await expect
|
|
.poll(async () => comfyPage.subgraph.countGraphPseudoPreviewEntries())
|
|
.toBe(0)
|
|
})
|
|
|
|
test('Removing subgraph node clears pseudo-preview DOM elements', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-preview-node'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const beforePseudo = await getPseudoPreviewWidgets(comfyPage, '5')
|
|
expect(beforePseudo.length).toBeGreaterThan(0)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('5')
|
|
expect(await subgraphNode.exists()).toBe(true)
|
|
|
|
await subgraphNode.delete()
|
|
|
|
expect(await subgraphNode.exists()).toBe(false)
|
|
|
|
await expect
|
|
.poll(async () => comfyPage.subgraph.countGraphPseudoPreviewEntries())
|
|
.toBe(0)
|
|
await expect(comfyPage.page.locator(domPreviewSelector)).toHaveCount(0)
|
|
})
|
|
|
|
test('Unpacking one subgraph does not clear sibling pseudo-preview entries', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-multiple-promoted-previews'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const firstNodeBefore = await getPseudoPreviewWidgets(comfyPage, '7')
|
|
const secondNodeBefore = await getPseudoPreviewWidgets(comfyPage, '8')
|
|
|
|
expect(firstNodeBefore.length).toBeGreaterThan(0)
|
|
expect(secondNodeBefore.length).toBeGreaterThan(0)
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.graph!
|
|
const subgraphNode = graph.getNodeById('7')
|
|
if (!subgraphNode || !subgraphNode.isSubgraphNode()) return
|
|
graph.unpackSubgraph(subgraphNode)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
const firstNodeExists = await comfyPage.page.evaluate(() => {
|
|
return !!window.app!.graph!.getNodeById('7')
|
|
})
|
|
expect(firstNodeExists).toBe(false)
|
|
|
|
const secondNodeAfter = await getPseudoPreviewWidgets(comfyPage, '8')
|
|
expect(secondNodeAfter).toEqual(secondNodeBefore)
|
|
})
|
|
})
|
|
}
|
|
)
|