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>
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
|
|
type PromotedWidgetEntry = [string, string]
|
|
|
|
function isPromotedWidgetEntry(entry: unknown): entry is PromotedWidgetEntry {
|
|
return (
|
|
Array.isArray(entry) &&
|
|
entry.length === 2 &&
|
|
typeof entry[0] === 'string' &&
|
|
typeof entry[1] === 'string'
|
|
)
|
|
}
|
|
|
|
function normalizePromotedWidgets(value: unknown): PromotedWidgetEntry[] {
|
|
if (!Array.isArray(value)) return []
|
|
return value.filter(isPromotedWidgetEntry)
|
|
}
|
|
|
|
export async function getPromotedWidgets(
|
|
comfyPage: ComfyPage,
|
|
nodeId: string
|
|
): Promise<PromotedWidgetEntry[]> {
|
|
const raw = await comfyPage.page.evaluate((id) => {
|
|
const node = window.app!.canvas.graph!.getNodeById(id)
|
|
return node?.properties?.proxyWidgets ?? []
|
|
}, nodeId)
|
|
|
|
return normalizePromotedWidgets(raw)
|
|
}
|
|
|
|
export async function getPromotedWidgetNames(
|
|
comfyPage: ComfyPage,
|
|
nodeId: string
|
|
): Promise<string[]> {
|
|
const promotedWidgets = await getPromotedWidgets(comfyPage, nodeId)
|
|
return promotedWidgets.map(([, widgetName]) => widgetName)
|
|
}
|
|
|
|
export async function getPromotedWidgetCount(
|
|
comfyPage: ComfyPage,
|
|
nodeId: string
|
|
): Promise<number> {
|
|
const promotedWidgets = await getPromotedWidgets(comfyPage, nodeId)
|
|
return promotedWidgets.length
|
|
}
|
|
|
|
function isPseudoPreviewEntry(entry: PromotedWidgetEntry): boolean {
|
|
return entry[1].startsWith('$$')
|
|
}
|
|
|
|
export async function getPseudoPreviewWidgets(
|
|
comfyPage: ComfyPage,
|
|
nodeId: string
|
|
): Promise<PromotedWidgetEntry[]> {
|
|
const widgets = await getPromotedWidgets(comfyPage, nodeId)
|
|
return widgets.filter(isPseudoPreviewEntry)
|
|
}
|
|
|
|
export async function getPromotedWidgetCountByName(
|
|
comfyPage: ComfyPage,
|
|
nodeId: string,
|
|
widgetName: string
|
|
): Promise<number> {
|
|
return comfyPage.page.evaluate(
|
|
([id, name]) => {
|
|
const node = window.app!.canvas.graph!.getNodeById(id)
|
|
const widgets = node?.widgets ?? []
|
|
return widgets.filter((widget) => widget.name === name).length
|
|
},
|
|
[nodeId, widgetName] as const
|
|
)
|
|
}
|