mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary - Convert `fromAny` → `fromPartial` in 7 test files where object literals or interfaces are passed - `fromPartial` type-checks the provided fields, unlike `fromAny` which bypasses all checking (same as `as unknown as`) - Class-based types (`LGraphNode`, `LGraph`) remain `fromAny` due to shoehorn's `PartialDeep` incompatibility with class constructors ## Changes - **Pure conversions** (all `fromAny` → `fromPartial`): `domWidgetZIndex`, `matchPromotedInput`, `promotionUtils`, `subgraphNavigationStore` - **Mixed** (some converted, some kept): `promotedWidgetView`, `widgetUtil` - **Cleanup**: `nodeOutputStore` type param normalization Follows up on #10761. ## Test plan - [x] `pnpm typecheck` passes - [x] `pnpm vitest run` on all 7 changed files — 169 tests pass - [x] `pnpm lint` passes ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10788-test-migrate-fromAny-to-fromPartial-for-type-checked-test-mocks-3356d73d365081f7bf61d48a47af530c) by [Unito](https://www.unito.io)
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { fromPartial } from '@total-typescript/shoehorn'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph'
|
|
import { getDomWidgetZIndex } from './domWidgetZIndex'
|
|
|
|
describe('getDomWidgetZIndex', () => {
|
|
it('follows graph node ordering when node.order is stale', () => {
|
|
const graph = new LGraph()
|
|
const first = new LGraphNode('first')
|
|
const second = new LGraphNode('second')
|
|
graph.add(first)
|
|
graph.add(second)
|
|
|
|
first.order = 0
|
|
second.order = 1
|
|
|
|
const nodes = fromPartial<{ _nodes: LGraphNode[] }>(graph)._nodes
|
|
nodes.splice(nodes.indexOf(first), 1)
|
|
nodes.push(first)
|
|
|
|
expect(first.order).toBe(0)
|
|
expect(second.order).toBe(1)
|
|
|
|
expect(getDomWidgetZIndex(first, graph)).toBe(1)
|
|
expect(getDomWidgetZIndex(second, graph)).toBe(0)
|
|
})
|
|
|
|
it('falls back to node.order when node is not in current graph', () => {
|
|
const graph = new LGraph()
|
|
const node = new LGraphNode('orphan')
|
|
node.order = 7
|
|
|
|
expect(getDomWidgetZIndex(node, graph)).toBe(7)
|
|
expect(getDomWidgetZIndex(node, undefined)).toBe(7)
|
|
})
|
|
})
|