Add tests on litegraph search box triggering events (#97)

* Add test on litegraph canvas event

* Update tests

* Update litegraph
This commit is contained in:
Chenlei Hu
2024-07-06 18:49:22 -04:00
committed by GitHub
parent 2ae2e827d8
commit 525adb754f
4 changed files with 44 additions and 5 deletions

View File

@@ -144,6 +144,11 @@ export class ComfyPage {
await this.nextFrame();
}
async doubleClickCanvas() {
await this.page.mouse.dblclick(10, 10);
await this.nextFrame();
}
async rightClickEmptyLatentNode() {
await this.canvas.click({
position: {

View File

@@ -0,0 +1,34 @@
import { expect } from "@playwright/test";
import { comfyPageFixture as test } from "./ComfyPage";
function listenForEvent(): Promise<Event> {
return new Promise<Event>((resolve) => {
document.addEventListener("litegraph:canvas", (e) => resolve(e), { once: true });
});
}
test.describe("Canvas Event", () => {
test("Emit litegraph:canvas empty-release", async ({ comfyPage }) => {
const eventPromise = comfyPage.page.evaluate(listenForEvent);
const disconnectPromise = comfyPage.disconnectEdge();
const event = await eventPromise;
await disconnectPromise;
expect(event).not.toBeNull();
// No further check on event content as the content is dropped by
// playwright for some reason.
// See https://github.com/microsoft/playwright/issues/31580
});
test("Emit litegraph:canvas empty-double-click", async ({ comfyPage }) => {
const eventPromise = comfyPage.page.evaluate(listenForEvent);
const doubleClickPromise = comfyPage.doubleClickCanvas();
const event = await eventPromise;
await doubleClickPromise;
expect(event).not.toBeNull();
// No further check on event content as the content is dropped by
// playwright for some reason.
// See https://github.com/microsoft/playwright/issues/31580
});
});

8
package-lock.json generated
View File

@@ -8,7 +8,7 @@
"name": "comfyui-frontend",
"version": "1.0.1",
"dependencies": {
"@comfyorg/litegraph": "^0.7.20",
"@comfyorg/litegraph": "^0.7.23",
"dotenv": "^16.4.5",
"zod": "^3.23.8",
"zod-validation-error": "^3.3.0"
@@ -1778,9 +1778,9 @@
"dev": true
},
"node_modules/@comfyorg/litegraph": {
"version": "0.7.20",
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.20.tgz",
"integrity": "sha512-MOXObIlBhfPWHCT5/mQeYQhU1fh1Qtfmq6fzEBCiJHRvxTSFPMtaLe+h3GDrE1ZUlbJJ9Q/22UJnpHrPyWYeqg=="
"version": "0.7.23",
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.23.tgz",
"integrity": "sha512-jW7oNubtCtP9aUiG7RPQB5Tzfl9f5NdnpH9TzDtPLF22qBt2TU0KUo20dvfi3pv+uZigGialJkbhV9nGSRFRLw=="
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",

View File

@@ -40,7 +40,7 @@
"zip-dir": "^2.0.0"
},
"dependencies": {
"@comfyorg/litegraph": "^0.7.20",
"@comfyorg/litegraph": "^0.7.23",
"dotenv": "^16.4.5",
"zod": "^3.23.8",
"zod-validation-error": "^3.3.0"