Files
ComfyUI_frontend/browser_tests/helpers/subgraphTestUtils.ts
Alexander Brown 4b9c32d326 [backport core/1.41] fix: subgraph promoted widget input label rename (#10412)
Backport of #10195 to `core/1.41`.

## Summary

- Fix widget-input slot positioning for promoted subgraph inputs in both
LiteGraph and Vue rendering modes
- Sync `input.widget.name` with display name on label rename and initial
setup
- `_arrangeWidgetInputSlots` rewrite iterates `_concreteInputs` directly
- Add `promotedLabel` field to `SafeWidgetData` for correct label
display after rename

## Conflicts resolved

- `useGraphNodeManager.ts`: Added `tooltip` and `promotedLabel` fields
without `sourceExecutionId` (not on target branch)
- `SubgraphNode.ts`: Kept PR's comment about not changing
`input.widget.name`, deduplicated `_invalidatePromotedViewsCache()` call
- `NodeWidgets.vue`: Applied `widget.promotedLabel ??
widgetState?.label` without `linkedUpstream` (not on target branch)
- `widgetUtil.test.ts`: Took PR version with new `_subgraphSlot.label`
test case

Fixes #9998

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10412-backport-core-1-41-fix-subgraph-promoted-widget-input-label-rename-32d6d73d365081c7919ffaf5d37a8478)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Arthur R Longbottom <art.longbottom.jr@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jaeone94 <jaeone.prt@gmail.com>
2026-03-23 18:05:08 -07:00

46 lines
1.4 KiB
TypeScript

import type { Page } from '@playwright/test'
import type { LGraph, Subgraph } from '../../src/lib/litegraph/src/litegraph'
import { isSubgraph } from '../../src/utils/typeGuardUtil'
/**
* Assertion helper for tests where being in a subgraph is a precondition.
* Throws a clear error if the graph is not a Subgraph.
*/
export function assertSubgraph(
graph: LGraph | Subgraph | null | undefined
): asserts graph is Subgraph {
if (!isSubgraph(graph)) {
throw new Error(
'Expected to be in a subgraph context, but graph is not a Subgraph'
)
}
}
/**
* Returns the widget-input slot Y position and the node title height
* for the promoted "text" input on the SubgraphNode.
*
* The slot Y should be at the widget row, not the header. A value near
* zero or negative indicates the slot is positioned at the header (the bug).
*/
export function getTextSlotPosition(page: Page, nodeId: string) {
return page.evaluate((id) => {
const node = window.app!.canvas.graph!.getNodeById(id)
if (!node) return null
const titleHeight = window.LiteGraph!.NODE_TITLE_HEIGHT
for (const input of node.inputs) {
if (!input.widget || input.type !== 'STRING') continue
return {
hasPos: !!input.pos,
posY: input.pos?.[1] ?? null,
widgetName: input.widget.name,
titleHeight
}
}
return null
}, nodeId)
}