mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Add integration contract tests (unit) and expanded Playwright coverage for subgraph promotion, hydration, navigation, and lifecycle edge behaviors. ## Changes - **What**: 22 unit/integration tests across 9 files covering promotion store sync, widget view lifecycle, input link resolution, pseudo-widget cache, navigation viewport restore, and subgraph operations. 13 Playwright E2E tests covering proxyWidgets hydration stability, promoted source removal cleanup, pseudo-preview unpack/remove, multi-link representative round-trip, nested promotion retarget, and navigation state on workflow switch. - **Helpers**: Added `isPseudoPreviewEntry`, `getPseudoPreviewWidgets`, `getNonPreviewPromotedWidgets` to promotedWidgets helper. Added `SubgraphHelper.getNodeCount()`. ## Review Focus - Test-only PR — no production code changes - Validates existing subgraph behaviors are covered by regression tests before further feature work - Phase 4 (unit/integration contracts) and Phase 5 (Playwright expansion) of the subgraph test coverage plan ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10123-test-subgraph-integration-contracts-and-expanded-Playwright-coverage-3256d73d365081258023e3a763859e00) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com>
132 lines
4.9 KiB
TypeScript
132 lines
4.9 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.describe(
|
|
'Subgraph progress clear on navigation',
|
|
{ tag: ['@subgraph'] },
|
|
() => {
|
|
test('Stale progress is cleared on subgraph node after navigating back', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
await comfyPage.nextFrame()
|
|
|
|
// Find the subgraph node
|
|
const subgraphNodeId = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph!
|
|
const subgraphNode = graph.nodes.find(
|
|
(n) => typeof n.isSubgraphNode === 'function' && n.isSubgraphNode()
|
|
)
|
|
return subgraphNode ? String(subgraphNode.id) : null
|
|
})
|
|
expect(subgraphNodeId).not.toBeNull()
|
|
|
|
// Simulate a stale progress value on the subgraph node.
|
|
// This happens when:
|
|
// 1. User views root graph during execution
|
|
// 2. Progress watcher sets node.progress = 0.5
|
|
// 3. User enters subgraph
|
|
// 4. Execution completes (nodeProgressStates becomes {})
|
|
// 5. Watcher fires, clears subgraph-internal nodes, but root-level
|
|
// SubgraphNode isn't visible so it keeps stale progress
|
|
// 6. User navigates back — watcher should fire and clear it
|
|
await comfyPage.page.evaluate((nodeId) => {
|
|
const node = window.app!.canvas.graph!.getNodeById(nodeId)!
|
|
node.progress = 0.5
|
|
}, subgraphNodeId!)
|
|
|
|
// Verify progress is set
|
|
const progressBefore = await comfyPage.page.evaluate((nodeId) => {
|
|
return window.app!.canvas.graph!.getNodeById(nodeId)!.progress
|
|
}, subgraphNodeId!)
|
|
expect(progressBefore).toBe(0.5)
|
|
|
|
// Navigate into the subgraph
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById(
|
|
subgraphNodeId!
|
|
)
|
|
await subgraphNode.navigateIntoSubgraph()
|
|
|
|
// Verify we're inside the subgraph
|
|
const inSubgraph = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph
|
|
return !!graph && 'inputNode' in graph
|
|
})
|
|
expect(inSubgraph).toBe(true)
|
|
|
|
// Navigate back to the root graph
|
|
await comfyPage.page.keyboard.press('Escape')
|
|
await comfyPage.nextFrame()
|
|
|
|
// The progress watcher should fire when graph changes (because
|
|
// nodeLocationProgressStates is empty {} and the watcher should
|
|
// iterate canvas.graph.nodes to clear stale node.progress values).
|
|
//
|
|
// BUG: Without watching canvasStore.currentGraph, the watcher doesn't
|
|
// fire on subgraph->root navigation when progress is already empty,
|
|
// leaving stale node.progress = 0.5 on the SubgraphNode.
|
|
await expect(async () => {
|
|
const progressAfter = await comfyPage.page.evaluate((nodeId) => {
|
|
return window.app!.canvas.graph!.getNodeById(nodeId)!.progress
|
|
}, subgraphNodeId!)
|
|
expect(progressAfter).toBeUndefined()
|
|
}).toPass({ timeout: 2_000 })
|
|
})
|
|
|
|
test('Stale progress is cleared when switching workflows while inside subgraph', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
await comfyPage.nextFrame()
|
|
|
|
const subgraphNodeId = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph!
|
|
const subgraphNode = graph.nodes.find(
|
|
(n) => typeof n.isSubgraphNode === 'function' && n.isSubgraphNode()
|
|
)
|
|
return subgraphNode ? String(subgraphNode.id) : null
|
|
})
|
|
expect(subgraphNodeId).not.toBeNull()
|
|
|
|
await comfyPage.page.evaluate((nodeId) => {
|
|
const node = window.app!.canvas.graph!.getNodeById(nodeId)!
|
|
node.progress = 0.7
|
|
}, subgraphNodeId!)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById(
|
|
subgraphNodeId!
|
|
)
|
|
await subgraphNode.navigateIntoSubgraph()
|
|
|
|
const inSubgraph = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph
|
|
return !!graph && 'inputNode' in graph
|
|
})
|
|
expect(inSubgraph).toBe(true)
|
|
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph')
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect(async () => {
|
|
const subgraphProgressState = await comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph!
|
|
const subgraphNode = graph.nodes.find(
|
|
(n) => typeof n.isSubgraphNode === 'function' && n.isSubgraphNode()
|
|
)
|
|
if (!subgraphNode) {
|
|
return { exists: false, progress: null }
|
|
}
|
|
|
|
return { exists: true, progress: subgraphNode.progress }
|
|
})
|
|
expect(subgraphProgressState.exists).toBe(true)
|
|
expect(subgraphProgressState.progress).toBeUndefined()
|
|
}).toPass({ timeout: 5_000 })
|
|
})
|
|
}
|
|
)
|