Road to No explicit any: Group 8 (part 8) test files (#8496)

## Summary

This PR removes unsafe type assertions ("as unknown as Type") from test
files and improves type safety across the codebase.

### Key Changes

#### Type Safety Improvements
- Removed improper `as unknown as Type` patterns from test files in
Group 8 part 8
- Replaced with proper TypeScript patterns using Pinia store testing
patterns
- Fixed parameter shadowing issue in typeGuardUtil.test.ts (constructor
→ nodeConstructor)
- Fixed stale mock values in useConflictDetection.test.ts using getter
functions
- Refactored useManagerState tests to follow proper Pinia store testing
patterns with createTestingPinia

### Files Changed

Test files (Group 8 part 8 - utils and manager composables):
- src/utils/typeGuardUtil.test.ts - Fixed parameter shadowing
- src/utils/graphTraversalUtil.test.ts - Removed unsafe type assertions
- src/utils/litegraphUtil.test.ts - Improved type handling
- src/workbench/extensions/manager/composables/useManagerState.test.ts -
Complete rewrite using Pinia testing patterns
-
src/workbench/extensions/manager/composables/useConflictDetection.test.ts
- Fixed stale mock values with getters
- src/workbench/extensions/manager/composables/useManagerQueue.test.ts -
Type safety improvements
-
src/workbench/extensions/manager/composables/nodePack/useMissingNodes.test.ts
- Removed unsafe casts
-
src/workbench/extensions/manager/composables/nodePack/usePacksSelection.test.ts
- Type improvements
-
src/workbench/extensions/manager/composables/nodePack/usePacksStatus.test.ts
- Type improvements
- src/workbench/extensions/manager/utils/versionUtil.test.ts - Type
safety fixes

Source files (minor type fixes):
- src/utils/fuseUtil.ts - Type improvements
- src/utils/linkFixer.ts - Type safety fixes
- src/utils/syncUtil.ts - Type improvements
-
src/workbench/extensions/manager/composables/nodePack/useWorkflowPacks.ts
- Type fix
-
src/workbench/extensions/manager/composables/useConflictAcknowledgment.ts
- Type fix

### Testing
- All TypeScript type checking passes (`pnpm typecheck`)
- All affected test files pass (`pnpm test:unit`)
- Linting passes without errors (`pnpm lint`)
- Code formatting applied (`pnpm format`)

Part of the "Road to No Explicit Any" initiative, cleaning up type
casting issues from branch `fix/remove-any-types-part8`.

### Previous PRs in this series:
- Part 2: #7401
- Part 3: #7935
- Part 4: #7970
- Part 5: #8064
- Part 6: #8083
- Part 7: #8092
- Part 8 Group 1: #8253
- Part 8 Group 2: #8258
- Part 8 Group 3: #8304
- Part 8 Group 4: #8314
- Part 8 Group 5: #8329
- Part 8 Group 6: #8344
- Part 8 Group 7: #8459
- Part 8 Group 8: #8496 (this PR)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8496-Road-to-No-explicit-any-Group-8-part-8-test-files-2f86d73d365081f3afdcf8d01fba81e1)
by [Unito](https://www.unito.io)

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Johnpaul Chiwetelu
2026-01-30 22:25:10 +01:00
committed by GitHub
parent 59c58379fe
commit a64c561a5f
15 changed files with 478 additions and 340 deletions

View File

@@ -26,10 +26,10 @@ describe('migrateWidgetsValues', () => {
}
}
const widgets: IWidget[] = [
const widgets = [
{ name: 'normalInput', type: 'number' },
{ name: 'anotherNormal', type: 'number' }
] as unknown as IWidget[]
] as Partial<IWidget>[] as IWidget[]
const widgetValues = [42, 'dummy value', 3.14]
@@ -56,7 +56,7 @@ describe('migrateWidgetsValues', () => {
it('should handle empty widgets and values', () => {
const inputDefs: Record<string, InputSpec> = {}
const widgets: IWidget[] = []
const widgetValues: any[] = []
const widgetValues: unknown[] = []
const result = migrateWidgetsValues(inputDefs, widgets, widgetValues)
expect(result).toEqual([])
@@ -79,10 +79,10 @@ describe('migrateWidgetsValues', () => {
}
}
const widgets: IWidget[] = [
const widgets = [
{ name: 'first', type: 'number' },
{ name: 'last', type: 'number' }
] as unknown as IWidget[]
] as Partial<IWidget>[] as IWidget[]
const widgetValues = ['first value', 'dummy', 'last value']
@@ -93,7 +93,8 @@ describe('migrateWidgetsValues', () => {
describe('compressWidgetInputSlots', () => {
it('should remove unconnected widget input slots', () => {
const graph: ISerialisedGraph = {
// Using partial mock - only including properties needed for test
const graph = {
nodes: [
{
id: 1,
@@ -112,7 +113,7 @@ describe('compressWidgetInputSlots', () => {
}
],
links: [[2, 1, 0, 1, 0, 'INT']]
} as unknown as ISerialisedGraph
} as Partial<ISerialisedGraph> as ISerialisedGraph
compressWidgetInputSlots(graph)
@@ -122,7 +123,7 @@ describe('compressWidgetInputSlots', () => {
})
it('should update link target slots correctly', () => {
const graph: ISerialisedGraph = {
const graph = {
nodes: [
{
id: 1,
@@ -144,7 +145,7 @@ describe('compressWidgetInputSlots', () => {
[2, 1, 0, 1, 1, 'INT'],
[3, 1, 0, 1, 2, 'INT']
]
} as unknown as ISerialisedGraph
} as Partial<ISerialisedGraph> as ISerialisedGraph
compressWidgetInputSlots(graph)
@@ -160,10 +161,11 @@ describe('compressWidgetInputSlots', () => {
})
it('should handle graphs with no nodes gracefully', () => {
const graph: ISerialisedGraph = {
// Using partial mock - only including properties needed for test
const graph = {
nodes: [],
links: []
} as unknown as ISerialisedGraph
} as Partial<ISerialisedGraph> as ISerialisedGraph
compressWidgetInputSlots(graph)