mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 01:09:46 +00:00
## Summary Reorganize the subgraph test suite so browser tests are thin representative user journeys while lower-level Vitest suites own combinatorics, migration edge cases, and data-shape semantics. ## Changes - **What**: Migrate 17 flat subgraph browser specs into 10 domain-organized specs under `browser_tests/tests/subgraph/`, move redundant semantic coverage down to 8 Vitest owner suites, delete all legacy flat files - **Browser specs** (54 tests): `subgraphSlots`, `subgraphPromotion`, `subgraphPromotionDom`, `subgraphSerialization`, `subgraphNavigation`, `subgraphNested`, `subgraphLifecycle`, `subgraphCrud`, `subgraphSearch`, `subgraphOperations` - **Vitest owners** (230 tests): `SubgraphNode.test.ts` (rename/label propagation), `subgraphNodePromotion.test.ts`, `promotedWidgetView.test.ts`, `SubgraphSerialization.test.ts` (duplicate-ID remap), `SubgraphWidgetPromotion.test.ts` (legacy hydration), `subgraphNavigationStore*.test.ts` (viewport cache, workflow-switch), `subgraphStore.test.ts` (search aliases, description) - **Net effect**: browser suite shrinks from ~96 scattered tests to 54 focused journeys ## Review Focus - Coverage ownership split: each browser test has a unique UI-only failure mode; semantic coverage lives in Vitest - `subgraphPromotionDom.spec.ts` forces LiteGraph mode and uses `canvas.openSubgraph()` instead of `navigateIntoSubgraph()` to avoid a wrapper-specific DOM overlay duplication issue — entry-affordance coverage lives in `subgraphNavigation.spec.ts` - No product code changes — test-only migration ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10759-test-reorganize-subgraph-test-suite-into-composable-domain-specs-3336d73d365081b0a56bcbf809b1f584) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
145 lines
4.6 KiB
TypeScript
145 lines
4.6 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
const NEW_SUBGRAPH_TITLE = 'New Subgraph'
|
|
|
|
test.describe('Subgraph CRUD', { tag: ['@slow', '@subgraph'] }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
async function duplicateSubgraphNodeViaAltDrag(
|
|
comfyPage: ComfyPage
|
|
): Promise<void> {
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('2')
|
|
const subgraphPos = await subgraphNode.getPosition()
|
|
|
|
await comfyPage.page.mouse.move(subgraphPos.x + 16, subgraphPos.y + 16)
|
|
await comfyPage.page.keyboard.down('Alt')
|
|
try {
|
|
await comfyPage.page.mouse.down()
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.page.mouse.move(subgraphPos.x + 64, subgraphPos.y + 64)
|
|
await comfyPage.page.mouse.up()
|
|
} finally {
|
|
await comfyPage.page.keyboard.up('Alt')
|
|
}
|
|
}
|
|
|
|
test.describe('Subgraph Unpacking', () => {
|
|
test('Unpacking subgraph with duplicate links does not create extra links', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-duplicate-links'
|
|
)
|
|
|
|
const result = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.graph!
|
|
const subgraphNode = graph.nodes.find((n) => n.isSubgraphNode())
|
|
if (!subgraphNode || !subgraphNode.isSubgraphNode()) {
|
|
return { error: 'No subgraph node found' }
|
|
}
|
|
|
|
graph.unpackSubgraph(subgraphNode)
|
|
|
|
const linkCount = graph.links.size
|
|
const nodes = graph.nodes
|
|
const ksampler = nodes.find((n) => n.type === 'KSampler')
|
|
if (!ksampler) return { error: 'No KSampler found after unpack' }
|
|
|
|
const linkedInputCount = ksampler.inputs.filter(
|
|
(input) => input.link != null
|
|
).length
|
|
|
|
return { linkCount, linkedInputCount, nodeCount: nodes.length }
|
|
})
|
|
|
|
expect(result).not.toHaveProperty('error')
|
|
expect(result.linkCount).toBe(1)
|
|
expect(result.linkedInputCount).toBe(1)
|
|
})
|
|
})
|
|
|
|
test.describe('Subgraph Creation and Deletion', () => {
|
|
test('Can create subgraph from selected nodes', async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
|
|
await comfyPage.keyboard.selectAll()
|
|
await comfyPage.nextFrame()
|
|
|
|
const node = await comfyPage.nodeOps.getNodeRefById('5')
|
|
await node.convertToSubgraph()
|
|
|
|
await expect
|
|
.poll(
|
|
async () =>
|
|
(await comfyPage.nodeOps.getNodeRefsByTitle(NEW_SUBGRAPH_TITLE))
|
|
.length
|
|
)
|
|
.toBe(1)
|
|
await expect.poll(() => comfyPage.subgraph.getNodeCount()).toBe(1)
|
|
})
|
|
|
|
test('Can delete subgraph node', async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('2')
|
|
expect(await subgraphNode.exists()).toBe(true)
|
|
|
|
const initialNodeCount = await comfyPage.subgraph.getNodeCount()
|
|
|
|
await subgraphNode.delete()
|
|
|
|
const deletedNode = await comfyPage.nodeOps.getNodeRefById('2')
|
|
await expect
|
|
.poll(() => comfyPage.subgraph.getNodeCount())
|
|
.toBe(initialNodeCount - 1)
|
|
await expect.poll(() => deletedNode.exists()).toBe(false)
|
|
})
|
|
|
|
test.describe('Subgraph Copy', () => {
|
|
test('Can duplicate a subgraph node by alt-dragging', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
|
|
await duplicateSubgraphNodeViaAltDrag(comfyPage)
|
|
|
|
await expect
|
|
.poll(
|
|
async () =>
|
|
(await comfyPage.nodeOps.getNodeRefsByTitle(NEW_SUBGRAPH_TITLE))
|
|
.length
|
|
)
|
|
.toBe(2)
|
|
})
|
|
|
|
test('Alt-dragging a subgraph node creates a new subgraph type', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
|
|
await duplicateSubgraphNodeViaAltDrag(comfyPage)
|
|
|
|
await expect
|
|
.poll(
|
|
async () =>
|
|
(await comfyPage.nodeOps.getNodeRefsByTitle(NEW_SUBGRAPH_TITLE))
|
|
.length
|
|
)
|
|
.toBe(2)
|
|
|
|
const subgraphNodes =
|
|
await comfyPage.nodeOps.getNodeRefsByTitle(NEW_SUBGRAPH_TITLE)
|
|
const nodeType1 = await subgraphNodes[0].getType()
|
|
const nodeType2 = await subgraphNodes[1].getType()
|
|
expect(nodeType1).not.toBe(nodeType2)
|
|
})
|
|
})
|
|
})
|
|
})
|