Converted seed widget test
This commit is contained in:
@@ -11,7 +11,8 @@ import type { ComfyNodeDef } from '$lib/ComfyNodeDef';
|
||||
|
||||
const objectInfo: Record<string, ComfyNodeDef> = await import("./data/objectInfo.json")
|
||||
const json1: ComfyVanillaWorkflow = await import("./data/convertedWidget.json")
|
||||
const json2: ComfyVanillaWorkflow = await import("./data/convertedWidgetAndPrimitiveNode.json")
|
||||
const json2: ComfyVanillaWorkflow = await import("./data/convertedSeedWidget.json")
|
||||
const json3: ComfyVanillaWorkflow = await import("./data/convertedWidgetAndPrimitiveNode.json")
|
||||
|
||||
export default class convertVanillaWorkflowTests extends UnitTest {
|
||||
test__convertsWidget() {
|
||||
@@ -53,9 +54,56 @@ export default class convertVanillaWorkflowTests extends UnitTest {
|
||||
expect(convWorkflow.graph.getNodeById(widget.node.id)).toEqual(widget.node)
|
||||
}
|
||||
|
||||
test__convertsSeedWidget() {
|
||||
const workflow = LiteGraph.cloneObject(json2)
|
||||
const attrs: WorkflowAttributes = { ...defaultWorkflowAttributes }
|
||||
|
||||
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(10)
|
||||
|
||||
const widgets = Object.values(layout.allItems).filter(di => di.dragItem.type === "widget").map(di => di.dragItem) as WidgetLayout[];
|
||||
expect(widgets).toHaveLength(6);
|
||||
|
||||
const widgetsValues = widgets.map(w => { return [w.node.type, w.node.getValue(), w.attrs.title] })
|
||||
expect(widgetsValues).toEqual([
|
||||
["ui/number", 20, 'steps'],
|
||||
["ui/number", 8, 'cfg'],
|
||||
["ui/combo", 'euler', 'sampler_name'],
|
||||
["ui/combo", 'normal', 'scheduler'],
|
||||
["ui/number", 1, 'denoise'],
|
||||
["ui/number", 1461, 'seed']
|
||||
]);
|
||||
|
||||
const widget = widgets.find(w => w.attrs.title === "seed") as WidgetLayout | null;
|
||||
expect(widget).toBeDefined();
|
||||
expect(widget.node).toBeDefined();
|
||||
expect(widget.node.type).toEqual("ui/number")
|
||||
expect(widget.node.getValue()).toEqual(1461)
|
||||
expect(convWorkflow.graph.getNodeById(widget.node.id)).toEqual(widget.node)
|
||||
|
||||
const links = widget.node.getOutputLinks(0)
|
||||
expect(links).toHaveLength(1);
|
||||
|
||||
const kSampler = convWorkflow.graph.findNodesByType("KSampler")[0];
|
||||
expect(links[0].origin_id).toEqual(widget.node.id);
|
||||
expect(links[0].target_id).toEqual(kSampler.id);
|
||||
expect(widget.node.outputs[0].type).toEqual("number");
|
||||
expect(links[0].type).toEqual("number");
|
||||
}
|
||||
|
||||
test__convertsPrimitiveNodeAndConvertedInput() {
|
||||
const workflow = LiteGraph.cloneObject(json2)
|
||||
const workflow = LiteGraph.cloneObject(json3)
|
||||
const attrs: WorkflowAttributes = { ...defaultWorkflowAttributes }
|
||||
|
||||
ComfyApp.knownBackendNodes["KSampler"] = {
|
||||
|
||||
134
src/tests/data/convertedSeedWidget.json
Normal file
134
src/tests/data/convertedSeedWidget.json
Normal file
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"last_node_id": 2,
|
||||
"last_link_id": 1,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "KSampler",
|
||||
"pos": [
|
||||
1514,
|
||||
348
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
262
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "model",
|
||||
"type": "MODEL",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"type": "CONDITIONING",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"type": "CONDITIONING",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "latent_image",
|
||||
"type": "LATENT",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "seed",
|
||||
"type": "INT",
|
||||
"link": 1,
|
||||
"widget": {
|
||||
"name": "seed",
|
||||
"config": [
|
||||
"INT",
|
||||
{
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 18446744073709552000
|
||||
}
|
||||
]
|
||||
},
|
||||
"slot_index": 4
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "LATENT",
|
||||
"type": "LATENT",
|
||||
"links": null,
|
||||
"shape": 3
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "KSampler"
|
||||
},
|
||||
"widgets_values": [
|
||||
1461,
|
||||
"randomize",
|
||||
20,
|
||||
8,
|
||||
"euler",
|
||||
"normal",
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "PrimitiveNode",
|
||||
"pos": [
|
||||
1160,
|
||||
420
|
||||
],
|
||||
"size": {
|
||||
"0": 210,
|
||||
"1": 82
|
||||
},
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"name": "INT",
|
||||
"type": "INT",
|
||||
"links": [
|
||||
1
|
||||
],
|
||||
"widget": {
|
||||
"name": "seed",
|
||||
"config": [
|
||||
"INT",
|
||||
{
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 18446744073709552000
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties": {},
|
||||
"widgets_values": [
|
||||
1461,
|
||||
"randomize"
|
||||
]
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
4,
|
||||
"INT"
|
||||
]
|
||||
],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {},
|
||||
"version": 0.4
|
||||
}
|
||||
Reference in New Issue
Block a user