mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +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>
171 lines
5.6 KiB
TypeScript
171 lines
5.6 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { SubgraphHelper } from '@e2e/fixtures/helpers/SubgraphHelper'
|
|
import { getPromotedWidgetNames } from '@e2e/helpers/promotedWidgets'
|
|
|
|
const DOM_WIDGET_SELECTOR = '.comfy-multiline-input'
|
|
const VISIBLE_DOM_WIDGET_SELECTOR = `${DOM_WIDGET_SELECTOR}:visible`
|
|
const TEST_WIDGET_CONTENT = 'Test content that should persist'
|
|
|
|
async function openSubgraphById(comfyPage: ComfyPage, nodeId: string) {
|
|
await comfyPage.page.evaluate((targetNodeId) => {
|
|
const node = window.app!.rootGraph.nodes.find(
|
|
(candidate) => String(candidate.id) === targetNodeId
|
|
)
|
|
if (!node || !('subgraph' in node) || !node.subgraph) {
|
|
throw new Error(`Subgraph node ${targetNodeId} not found`)
|
|
}
|
|
|
|
window.app!.canvas.openSubgraph(node.subgraph, node)
|
|
}, nodeId)
|
|
|
|
await expect
|
|
.poll(
|
|
() =>
|
|
comfyPage.page.evaluate(() => {
|
|
const graph = window.app!.canvas.graph
|
|
return !!graph && 'inputNode' in graph
|
|
}),
|
|
{ timeout: 5_000 }
|
|
)
|
|
.toBe(true)
|
|
}
|
|
|
|
test.describe('Subgraph Promotion DOM', { tag: ['@subgraph'] }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', false)
|
|
})
|
|
|
|
test('Promoted seed widget renders in node body, not header', async ({
|
|
comfyPage
|
|
}) => {
|
|
const subgraphNode =
|
|
await comfyPage.subgraph.convertDefaultKSamplerToSubgraph()
|
|
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
|
|
const subgraphNodeId = String(subgraphNode.id)
|
|
const promotedNames = await getPromotedWidgetNames(
|
|
comfyPage,
|
|
subgraphNodeId
|
|
)
|
|
expect(promotedNames).toContain('seed')
|
|
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
|
|
const nodeLocator = comfyPage.vueNodes.getNodeLocator(subgraphNodeId)
|
|
await expect(nodeLocator).toBeVisible()
|
|
|
|
const seedWidget = nodeLocator.getByLabel('seed', { exact: true }).first()
|
|
await expect(seedWidget).toBeVisible()
|
|
|
|
await SubgraphHelper.expectWidgetBelowHeader(nodeLocator, seedWidget)
|
|
})
|
|
|
|
test.describe('DOM Widget Promotion', () => {
|
|
test('DOM widget stays visible and preserves content through subgraph navigation', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-promoted-text-widget'
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
const parentTextarea = comfyPage.page.locator(DOM_WIDGET_SELECTOR)
|
|
await expect(parentTextarea).toBeVisible()
|
|
await expect(parentTextarea).toHaveCount(1)
|
|
await parentTextarea.fill(TEST_WIDGET_CONTENT)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
expect(await subgraphNode.exists()).toBe(true)
|
|
|
|
await openSubgraphById(comfyPage, '11')
|
|
|
|
const subgraphTextarea = comfyPage.page.locator(DOM_WIDGET_SELECTOR)
|
|
await expect(subgraphTextarea).toBeVisible()
|
|
await expect(subgraphTextarea).toHaveCount(1)
|
|
|
|
await expect(subgraphTextarea).toHaveValue(TEST_WIDGET_CONTENT)
|
|
|
|
await comfyPage.page.keyboard.press('Escape')
|
|
await comfyPage.nextFrame()
|
|
|
|
const backToParentTextarea = comfyPage.page.locator(DOM_WIDGET_SELECTOR)
|
|
await expect(backToParentTextarea).toBeVisible()
|
|
await expect(backToParentTextarea).toHaveCount(1)
|
|
await expect(backToParentTextarea).toHaveValue(TEST_WIDGET_CONTENT)
|
|
})
|
|
|
|
test('DOM elements are cleaned up when subgraph node is removed', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-promoted-text-widget'
|
|
)
|
|
|
|
await expect(comfyPage.page.locator(DOM_WIDGET_SELECTOR)).toHaveCount(1)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
await subgraphNode.delete()
|
|
|
|
await expect(comfyPage.page.locator(DOM_WIDGET_SELECTOR)).toHaveCount(0)
|
|
})
|
|
|
|
test('DOM elements are cleaned up when widget is disconnected from I/O', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-promoted-text-widget'
|
|
)
|
|
|
|
await expect(comfyPage.page.locator(DOM_WIDGET_SELECTOR)).toHaveCount(1)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
expect(await subgraphNode.exists()).toBe(true)
|
|
|
|
await openSubgraphById(comfyPage, '11')
|
|
|
|
await comfyPage.subgraph.removeSlot('input', 'text')
|
|
|
|
await comfyPage.subgraph.exitViaBreadcrumb()
|
|
|
|
await expect(
|
|
comfyPage.page.locator(VISIBLE_DOM_WIDGET_SELECTOR)
|
|
).toHaveCount(0)
|
|
})
|
|
|
|
test('Multiple promoted widgets are handled correctly', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow(
|
|
'subgraphs/subgraph-with-multiple-promoted-widgets'
|
|
)
|
|
|
|
const parentCount = await comfyPage.page
|
|
.locator(VISIBLE_DOM_WIDGET_SELECTOR)
|
|
.count()
|
|
expect(parentCount).toBeGreaterThan(1)
|
|
|
|
const subgraphNode = await comfyPage.nodeOps.getNodeRefById('11')
|
|
expect(await subgraphNode.exists()).toBe(true)
|
|
|
|
await openSubgraphById(comfyPage, '11')
|
|
|
|
await expect(
|
|
comfyPage.page.locator(VISIBLE_DOM_WIDGET_SELECTOR)
|
|
).toHaveCount(parentCount)
|
|
|
|
await comfyPage.subgraph.exitViaBreadcrumb()
|
|
|
|
await expect(
|
|
comfyPage.page.locator(VISIBLE_DOM_WIDGET_SELECTOR)
|
|
).toHaveCount(parentCount)
|
|
})
|
|
})
|
|
})
|