Files
ComfyUI_frontend/src/core/graph/subgraph/widgetRenderKey.test.ts
Alexander Brown 49bec80f12 [backport core/1.41] fix: stabilize subgraph promoted widget identity and rendering (#9928)
## Summary
- Backport of #9896 to `core/1.41` via cherry-pick of merge commit
`74a48ab2aa6de160ca38496c843a19a8fcf0f77b`
- Resolved conflicts in:
  - `src/composables/graph/useGraphNodeManager.test.ts`
  - `src/lib/litegraph/src/subgraph/SubgraphNode.ts`
  - `src/renderer/extensions/vueNodes/components/NodeWidgets.vue`
- Applied `core/1.41` compatibility resolution for non-obvious conflict:
retained identity/render-key stabilization while keeping
execution-error-only widget error detection (no missing-model-store
dependency introduced)

## Testing
- `pnpm exec vitest run
src/composables/graph/useGraphNodeManager.test.ts
src/lib/litegraph/src/subgraph/SubgraphNode.test.ts
src/renderer/extensions/vueNodes/components/NodeWidgets.test.ts`
- `pnpm typecheck`

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9928-backport-core-1-41-fix-stabilize-subgraph-promoted-widget-identity-and-rendering-3236d73d365081f5a0a8e3d549b2e19b)
by [Unito](https://www.unito.io)

Co-authored-by: Amp <amp@ampcode.com>
2026-03-14 15:42:33 -07:00

35 lines
945 B
TypeScript

import { describe, expect, it } from 'vitest'
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import { getStableWidgetRenderKey } from './widgetRenderKey'
function createWidget(overrides: Partial<IBaseWidget> = {}): IBaseWidget {
return {
name: 'seed',
type: 'number',
...overrides
} as IBaseWidget
}
describe(getStableWidgetRenderKey, () => {
it('returns a stable key for the same widget instance', () => {
const widget = createWidget()
const first = getStableWidgetRenderKey(widget)
const second = getStableWidgetRenderKey(widget)
expect(second).toBe(first)
})
it('returns distinct keys for distinct widget instances', () => {
const firstWidget = createWidget()
const secondWidget = createWidget()
const firstKey = getStableWidgetRenderKey(firstWidget)
const secondKey = getStableWidgetRenderKey(secondWidget)
expect(secondKey).not.toBe(firstKey)
})
})