mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +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:
15
test/ConfigureGraph.test.ts
Normal file
15
test/ConfigureGraph.test.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { describe } from "vitest"
|
||||||
|
import { LGraph } from "@/litegraph"
|
||||||
|
import { dirtyTest } from "./testExtensions"
|
||||||
|
|
||||||
|
describe("LGraph configure()", () => {
|
||||||
|
dirtyTest("LGraph matches previous snapshot (normal configure() usage)", ({ expect, minimalSerialisableGraph, basicSerialisableGraph }) => {
|
||||||
|
const configuredMinGraph = new LGraph()
|
||||||
|
configuredMinGraph.configure(minimalSerialisableGraph)
|
||||||
|
expect(configuredMinGraph).toMatchSnapshot("configuredMinGraph")
|
||||||
|
|
||||||
|
const configuredBasicGraph = new LGraph()
|
||||||
|
configuredBasicGraph.configure(basicSerialisableGraph)
|
||||||
|
expect(configuredBasicGraph).toMatchSnapshot("configuredBasicGraph")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -2,7 +2,7 @@ import { describe } from "vitest"
|
|||||||
import { LGraph, LiteGraph } from "@/litegraph"
|
import { LGraph, LiteGraph } from "@/litegraph"
|
||||||
import { test } from "./testExtensions"
|
import { test } from "./testExtensions"
|
||||||
|
|
||||||
describe.concurrent("LGraph", () => {
|
describe("LGraph", () => {
|
||||||
test("can be instantiated", ({ expect }) => {
|
test("can be instantiated", ({ expect }) => {
|
||||||
// @ts-expect-error Intentional - extra holds any / all consumer data that should be serialised
|
// @ts-expect-error Intentional - extra holds any / all consumer data that should be serialised
|
||||||
const graph = new LGraph({ extra: "TestGraph" })
|
const graph = new LGraph({ extra: "TestGraph" })
|
||||||
@@ -11,6 +11,14 @@ describe.concurrent("LGraph", () => {
|
|||||||
expect(graph.extra).toBe("TestGraph")
|
expect(graph.extra).toBe("TestGraph")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("is exactly the same type", async ({ expect }) => {
|
||||||
|
const directImport = await import("@/LGraph")
|
||||||
|
const entryPointImport = await import("@/litegraph")
|
||||||
|
|
||||||
|
expect(LiteGraph.LGraph).toBe(directImport.LGraph)
|
||||||
|
expect(LiteGraph.LGraph).toBe(entryPointImport.LGraph)
|
||||||
|
})
|
||||||
|
|
||||||
test("populates optional values", ({ expect, minimalSerialisableGraph }) => {
|
test("populates optional values", ({ expect, minimalSerialisableGraph }) => {
|
||||||
const dGraph = new LGraph(minimalSerialisableGraph)
|
const dGraph = new LGraph(minimalSerialisableGraph)
|
||||||
expect(dGraph.links).toBeInstanceOf(Map)
|
expect(dGraph.links).toBeInstanceOf(Map)
|
||||||
@@ -18,20 +26,13 @@ describe.concurrent("LGraph", () => {
|
|||||||
expect(dGraph.groups).toBeInstanceOf(Array)
|
expect(dGraph.groups).toBeInstanceOf(Array)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("matches previous snapshot", ({ expect, minimalSerialisableGraph, basicSerialisableGraph }) => {
|
|
||||||
const minLGraph = new LGraph(minimalSerialisableGraph)
|
|
||||||
expect(minLGraph).toMatchSnapshot("minLGraph")
|
|
||||||
const basicLGraph = new LGraph(basicSerialisableGraph)
|
|
||||||
expect(basicLGraph).toMatchSnapshot("basicLGraph")
|
|
||||||
})
|
|
||||||
|
|
||||||
test("supports schema v0.4 graphs", ({ expect, oldSchemaGraph }) => {
|
test("supports schema v0.4 graphs", ({ expect, oldSchemaGraph }) => {
|
||||||
const fromOldSchema = new LGraph(oldSchemaGraph)
|
const fromOldSchema = new LGraph(oldSchemaGraph)
|
||||||
expect(fromOldSchema).toMatchSnapshot("oldSchemaGraph")
|
expect(fromOldSchema).toMatchSnapshot("oldSchemaGraph")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.concurrent("Legacy LGraph Compatibility Layer", () => {
|
describe("Legacy LGraph Compatibility Layer", () => {
|
||||||
test("can be extended via prototype", ({ expect, minimalGraph }) => {
|
test("can be extended via prototype", ({ expect, minimalGraph }) => {
|
||||||
// @ts-expect-error Should always be an error.
|
// @ts-expect-error Should always be an error.
|
||||||
LGraph.prototype.newMethod = function () {
|
LGraph.prototype.newMethod = function () {
|
||||||
|
|||||||
13
test/LGraph_constructor.test.ts
Normal file
13
test/LGraph_constructor.test.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { describe } from "vitest"
|
||||||
|
import { LGraph } from "@/litegraph"
|
||||||
|
import { dirtyTest } from "./testExtensions"
|
||||||
|
|
||||||
|
describe("LGraph (constructor only)", () => {
|
||||||
|
dirtyTest("Matches previous snapshot", ({ expect, minimalSerialisableGraph, basicSerialisableGraph }) => {
|
||||||
|
const minLGraph = new LGraph(minimalSerialisableGraph)
|
||||||
|
expect(minLGraph).toMatchSnapshot("minLGraph")
|
||||||
|
|
||||||
|
const basicLGraph = new LGraph(basicSerialisableGraph)
|
||||||
|
expect(basicLGraph).toMatchSnapshot("basicLGraph")
|
||||||
|
})
|
||||||
|
})
|
||||||
315
test/__snapshots__/ConfigureGraph.test.ts.snap
Normal file
315
test/__snapshots__/ConfigureGraph.test.ts.snap
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
|
exports[`LGraph configure() > LGraph matches previous snapshot (normal configure() usage) > configuredBasicGraph 1`] = `
|
||||||
|
LGraph {
|
||||||
|
"_groups": [
|
||||||
|
LGraphGroup {
|
||||||
|
"_bounding": Float32Array [
|
||||||
|
20,
|
||||||
|
20,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
"_children": Set {},
|
||||||
|
"_nodes": [],
|
||||||
|
"_pos": Float32Array [
|
||||||
|
20,
|
||||||
|
20,
|
||||||
|
],
|
||||||
|
"_size": Float32Array [
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
"color": "#6029aa",
|
||||||
|
"flags": {},
|
||||||
|
"font": undefined,
|
||||||
|
"font_size": 14,
|
||||||
|
"graph": [Circular],
|
||||||
|
"id": 123,
|
||||||
|
"isPointInside": [Function],
|
||||||
|
"selected": undefined,
|
||||||
|
"setDirtyCanvas": [Function],
|
||||||
|
"title": "A group to test with",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_input_nodes": undefined,
|
||||||
|
"_last_trigger_time": undefined,
|
||||||
|
"_links": Map {},
|
||||||
|
"_nodes": [
|
||||||
|
LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_nodes_by_id": {
|
||||||
|
"1": LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"_nodes_executable": [],
|
||||||
|
"_nodes_in_order": [
|
||||||
|
LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_version": 3,
|
||||||
|
"catch_errors": true,
|
||||||
|
"config": {},
|
||||||
|
"elapsed_time": 0.01,
|
||||||
|
"errors_in_execution": undefined,
|
||||||
|
"execution_time": undefined,
|
||||||
|
"execution_timer_id": undefined,
|
||||||
|
"extra": {},
|
||||||
|
"filter": undefined,
|
||||||
|
"fixedtime": 0,
|
||||||
|
"fixedtime_lapse": 0.01,
|
||||||
|
"globaltime": 0,
|
||||||
|
"inputs": {},
|
||||||
|
"iteration": 0,
|
||||||
|
"last_update_time": 0,
|
||||||
|
"links": Map {},
|
||||||
|
"list_of_graphcanvas": null,
|
||||||
|
"nodes_actioning": [],
|
||||||
|
"nodes_executedAction": [],
|
||||||
|
"nodes_executing": [],
|
||||||
|
"outputs": {},
|
||||||
|
"runningtime": 0,
|
||||||
|
"starttime": 0,
|
||||||
|
"state": {
|
||||||
|
"lastGroupId": 123,
|
||||||
|
"lastLinkId": 0,
|
||||||
|
"lastNodeId": 1,
|
||||||
|
"lastRerouteId": 0,
|
||||||
|
},
|
||||||
|
"status": 1,
|
||||||
|
"vars": {},
|
||||||
|
"version": 1,
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`LGraph configure() > LGraph matches previous snapshot (normal configure() usage) > configuredMinGraph 1`] = `
|
||||||
|
LGraph {
|
||||||
|
"_groups": [],
|
||||||
|
"_input_nodes": undefined,
|
||||||
|
"_last_trigger_time": undefined,
|
||||||
|
"_links": Map {},
|
||||||
|
"_nodes": [],
|
||||||
|
"_nodes_by_id": {},
|
||||||
|
"_nodes_executable": [],
|
||||||
|
"_nodes_in_order": [],
|
||||||
|
"_version": 0,
|
||||||
|
"catch_errors": true,
|
||||||
|
"config": {},
|
||||||
|
"elapsed_time": 0.01,
|
||||||
|
"errors_in_execution": undefined,
|
||||||
|
"execution_time": undefined,
|
||||||
|
"execution_timer_id": undefined,
|
||||||
|
"extra": {},
|
||||||
|
"filter": undefined,
|
||||||
|
"fixedtime": 0,
|
||||||
|
"fixedtime_lapse": 0.01,
|
||||||
|
"globaltime": 0,
|
||||||
|
"inputs": {},
|
||||||
|
"iteration": 0,
|
||||||
|
"last_update_time": 0,
|
||||||
|
"links": Map {},
|
||||||
|
"list_of_graphcanvas": null,
|
||||||
|
"nodes_actioning": [],
|
||||||
|
"nodes_executedAction": [],
|
||||||
|
"nodes_executing": [],
|
||||||
|
"outputs": {},
|
||||||
|
"runningtime": 0,
|
||||||
|
"starttime": 0,
|
||||||
|
"state": {
|
||||||
|
"lastGroupId": 0,
|
||||||
|
"lastLinkId": 0,
|
||||||
|
"lastNodeId": 0,
|
||||||
|
"lastRerouteId": 0,
|
||||||
|
},
|
||||||
|
"status": 1,
|
||||||
|
"vars": {},
|
||||||
|
"version": 1,
|
||||||
|
}
|
||||||
|
`;
|
||||||
@@ -1,325 +1,5 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`LGraph > matches previous snapshot > basicLGraph 1`] = `
|
|
||||||
LGraph {
|
|
||||||
"_groups": [
|
|
||||||
LGraphGroup {
|
|
||||||
"_bounding": Float32Array [
|
|
||||||
20,
|
|
||||||
20,
|
|
||||||
1,
|
|
||||||
3,
|
|
||||||
],
|
|
||||||
"_children": Set {},
|
|
||||||
"_nodes": [],
|
|
||||||
"_pos": Float32Array [
|
|
||||||
20,
|
|
||||||
20,
|
|
||||||
],
|
|
||||||
"_size": Float32Array [
|
|
||||||
1,
|
|
||||||
3,
|
|
||||||
],
|
|
||||||
"color": "#6029aa",
|
|
||||||
"flags": {},
|
|
||||||
"font": undefined,
|
|
||||||
"font_size": 14,
|
|
||||||
"graph": [Circular],
|
|
||||||
"id": 123,
|
|
||||||
"isPointInside": [Function],
|
|
||||||
"selected": undefined,
|
|
||||||
"setDirtyCanvas": [Function],
|
|
||||||
"title": "A group to test with",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"_input_nodes": undefined,
|
|
||||||
"_last_trigger_time": undefined,
|
|
||||||
"_links": Map {},
|
|
||||||
"_nodes": [
|
|
||||||
LGraphNode {
|
|
||||||
"_collapsed_width": undefined,
|
|
||||||
"_level": undefined,
|
|
||||||
"_pos": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
],
|
|
||||||
"_posSize": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"_relative_id": undefined,
|
|
||||||
"_shape": undefined,
|
|
||||||
"_size": Float32Array [
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"action_call": undefined,
|
|
||||||
"action_triggered": undefined,
|
|
||||||
"badgePosition": "top-left",
|
|
||||||
"badges": [],
|
|
||||||
"bgcolor": undefined,
|
|
||||||
"block_delete": undefined,
|
|
||||||
"boxcolor": undefined,
|
|
||||||
"clip_area": undefined,
|
|
||||||
"clonable": undefined,
|
|
||||||
"color": undefined,
|
|
||||||
"connections": [],
|
|
||||||
"console": undefined,
|
|
||||||
"exec_version": undefined,
|
|
||||||
"execute_triggered": undefined,
|
|
||||||
"flags": {},
|
|
||||||
"freeWidgetSpace": undefined,
|
|
||||||
"gotFocusAt": undefined,
|
|
||||||
"graph": [Circular],
|
|
||||||
"has_errors": true,
|
|
||||||
"id": 1,
|
|
||||||
"ignore_remove": undefined,
|
|
||||||
"inputs": [],
|
|
||||||
"last_serialization": {
|
|
||||||
"id": 1,
|
|
||||||
},
|
|
||||||
"locked": undefined,
|
|
||||||
"lostFocusAt": undefined,
|
|
||||||
"mode": undefined,
|
|
||||||
"mouseOver": undefined,
|
|
||||||
"optional_inputs": undefined,
|
|
||||||
"optional_outputs": undefined,
|
|
||||||
"order": 0,
|
|
||||||
"outputs": [],
|
|
||||||
"properties": {},
|
|
||||||
"properties_info": [],
|
|
||||||
"redraw_on_mouse": undefined,
|
|
||||||
"removable": undefined,
|
|
||||||
"resizable": undefined,
|
|
||||||
"selected": undefined,
|
|
||||||
"serialize_widgets": undefined,
|
|
||||||
"showAdvanced": undefined,
|
|
||||||
"title": undefined,
|
|
||||||
"type": null,
|
|
||||||
"widgets": undefined,
|
|
||||||
"widgets_start_y": undefined,
|
|
||||||
"widgets_up": undefined,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"_nodes_by_id": {
|
|
||||||
"1": LGraphNode {
|
|
||||||
"_collapsed_width": undefined,
|
|
||||||
"_level": undefined,
|
|
||||||
"_pos": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
],
|
|
||||||
"_posSize": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"_relative_id": undefined,
|
|
||||||
"_shape": undefined,
|
|
||||||
"_size": Float32Array [
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"action_call": undefined,
|
|
||||||
"action_triggered": undefined,
|
|
||||||
"badgePosition": "top-left",
|
|
||||||
"badges": [],
|
|
||||||
"bgcolor": undefined,
|
|
||||||
"block_delete": undefined,
|
|
||||||
"boxcolor": undefined,
|
|
||||||
"clip_area": undefined,
|
|
||||||
"clonable": undefined,
|
|
||||||
"color": undefined,
|
|
||||||
"connections": [],
|
|
||||||
"console": undefined,
|
|
||||||
"exec_version": undefined,
|
|
||||||
"execute_triggered": undefined,
|
|
||||||
"flags": {},
|
|
||||||
"freeWidgetSpace": undefined,
|
|
||||||
"gotFocusAt": undefined,
|
|
||||||
"graph": [Circular],
|
|
||||||
"has_errors": true,
|
|
||||||
"id": 1,
|
|
||||||
"ignore_remove": undefined,
|
|
||||||
"inputs": [],
|
|
||||||
"last_serialization": {
|
|
||||||
"id": 1,
|
|
||||||
},
|
|
||||||
"locked": undefined,
|
|
||||||
"lostFocusAt": undefined,
|
|
||||||
"mode": undefined,
|
|
||||||
"mouseOver": undefined,
|
|
||||||
"optional_inputs": undefined,
|
|
||||||
"optional_outputs": undefined,
|
|
||||||
"order": 0,
|
|
||||||
"outputs": [],
|
|
||||||
"properties": {},
|
|
||||||
"properties_info": [],
|
|
||||||
"redraw_on_mouse": undefined,
|
|
||||||
"removable": undefined,
|
|
||||||
"resizable": undefined,
|
|
||||||
"selected": undefined,
|
|
||||||
"serialize_widgets": undefined,
|
|
||||||
"showAdvanced": undefined,
|
|
||||||
"title": undefined,
|
|
||||||
"type": null,
|
|
||||||
"widgets": undefined,
|
|
||||||
"widgets_start_y": undefined,
|
|
||||||
"widgets_up": undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"_nodes_executable": [],
|
|
||||||
"_nodes_in_order": [
|
|
||||||
LGraphNode {
|
|
||||||
"_collapsed_width": undefined,
|
|
||||||
"_level": undefined,
|
|
||||||
"_pos": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
],
|
|
||||||
"_posSize": Float32Array [
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"_relative_id": undefined,
|
|
||||||
"_shape": undefined,
|
|
||||||
"_size": Float32Array [
|
|
||||||
140,
|
|
||||||
60,
|
|
||||||
],
|
|
||||||
"action_call": undefined,
|
|
||||||
"action_triggered": undefined,
|
|
||||||
"badgePosition": "top-left",
|
|
||||||
"badges": [],
|
|
||||||
"bgcolor": undefined,
|
|
||||||
"block_delete": undefined,
|
|
||||||
"boxcolor": undefined,
|
|
||||||
"clip_area": undefined,
|
|
||||||
"clonable": undefined,
|
|
||||||
"color": undefined,
|
|
||||||
"connections": [],
|
|
||||||
"console": undefined,
|
|
||||||
"exec_version": undefined,
|
|
||||||
"execute_triggered": undefined,
|
|
||||||
"flags": {},
|
|
||||||
"freeWidgetSpace": undefined,
|
|
||||||
"gotFocusAt": undefined,
|
|
||||||
"graph": [Circular],
|
|
||||||
"has_errors": true,
|
|
||||||
"id": 1,
|
|
||||||
"ignore_remove": undefined,
|
|
||||||
"inputs": [],
|
|
||||||
"last_serialization": {
|
|
||||||
"id": 1,
|
|
||||||
},
|
|
||||||
"locked": undefined,
|
|
||||||
"lostFocusAt": undefined,
|
|
||||||
"mode": undefined,
|
|
||||||
"mouseOver": undefined,
|
|
||||||
"optional_inputs": undefined,
|
|
||||||
"optional_outputs": undefined,
|
|
||||||
"order": 0,
|
|
||||||
"outputs": [],
|
|
||||||
"properties": {},
|
|
||||||
"properties_info": [],
|
|
||||||
"redraw_on_mouse": undefined,
|
|
||||||
"removable": undefined,
|
|
||||||
"resizable": undefined,
|
|
||||||
"selected": undefined,
|
|
||||||
"serialize_widgets": undefined,
|
|
||||||
"showAdvanced": undefined,
|
|
||||||
"title": undefined,
|
|
||||||
"type": null,
|
|
||||||
"widgets": undefined,
|
|
||||||
"widgets_start_y": undefined,
|
|
||||||
"widgets_up": undefined,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"_version": 3,
|
|
||||||
"catch_errors": true,
|
|
||||||
"config": {},
|
|
||||||
"elapsed_time": 0.01,
|
|
||||||
"errors_in_execution": undefined,
|
|
||||||
"execution_time": undefined,
|
|
||||||
"execution_timer_id": undefined,
|
|
||||||
"extra": {},
|
|
||||||
"filter": undefined,
|
|
||||||
"fixedtime": 0,
|
|
||||||
"fixedtime_lapse": 0.01,
|
|
||||||
"globaltime": 0,
|
|
||||||
"inputs": {},
|
|
||||||
"iteration": 0,
|
|
||||||
"last_update_time": 0,
|
|
||||||
"links": Map {},
|
|
||||||
"list_of_graphcanvas": null,
|
|
||||||
"nodes_actioning": [],
|
|
||||||
"nodes_executedAction": [],
|
|
||||||
"nodes_executing": [],
|
|
||||||
"outputs": {},
|
|
||||||
"runningtime": 0,
|
|
||||||
"starttime": 0,
|
|
||||||
"state": {
|
|
||||||
"lastGroupId": 123,
|
|
||||||
"lastLinkId": 0,
|
|
||||||
"lastNodeId": 1,
|
|
||||||
"lastRerouteId": 0,
|
|
||||||
},
|
|
||||||
"status": 1,
|
|
||||||
"vars": {},
|
|
||||||
"version": 1,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`LGraph > matches previous snapshot > minLGraph 1`] = `
|
|
||||||
LGraph {
|
|
||||||
"_groups": [],
|
|
||||||
"_input_nodes": undefined,
|
|
||||||
"_last_trigger_time": undefined,
|
|
||||||
"_links": Map {},
|
|
||||||
"_nodes": [],
|
|
||||||
"_nodes_by_id": {},
|
|
||||||
"_nodes_executable": [],
|
|
||||||
"_nodes_in_order": [],
|
|
||||||
"_version": 0,
|
|
||||||
"catch_errors": true,
|
|
||||||
"config": {},
|
|
||||||
"elapsed_time": 0.01,
|
|
||||||
"errors_in_execution": undefined,
|
|
||||||
"execution_time": undefined,
|
|
||||||
"execution_timer_id": undefined,
|
|
||||||
"extra": {},
|
|
||||||
"filter": undefined,
|
|
||||||
"fixedtime": 0,
|
|
||||||
"fixedtime_lapse": 0.01,
|
|
||||||
"globaltime": 0,
|
|
||||||
"inputs": {},
|
|
||||||
"iteration": 0,
|
|
||||||
"last_update_time": 0,
|
|
||||||
"links": Map {},
|
|
||||||
"list_of_graphcanvas": null,
|
|
||||||
"nodes_actioning": [],
|
|
||||||
"nodes_executedAction": [],
|
|
||||||
"nodes_executing": [],
|
|
||||||
"outputs": {},
|
|
||||||
"runningtime": 0,
|
|
||||||
"starttime": 0,
|
|
||||||
"state": {
|
|
||||||
"lastGroupId": 0,
|
|
||||||
"lastLinkId": 0,
|
|
||||||
"lastNodeId": 0,
|
|
||||||
"lastRerouteId": 0,
|
|
||||||
},
|
|
||||||
"status": 1,
|
|
||||||
"vars": {},
|
|
||||||
"version": 1,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`LGraph > supports schema v0.4 graphs > oldSchemaGraph 1`] = `
|
exports[`LGraph > supports schema v0.4 graphs > oldSchemaGraph 1`] = `
|
||||||
LGraph {
|
LGraph {
|
||||||
"_groups": [
|
"_groups": [
|
||||||
|
|||||||
315
test/__snapshots__/LGraph_constructor.test.ts.snap
Normal file
315
test/__snapshots__/LGraph_constructor.test.ts.snap
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
|
exports[`LGraph (constructor only) > Matches previous snapshot > basicLGraph 1`] = `
|
||||||
|
LGraph {
|
||||||
|
"_groups": [
|
||||||
|
LGraphGroup {
|
||||||
|
"_bounding": Float32Array [
|
||||||
|
20,
|
||||||
|
20,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
"_children": Set {},
|
||||||
|
"_nodes": [],
|
||||||
|
"_pos": Float32Array [
|
||||||
|
20,
|
||||||
|
20,
|
||||||
|
],
|
||||||
|
"_size": Float32Array [
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
"color": "#6029aa",
|
||||||
|
"flags": {},
|
||||||
|
"font": undefined,
|
||||||
|
"font_size": 14,
|
||||||
|
"graph": [Circular],
|
||||||
|
"id": 123,
|
||||||
|
"isPointInside": [Function],
|
||||||
|
"selected": undefined,
|
||||||
|
"setDirtyCanvas": [Function],
|
||||||
|
"title": "A group to test with",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_input_nodes": undefined,
|
||||||
|
"_last_trigger_time": undefined,
|
||||||
|
"_links": Map {},
|
||||||
|
"_nodes": [
|
||||||
|
LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_nodes_by_id": {
|
||||||
|
"1": LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"_nodes_executable": [],
|
||||||
|
"_nodes_in_order": [
|
||||||
|
LGraphNode {
|
||||||
|
"_collapsed_width": undefined,
|
||||||
|
"_level": undefined,
|
||||||
|
"_pos": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
],
|
||||||
|
"_posSize": Float32Array [
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"_relative_id": undefined,
|
||||||
|
"_shape": undefined,
|
||||||
|
"_size": Float32Array [
|
||||||
|
140,
|
||||||
|
60,
|
||||||
|
],
|
||||||
|
"action_call": undefined,
|
||||||
|
"action_triggered": undefined,
|
||||||
|
"badgePosition": "top-left",
|
||||||
|
"badges": [],
|
||||||
|
"bgcolor": undefined,
|
||||||
|
"block_delete": undefined,
|
||||||
|
"boxcolor": undefined,
|
||||||
|
"clip_area": undefined,
|
||||||
|
"clonable": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"connections": [],
|
||||||
|
"console": undefined,
|
||||||
|
"exec_version": undefined,
|
||||||
|
"execute_triggered": undefined,
|
||||||
|
"flags": {},
|
||||||
|
"freeWidgetSpace": undefined,
|
||||||
|
"gotFocusAt": undefined,
|
||||||
|
"graph": [Circular],
|
||||||
|
"has_errors": undefined,
|
||||||
|
"id": 1,
|
||||||
|
"ignore_remove": undefined,
|
||||||
|
"inputs": [],
|
||||||
|
"last_serialization": undefined,
|
||||||
|
"locked": undefined,
|
||||||
|
"lostFocusAt": undefined,
|
||||||
|
"mode": 0,
|
||||||
|
"mouseOver": undefined,
|
||||||
|
"optional_inputs": undefined,
|
||||||
|
"optional_outputs": undefined,
|
||||||
|
"order": 0,
|
||||||
|
"outputs": [],
|
||||||
|
"properties": {},
|
||||||
|
"properties_info": [],
|
||||||
|
"redraw_on_mouse": undefined,
|
||||||
|
"removable": undefined,
|
||||||
|
"resizable": undefined,
|
||||||
|
"selected": undefined,
|
||||||
|
"serialize_widgets": undefined,
|
||||||
|
"showAdvanced": undefined,
|
||||||
|
"title": "LGraphNode",
|
||||||
|
"type": "mustBeSet",
|
||||||
|
"widgets": undefined,
|
||||||
|
"widgets_start_y": undefined,
|
||||||
|
"widgets_up": undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"_version": 3,
|
||||||
|
"catch_errors": true,
|
||||||
|
"config": {},
|
||||||
|
"elapsed_time": 0.01,
|
||||||
|
"errors_in_execution": undefined,
|
||||||
|
"execution_time": undefined,
|
||||||
|
"execution_timer_id": undefined,
|
||||||
|
"extra": {},
|
||||||
|
"filter": undefined,
|
||||||
|
"fixedtime": 0,
|
||||||
|
"fixedtime_lapse": 0.01,
|
||||||
|
"globaltime": 0,
|
||||||
|
"inputs": {},
|
||||||
|
"iteration": 0,
|
||||||
|
"last_update_time": 0,
|
||||||
|
"links": Map {},
|
||||||
|
"list_of_graphcanvas": null,
|
||||||
|
"nodes_actioning": [],
|
||||||
|
"nodes_executedAction": [],
|
||||||
|
"nodes_executing": [],
|
||||||
|
"outputs": {},
|
||||||
|
"runningtime": 0,
|
||||||
|
"starttime": 0,
|
||||||
|
"state": {
|
||||||
|
"lastGroupId": 123,
|
||||||
|
"lastLinkId": 0,
|
||||||
|
"lastNodeId": 1,
|
||||||
|
"lastRerouteId": 0,
|
||||||
|
},
|
||||||
|
"status": 1,
|
||||||
|
"vars": {},
|
||||||
|
"version": 1,
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`LGraph (constructor only) > Matches previous snapshot > minLGraph 1`] = `
|
||||||
|
LGraph {
|
||||||
|
"_groups": [],
|
||||||
|
"_input_nodes": undefined,
|
||||||
|
"_last_trigger_time": undefined,
|
||||||
|
"_links": Map {},
|
||||||
|
"_nodes": [],
|
||||||
|
"_nodes_by_id": {},
|
||||||
|
"_nodes_executable": [],
|
||||||
|
"_nodes_in_order": [],
|
||||||
|
"_version": 0,
|
||||||
|
"catch_errors": true,
|
||||||
|
"config": {},
|
||||||
|
"elapsed_time": 0.01,
|
||||||
|
"errors_in_execution": undefined,
|
||||||
|
"execution_time": undefined,
|
||||||
|
"execution_timer_id": undefined,
|
||||||
|
"extra": {},
|
||||||
|
"filter": undefined,
|
||||||
|
"fixedtime": 0,
|
||||||
|
"fixedtime_lapse": 0.01,
|
||||||
|
"globaltime": 0,
|
||||||
|
"inputs": {},
|
||||||
|
"iteration": 0,
|
||||||
|
"last_update_time": 0,
|
||||||
|
"links": Map {},
|
||||||
|
"list_of_graphcanvas": null,
|
||||||
|
"nodes_actioning": [],
|
||||||
|
"nodes_executedAction": [],
|
||||||
|
"nodes_executing": [],
|
||||||
|
"outputs": {},
|
||||||
|
"runningtime": 0,
|
||||||
|
"starttime": 0,
|
||||||
|
"state": {
|
||||||
|
"lastGroupId": 0,
|
||||||
|
"lastLinkId": 0,
|
||||||
|
"lastNodeId": 0,
|
||||||
|
"lastRerouteId": 0,
|
||||||
|
},
|
||||||
|
"status": 1,
|
||||||
|
"vars": {},
|
||||||
|
"version": 1,
|
||||||
|
}
|
||||||
|
`;
|
||||||
@@ -57,6 +57,7 @@ export const basicSerialisableGraph: SerialisableGraph = {
|
|||||||
nodes: [
|
nodes: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
type: "mustBeSet",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
links: [],
|
links: [],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { LGraph, LGraphGroup, LGraphNode } from "@/litegraph"
|
|||||||
import { test } from "./testExtensions"
|
import { test } from "./testExtensions"
|
||||||
import type { ISerialisedGraph } from "@/types/serialisation"
|
import type { ISerialisedGraph } from "@/types/serialisation"
|
||||||
|
|
||||||
describe.concurrent("LGraph Serialisation", () => {
|
describe("LGraph Serialisation", () => {
|
||||||
test("can (de)serialise node / group titles", ({ expect, minimalGraph }) => {
|
test("can (de)serialise node / group titles", ({ expect, minimalGraph }) => {
|
||||||
const nodeTitle = "Test Node"
|
const nodeTitle = "Test Node"
|
||||||
const groupTitle = "Test Group"
|
const groupTitle = "Test Group"
|
||||||
|
|||||||
@@ -2,14 +2,19 @@ import { test as baseTest } from "vitest"
|
|||||||
import type { ISerialisedGraph, SerialisableGraph } from "../src/types/serialisation"
|
import type { ISerialisedGraph, SerialisableGraph } from "../src/types/serialisation"
|
||||||
import { LGraph } from "@/LGraph"
|
import { LGraph } from "@/LGraph"
|
||||||
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
|
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
|
||||||
|
import { LiteGraph } from "@/litegraph"
|
||||||
|
|
||||||
interface LitegraphFixtures {
|
interface LitegraphFixtures {
|
||||||
minimalGraph: LGraph
|
minimalGraph: LGraph
|
||||||
minimalSerialisableGraph: SerialisableGraph
|
minimalSerialisableGraph: SerialisableGraph
|
||||||
basicSerialisableGraph: SerialisableGraph
|
|
||||||
oldSchemaGraph: ISerialisedGraph
|
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>({
|
export const test = baseTest.extend<LitegraphFixtures>({
|
||||||
minimalGraph: async ({ }, use) => {
|
minimalGraph: async ({ }, use) => {
|
||||||
// Before each test function
|
// Before each test function
|
||||||
@@ -18,10 +23,21 @@ export const test = baseTest.extend<LitegraphFixtures>({
|
|||||||
|
|
||||||
// use the fixture value
|
// use the fixture value
|
||||||
await use(lGraph)
|
await use(lGraph)
|
||||||
|
|
||||||
// After each test function
|
|
||||||
},
|
},
|
||||||
basicSerialisableGraph: structuredClone(basicSerialisableGraph),
|
|
||||||
minimalSerialisableGraph: structuredClone(minimalSerialisableGraph),
|
minimalSerialisableGraph: structuredClone(minimalSerialisableGraph),
|
||||||
oldSchemaGraph: structuredClone(oldSchemaGraph),
|
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))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|||||||
@@ -33,5 +33,7 @@ export default defineConfig({
|
|||||||
test: {
|
test: {
|
||||||
alias: { "@/": path.resolve(__dirname, "./src/") },
|
alias: { "@/": path.resolve(__dirname, "./src/") },
|
||||||
environment: "jsdom",
|
environment: "jsdom",
|
||||||
|
restoreMocks: true,
|
||||||
|
unstubGlobals: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user