mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-03 04:31:58 +00:00
Update litegraph to 0.7.26 (#161)
* Update litegraph * Test node order * Update test expectations [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
40
tests-ui/tests/litegraph.test.ts
Normal file
40
tests-ui/tests/litegraph.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { LiteGraph } from "@comfyorg/litegraph";
|
||||
import { LGraph } from "@comfyorg/litegraph";
|
||||
import { LGraphNode } from "@comfyorg/litegraph";
|
||||
|
||||
function swapNodes(nodes: LGraphNode[]) {
|
||||
const firstNode = nodes[0];
|
||||
const lastNode = nodes[nodes.length - 1];
|
||||
nodes[0] = lastNode;
|
||||
nodes[nodes.length - 1] = firstNode;
|
||||
return nodes;
|
||||
}
|
||||
|
||||
function createGraph(...nodes: LGraphNode[]) {
|
||||
const graph = new LGraph();
|
||||
nodes.forEach((node) => graph.add(node));
|
||||
return graph;
|
||||
}
|
||||
|
||||
class DummyNode extends LGraphNode {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
describe("LGraph", () => {
|
||||
it("should serialize deterministic node order", async () => {
|
||||
LiteGraph.registerNodeType("dummy", DummyNode);
|
||||
const node1 = new DummyNode();
|
||||
const node2 = new DummyNode();
|
||||
const graph = createGraph(node1, node2);
|
||||
|
||||
const result1 = graph.serialize();
|
||||
expect(result1.nodes).not.toHaveLength(0);
|
||||
// @ts-ignore
|
||||
graph._nodes = swapNodes(graph._nodes);
|
||||
const result2 = graph.serialize();
|
||||
|
||||
expect(result1).toEqual(result2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user