Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import type {LGraphNode} from "@comfyorg/frontend";
|
|
|
|
import {app} from "scripts/app.js";
|
|
import {wait} from "rgthree/common/shared_utils.js";
|
|
import {NodeTypesString} from "../constants.js";
|
|
|
|
type addNodeOptions = {
|
|
placement?: string;
|
|
};
|
|
|
|
/**
|
|
* A testing environment to make setting up, clearing, and queuing more predictable in an
|
|
* integration test environment.
|
|
*/
|
|
export class ComfyUITestEnvironment {
|
|
private lastNode: LGraphNode | null = null;
|
|
private maxY = 0;
|
|
|
|
constructor() {}
|
|
|
|
wait = wait;
|
|
|
|
async addNode(nodeString: string, options: addNodeOptions = {}) {
|
|
const [canvas, graph] = [app.canvas, app.graph];
|
|
const node = LiteGraph.createNode(nodeString)!;
|
|
let x = 0;
|
|
let y = 30;
|
|
if (this.lastNode) {
|
|
const placement = options.placement || "right";
|
|
if (placement === "under") {
|
|
x = this.lastNode.pos[0];
|
|
y = this.lastNode.pos[1] + this.lastNode.size[1] + 30;
|
|
} else if (placement === "right") {
|
|
x = this.lastNode.pos[0] + this.lastNode.size[0] + 100;
|
|
y = this.lastNode.pos[1];
|
|
} else if (placement === "start") {
|
|
x = 0;
|
|
y = this.maxY + 50;
|
|
}
|
|
}
|
|
canvas.graph!.add(node);
|
|
node.pos = [x, y];
|
|
canvas.selectNode(node);
|
|
app.graph.setDirtyCanvas(true, true);
|
|
await wait();
|
|
this.lastNode = node;
|
|
this.maxY = Math.max(this.maxY, y + this.lastNode.size[1]);
|
|
return (this.lastNode = node);
|
|
}
|
|
|
|
async clear() {
|
|
app.clean();
|
|
app.graph.clear();
|
|
const nodeConfig = await this.addNode(NodeTypesString.KSAMPLER_CONFIG);
|
|
const displayAny = await this.addNode(NodeTypesString.DISPLAY_ANY);
|
|
nodeConfig.widgets = nodeConfig.widgets || [];
|
|
nodeConfig.widgets[0]!.value = Math.round(Math.random() * 100);
|
|
nodeConfig.connect(0, displayAny, 0);
|
|
await this.queuePrompt();
|
|
app.clean();
|
|
app.graph.clear();
|
|
this.lastNode = null;
|
|
this.maxY = 0;
|
|
await wait();
|
|
}
|
|
|
|
async queuePrompt() {
|
|
await app.queuePrompt(0);
|
|
await wait(150);
|
|
}
|
|
}
|