mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 15:59:47 +00:00
[Test] Add integration test: LGraph snapshot (#591)
- Runs basic Litegraph init before performing the snapshot - Allows a significantly more useful verification of the public API
This commit is contained in:
@@ -2,14 +2,19 @@ import { test as baseTest } from "vitest"
|
||||
import type { ISerialisedGraph, SerialisableGraph } from "../src/types/serialisation"
|
||||
import { LGraph } from "@/LGraph"
|
||||
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
|
||||
import { LiteGraph } from "@/litegraph"
|
||||
|
||||
interface LitegraphFixtures {
|
||||
minimalGraph: LGraph
|
||||
minimalSerialisableGraph: SerialisableGraph
|
||||
basicSerialisableGraph: SerialisableGraph
|
||||
oldSchemaGraph: ISerialisedGraph
|
||||
}
|
||||
|
||||
/** These fixtures alter global state, and are difficult to reset. Relies on a single test per-file to reset state. */
|
||||
interface DirtyFixtures {
|
||||
basicSerialisableGraph: SerialisableGraph
|
||||
}
|
||||
|
||||
export const test = baseTest.extend<LitegraphFixtures>({
|
||||
minimalGraph: async ({ }, use) => {
|
||||
// Before each test function
|
||||
@@ -18,10 +23,21 @@ export const test = baseTest.extend<LitegraphFixtures>({
|
||||
|
||||
// use the fixture value
|
||||
await use(lGraph)
|
||||
|
||||
// After each test function
|
||||
},
|
||||
basicSerialisableGraph: structuredClone(basicSerialisableGraph),
|
||||
minimalSerialisableGraph: structuredClone(minimalSerialisableGraph),
|
||||
oldSchemaGraph: structuredClone(oldSchemaGraph),
|
||||
})
|
||||
|
||||
/** Test that use {@link DirtyFixtures}. One test per file. */
|
||||
export const dirtyTest = test.extend<DirtyFixtures>({
|
||||
basicSerialisableGraph: async ({}, use) => {
|
||||
if (!basicSerialisableGraph.nodes) throw new Error("Invalid test object")
|
||||
|
||||
// Register node types
|
||||
for (const node of basicSerialisableGraph.nodes) {
|
||||
LiteGraph.registerNodeType(node.type!, LiteGraph.LGraphNode)
|
||||
}
|
||||
|
||||
await use(structuredClone(basicSerialisableGraph))
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user