mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 05:32:02 +00:00
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>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { fromAny, fromPartial } from '@total-typescript/shoehorn'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
@@ -58,16 +59,16 @@ function mockNode(
|
||||
type: string,
|
||||
overrides: Partial<LGraphNode> = {}
|
||||
): LGraphNode {
|
||||
return {
|
||||
return fromAny<LGraphNode, unknown>({
|
||||
id,
|
||||
type,
|
||||
last_serialization: { type },
|
||||
...overrides
|
||||
} as unknown as LGraphNode
|
||||
})
|
||||
}
|
||||
|
||||
function mockGraph(): LGraph {
|
||||
return {} as unknown as LGraph
|
||||
return fromAny<LGraph, unknown>({})
|
||||
}
|
||||
|
||||
function getMissingNodesError(
|
||||
@@ -216,9 +217,9 @@ describe('scanMissingNodes (via rescanAndSurfaceMissingNodes)', () => {
|
||||
|
||||
it('uses last_serialization.type over node.type', () => {
|
||||
const node = mockNode(1, 'LiveType')
|
||||
node.last_serialization = {
|
||||
node.last_serialization = fromPartial<LGraphNode['last_serialization']>({
|
||||
type: 'OriginalType'
|
||||
} as unknown as LGraphNode['last_serialization']
|
||||
})
|
||||
vi.mocked(collectAllNodes).mockReturnValue([node])
|
||||
vi.mocked(getExecutionIdByNode).mockReturnValue(null)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user