diff --git a/browser_tests/ComfyPage.ts b/browser_tests/ComfyPage.ts index 89d83a11..6bc078da 100644 --- a/browser_tests/ComfyPage.ts +++ b/browser_tests/ComfyPage.ts @@ -1,5 +1,6 @@ import type { Page, Locator } from '@playwright/test' import { test as base } from '@playwright/test' +import { expect } from '@playwright/test' import dotenv from 'dotenv' dotenv.config() import * as fs from 'fs' @@ -705,8 +706,9 @@ export class ComfyPage { await dialog.accept(groupNodeName) }) await this.canvas.press('Control+a') - await this.rightClickEmptyLatentNode() - await this.page.getByText('Convert to Group Node').click() + const node = await this.getFirstNodeRef() + expect(node).not.toBeNull() + await node!.clickContextMenuOption('Convert to Group Node') await this.nextFrame() } async convertOffsetToCanvas(pos: [number, number]) { @@ -720,12 +722,19 @@ export class ComfyPage { async getNodeRefsByType(type: string): Promise { return ( await this.page.evaluate((type) => { - return window['app'].graph._nodes + return window['app'].graph.nodes .filter((n) => n.type === type) .map((n) => n.id) }, type) ).map((id: NodeId) => this.getNodeRefById(id)) } + async getFirstNodeRef(): Promise { + const id = await this.page.evaluate(() => { + return window['app'].graph.nodes[0]?.id + }) + if (!id) return null + return this.getNodeRefById(id) + } } class NodeSlotReference { constructor( diff --git a/browser_tests/groupNode.spec.ts b/browser_tests/groupNode.spec.ts index 97bdecd8..dcd12a14 100644 --- a/browser_tests/groupNode.spec.ts +++ b/browser_tests/groupNode.spec.ts @@ -6,33 +6,37 @@ test.describe('Group Node', () => { await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled') }) - test('Is added to node library sidebar', async ({ comfyPage }) => { - await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') - const groupNodeName = 'DefautWorkflowGroupNode' - await comfyPage.convertAllNodesToGroupNode(groupNodeName) - const tab = comfyPage.menu.nodeLibraryTab - await tab.open() - expect(await tab.getFolder('group nodes').count()).toBe(1) - }) + test.describe('Node library sidebar', () => { + test.beforeEach(async ({ comfyPage }) => { + await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') + }) - test('Can be added to canvas using node library sidebar', async ({ - comfyPage - }) => { - await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') - const groupNodeName = 'DefautWorkflowGroupNode' - await comfyPage.convertAllNodesToGroupNode(groupNodeName) - const initialNodeCount = await comfyPage.getGraphNodesCount() + test('Is added to node library sidebar', async ({ comfyPage }) => { + const groupNodeName = 'DefautWorkflowGroupNode' + await comfyPage.convertAllNodesToGroupNode(groupNodeName) + const tab = comfyPage.menu.nodeLibraryTab + await tab.open() + expect(await tab.getFolder('group nodes').count()).toBe(1) + }) - // Add group node from node library sidebar - const tab = comfyPage.menu.nodeLibraryTab - await tab.open() - await tab.getFolder('group nodes').click() - await tab.getFolder('workflow').click() - await tab.getFolder('workflow').last().click() - await tab.getNode(groupNodeName).click() + test('Can be added to canvas using node library sidebar', async ({ + comfyPage + }) => { + const groupNodeName = 'DefautWorkflowGroupNode' + await comfyPage.convertAllNodesToGroupNode(groupNodeName) + const initialNodeCount = await comfyPage.getGraphNodesCount() - // Verify the node is added to the canvas - expect(await comfyPage.getGraphNodesCount()).toBe(initialNodeCount + 1) + // Add group node from node library sidebar + const tab = comfyPage.menu.nodeLibraryTab + await tab.open() + await tab.getFolder('group nodes').click() + await tab.getFolder('workflow').click() + await tab.getFolder('workflow').last().click() + await tab.getNode(groupNodeName).click() + + // Verify the node is added to the canvas + expect(await comfyPage.getGraphNodesCount()).toBe(initialNodeCount + 1) + }) }) test('Can be added to canvas using search', async ({ comfyPage }) => {