Comfy-Org / Comfy-Org/ComfyUI_frontend
test(SubgraphNode): assert _subgraphSlot references are updated (not stale) after subgraph reconfigure
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Follow-up from PR #10187
**Requested by:** @christian-byrne
**Related comment:** https://github.com/Comfy-Org/ComfyUI_frontend/pull/10187#discussion_r2947987091
### Background
PR #10187 adds tests under the `'Nested SubgraphNode duplicate input prevention'` describe block in `src/lib/litegraph/src/subgraph/SubgraphNode.test.ts`. The first test currently only asserts that `_subgraphSlot` is truthy after a reconfigure cycle. It does not verify that the reference was actually updated to the *new* `SubgraphInput` object created during `_configureSubgraph`.
### Improvement
Strengthen the regression test by:
1. Capturing the `_subgraphSlot` references on each input **before** calling `subgraph.configure(serialized)`.
2. After reconfigure, asserting that:
- The `id` of each slot remains the same (identity preserved).
- The object reference itself has **changed** (i.e., the listener was rebound to the new `SubgraphInput` instance, not keeping the stale one).
This would catch a regression where the fix in `SubgraphNode.ts` reverts or the listener rebinding via `_addSubgraphInputListeners` stops working, leaving stale `SubgraphInput` references even though no duplicates are added.
### Suggested assertion shape
```ts
const slotsBefore = node.inputs.map((i) => i._subgraphSlot)
const idsBefore = slotsBefore.map((s) => s?.id)
const serialized = subgraph.asSerialisable()
subgraph.configure(serialized)
const slotsAfter = node.inputs.map((i) => i._subgraphSlot)
// IDs must be preserved
expect(slotsAfter.map((s) => s?.id)).toEqual(idsBefore)
// But references must have changed (rebound to new SubgraphInput objects)
for (let i = 0; i < slotsBefore.length; i++) {
expect(slotsAfter[i]).not.toBe(slotsBefore[i])
}
```
### File
`src/lib/litegraph/src/subgraph/SubgraphNode.test.ts` — `'Nested SubgraphNode duplicate input prevention'` describe block, first test case.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10194-test-SubgraphNode-assert-_subgraphSlot-references-are-updated-not-stale-after-sub-3266d73d365081d3b227dda2ba5990b6) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.