[Test] Add unit tests - complex floating links & nodes (#796)

This commit is contained in:
filtered
2025-03-17 13:25:57 +11:00
committed by GitHub
parent c1f9745e54
commit 39a9799db7
4 changed files with 429 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { test as baseTest } from "vitest"
import { LGraph } from "@/LGraph"
import { LiteGraph } from "@/litegraph"
import floatingBranch from "./assets/floatingBranch.json"
import floatingLink from "./assets/floatingLink.json"
import linkedNodes from "./assets/linkedNodes.json"
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
@@ -15,6 +16,8 @@ interface LitegraphFixtures {
oldSchemaGraph: ISerialisedGraph
floatingLinkGraph: ISerialisedGraph
linkedNodesGraph: ISerialisedGraph
floatingBranchSerialisedGraph: ISerialisedGraph
floatingBranchGraph: LGraph
}
/** These fixtures alter global state, and are difficult to reset. Relies on a single test per-file to reset state. */
@@ -35,6 +38,12 @@ export const test = baseTest.extend<LitegraphFixtures>({
oldSchemaGraph: structuredClone(oldSchemaGraph),
floatingLinkGraph: structuredClone(floatingLink as unknown as ISerialisedGraph),
linkedNodesGraph: structuredClone(linkedNodes as unknown as ISerialisedGraph),
floatingBranchSerialisedGraph: structuredClone(floatingBranch as unknown as ISerialisedGraph),
floatingBranchGraph: async ({ floatingBranchSerialisedGraph }, use) => {
const cloned = structuredClone(floatingBranchSerialisedGraph)
const graph = new LGraph(cloned)
await use(graph)
},
})
/** Test that use {@link DirtyFixtures}. One test per file. */