Files
ComfyUI_frontend/src/components/graph/widgets/domWidgetZIndex.test.ts
Alexander Brown 661e3d7949 test: migrate as unknown as to @total-typescript/shoehorn (#10761)
*PR Created by the Glary-Bot Agent*

---

## Summary

- Replace all `as unknown as Type` assertions in 59 unit test files with
type-safe `@total-typescript/shoehorn` functions
- Use `fromPartial<Type>()` for partial mock objects where deep-partial
type-checks (21 files)
- Use `fromAny<Type>()` for fundamentally incompatible types: null,
undefined, primitives, variables, class expressions, and mocks with
test-specific extra properties that `PartialDeepObject` rejects
(remaining files)
- All explicit type parameters preserved so TypeScript return types are
correct
- Browser test `.spec.ts` files excluded (shoehorn unavailable in
`page.evaluate` browser context)

## Verification

- `pnpm typecheck` 
- `pnpm lint` 
- `pnpm format` 
- Pre-commit hooks passed (format + oxlint + eslint + typecheck)
- Migrated test files verified passing (ran representative subset)
- No test behavior changes — only type assertion syntax changed
- No UI changes — screenshots not applicable

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10761-test-migrate-as-unknown-as-to-total-typescript-shoehorn-3336d73d365081f6b8adc44db5dcc380)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com>
Co-authored-by: Amp <amp@ampcode.com>
2026-03-30 19:20:18 -07:00

38 lines
1.1 KiB
TypeScript

import { fromAny } 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 = fromAny<{ _nodes: LGraphNode[] }, unknown>(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)
})
})