Fix group node playwright tests (#1849)

* Fix group node playwright tests

* nit

* nit
This commit is contained in:
Chenlei Hu
2024-12-08 17:21:59 -08:00
committed by GitHub
parent aa04ab78c1
commit 2d1b2cb1cc
3 changed files with 14 additions and 9 deletions

View File

@@ -514,6 +514,10 @@ export class ComfyPage {
return { x: 427, y: 98 } return { x: 427, y: 98 }
} }
get promptDialogInput() {
return this.page.locator('.p-dialog-content input[type="text"]')
}
async disconnectEdge() { async disconnectEdge() {
await this.dragAndDrop(this.clipTextEncodeNode1InputSlot, this.emptySpace) await this.dragAndDrop(this.clipTextEncodeNode1InputSlot, this.emptySpace)
} }
@@ -778,14 +782,15 @@ export class ComfyPage {
} }
async convertAllNodesToGroupNode(groupNodeName: string) { async convertAllNodesToGroupNode(groupNodeName: string) {
this.page.on('dialog', async (dialog) => {
await dialog.accept(groupNodeName)
})
await this.canvas.press('Control+a') await this.canvas.press('Control+a')
const node = await this.getFirstNodeRef() const node = await this.getFirstNodeRef()
await node!.clickContextMenuOption('Convert to Group Node') await node!.clickContextMenuOption('Convert to Group Node')
await this.promptDialogInput.fill(groupNodeName)
await this.page.keyboard.press('Enter')
await this.promptDialogInput.waitFor({ state: 'hidden' })
await this.nextFrame() await this.nextFrame()
} }
async convertOffsetToCanvas(pos: [number, number]) { async convertOffsetToCanvas(pos: [number, number]) {
return this.page.evaluate((pos) => { return this.page.evaluate((pos) => {
return window['app'].canvas.ds.convertOffsetToCanvas(pos) return window['app'].canvas.ds.convertOffsetToCanvas(pos)

View File

@@ -233,10 +233,10 @@ export class NodeReference {
await ctx.getByText(optionText).click() await ctx.getByText(optionText).click()
} }
async convertToGroupNode(groupNodeName: string = 'GroupNode') { async convertToGroupNode(groupNodeName: string = 'GroupNode') {
this.comfyPage.page.once('dialog', async (dialog) => {
await dialog.accept(groupNodeName)
})
await this.clickContextMenuOption('Convert to Group Node') await this.clickContextMenuOption('Convert to Group Node')
await this.comfyPage.promptDialogInput.fill(groupNodeName)
await this.comfyPage.page.keyboard.press('Enter')
await this.comfyPage.promptDialogInput.waitFor({ state: 'hidden' })
await this.comfyPage.nextFrame() await this.comfyPage.nextFrame()
const nodes = await this.comfyPage.getNodeRefsByType( const nodes = await this.comfyPage.getNodeRefsByType(
`workflow>${groupNodeName}` `workflow>${groupNodeName}`

View File

@@ -32,11 +32,11 @@ test.describe('Canvas Right Click Menu', () => {
test('Can convert to group node', async ({ comfyPage }) => { test('Can convert to group node', async ({ comfyPage }) => {
await comfyPage.select2Nodes() await comfyPage.select2Nodes()
await expect(comfyPage.canvas).toHaveScreenshot('selected-2-nodes.png') await expect(comfyPage.canvas).toHaveScreenshot('selected-2-nodes.png')
comfyPage.page.on('dialog', async (dialog) => {
await dialog.accept('GroupNode2CLIP')
})
await comfyPage.rightClickCanvas() await comfyPage.rightClickCanvas()
await comfyPage.clickContextMenuItem('Convert to Group Node') await comfyPage.clickContextMenuItem('Convert to Group Node')
await comfyPage.promptDialogInput.fill('GroupNode2CLIP')
await comfyPage.page.keyboard.press('Enter')
await comfyPage.promptDialogInput.waitFor({ state: 'hidden' })
await comfyPage.nextFrame() await comfyPage.nextFrame()
await expect(comfyPage.canvas).toHaveScreenshot( await expect(comfyPage.canvas).toHaveScreenshot(
'right-click-node-group-node.png' 'right-click-node-group-node.png'