This commit is contained in:
space-nuko
2023-05-21 18:07:05 -05:00
parent c4fe7e0bf1
commit 57f635bbfd

View File

@@ -4,7 +4,7 @@ import { readFile } from "fs/promises"
import { get } from "svelte/store";
import convertVanillaWorkflow, { type ComfyVanillaWorkflow } from '$lib/convertVanillaWorkflow';
import type { WorkflowAttributes } from '$lib/stores/workflowState';
import { defaultWorkflowAttributes, type IDragItem, type WidgetLayout } from '$lib/stores/layoutStates';
import layoutStates, { defaultWorkflowAttributes, type IDragItem, type WidgetLayout } from '$lib/stores/layoutStates';
import ComfyApp from '$lib/components/ComfyApp';
import { LiteGraph } from '@litegraph-ts/core';
import type { ComfyNodeDef } from '$lib/ComfyNodeDef';
@@ -17,23 +17,25 @@ export default class convertVanillaWorkflowTests extends UnitTest {
const workflow = LiteGraph.cloneObject(json1)
const attrs: WorkflowAttributes = { ...defaultWorkflowAttributes }
const converted = convertVanillaWorkflow(workflow, attrs)
ComfyApp.knownBackendNodes["KSampler"] = {
nodeDef: objectInfo["KSampler"]
}
const converted = convertVanillaWorkflow(workflow, attrs)
expect(converted).toBeInstanceOf(Array)
const [convWorkflow, convLayout] = converted;
const layout = get(convLayout)
expect(Object.keys(layout.allItems)).toHaveLength(4)
expect(Object.keys(layout.allItems)).toHaveLength(10)
const widget = Object.values(layout.allItems).find(di => di.dragItem.type === "widget")?.dragItem as WidgetLayout;
const widgets = Object.values(layout.allItems).filter(di => di.dragItem.type === "widget").map(di => di.dragItem);
expect(widgets).toHaveLength(6);
const widget = widgets.find(w => w.attrs.title === "cfg") as WidgetLayout | null;
expect(widget).toBeDefined();
expect(widget.attrs.title).toEqual("cfg")
expect(widget.node).toBeDefined();
expect(widget.node.type).toEqual("ui/number")
expect(convWorkflow.graph.getNodeById(widget.node.id)).toEqual(widget.node)