Chore: Upgrade Vitest to v4 (#7797)

## Summary

https://vitest.dev/guide/migration.html#vitest-4

## Changes

- **What**: Update Vitest and some associated dependencies
- **What**: Fix issue with our existing mocks and mock types

## Review Focus

Double check the test updates. I tried to keep the changes minimal.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7797-Chore-Upgrade-Vitest-to-v4-2d96d73d3650810cbe3ac42d7bd6585a)
by [Unito](https://www.unito.io)

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Alexander Brown
2025-12-29 19:24:35 -08:00
committed by GitHub
parent 91ed58acc9
commit 3ae2b52649
22 changed files with 615 additions and 576 deletions

View File

@@ -1,21 +1,21 @@
// TODO: Fix these tests after migration
import { afterEach, describe, expect, vi } from 'vitest'
import type { LGraph, Reroute } from '@/lib/litegraph/src/litegraph'
import {
type CanvasPointerEvent,
LGraphNode,
LLink,
LinkConnector,
type RerouteId
import type {
LGraph,
Reroute,
CanvasPointerEvent,
RerouteId
} from '@/lib/litegraph/src/litegraph'
import { LGraphNode, LLink, LinkConnector } from '@/lib/litegraph/src/litegraph'
import { test as baseTest } from './fixtures/testExtensions'
import type { ConnectingLink } from '@/lib/litegraph/src/interfaces'
interface TestContext {
graph: LGraph
connector: LinkConnector
setConnectingLinks: ReturnType<typeof vi.fn>
setConnectingLinks: (value: ConnectingLink[]) => void
createTestNode: (id: number) => LGraphNode
reroutesBeforeTest: [rerouteId: RerouteId, reroute: Reroute][]
validateIntegrityNoChanges: () => void
@@ -41,9 +41,8 @@ const test = baseTest.extend<TestContext>({
await use(reroutesComplexGraph)
},
setConnectingLinks: async (
// eslint-disable-next-line no-empty-pattern
{},
use: (mock: ReturnType<typeof vi.fn>) => Promise<void>
use: (mock: (value: ConnectingLink[]) => void) => Promise<void>
) => {
const mock = vi.fn()
await use(mock)

View File

@@ -1,23 +1,26 @@
import { test as baseTest, describe, expect, vi } from 'vitest'
import { LinkConnector } from '@/lib/litegraph/src/litegraph'
import type { MovingInputLink } from '@/lib/litegraph/src/litegraph'
import { ToInputRenderLink } from '@/lib/litegraph/src/litegraph'
import type { LinkNetwork } from '@/lib/litegraph/src/litegraph'
import type { ISlotType } from '@/lib/litegraph/src/litegraph'
import type {
MovingInputLink,
RerouteId,
LinkNetwork,
ISlotType
} from '@/lib/litegraph/src/litegraph'
import {
LGraph,
LGraphNode,
LLink,
Reroute,
type RerouteId
LinkConnector,
ToInputRenderLink,
LinkDirection
} from '@/lib/litegraph/src/litegraph'
import { LinkDirection } from '@/lib/litegraph/src/litegraph'
import type { ConnectingLink } from '@/lib/litegraph/src/interfaces'
interface TestContext {
network: LinkNetwork & { add(node: LGraphNode): void }
connector: LinkConnector
setConnectingLinks: ReturnType<typeof vi.fn>
setConnectingLinks: (value: ConnectingLink[]) => void
createTestNode: (id: number, slotType?: ISlotType) => LGraphNode
createTestLink: (
id: number,
@@ -28,7 +31,6 @@ interface TestContext {
}
const test = baseTest.extend<TestContext>({
// eslint-disable-next-line no-empty-pattern
network: async ({}, use) => {
const graph = new LGraph()
const floatingLinks = new Map<number, LLink>()
@@ -53,9 +55,8 @@ const test = baseTest.extend<TestContext>({
},
setConnectingLinks: async (
// eslint-disable-next-line no-empty-pattern
{},
use: (mock: ReturnType<typeof vi.fn>) => Promise<void>
use: (mock: (value: ConnectingLink[]) => void) => Promise<void>
) => {
const mock = vi.fn()
await use(mock)