Fix group node manage opening to wrong node type (#1754)

Remove dialog from DOM when closed
Add test
This commit is contained in:
pythongosssss
2024-12-02 00:52:08 +00:00
committed by GitHub
parent 9b07993e1a
commit 5c6eecd660
4 changed files with 41 additions and 3 deletions

View File

@@ -103,6 +103,36 @@ test.describe('Group Node', () => {
await expect(comfyPage.page.locator('.node-tooltip')).toBeVisible()
})
test('Manage group opens with the correct group selected', async ({
comfyPage
}) => {
const makeGroup = async (name, type1, type2) => {
const node1 = (await comfyPage.getNodeRefsByType(type1))[0]
const node2 = (await comfyPage.getNodeRefsByType(type2))[0]
await node1.click('title')
await node2.click('title', {
modifiers: ['Shift']
})
return await node2.convertToGroupNode(name)
}
const group1 = await makeGroup(
'g1',
'CLIPTextEncode',
'CheckpointLoaderSimple'
)
const group2 = await makeGroup('g2', 'EmptyLatentImage', 'KSampler')
const manage1 = await group1.manageGroupNode()
await comfyPage.nextFrame()
expect(await manage1.getSelectedNodeType()).toBe('g1')
await manage1.close()
await expect(manage1.root).not.toBeVisible()
const manage2 = await group2.manageGroupNode()
expect(await manage2.getSelectedNodeType()).toBe('g2')
})
test('Reconnects inputs after configuration changed via manage dialog save', async ({
comfyPage
}) => {

View File

@@ -1,12 +1,14 @@
import { Locator, Page } from '@playwright/test'
export class ManageGroupNode {
footer: Locator
header: Locator
constructor(
readonly page: Page,
readonly root: Locator
) {
this.footer = root.locator('footer')
this.header = root.locator('header')
}
async setLabel(name: string, label: string) {
@@ -23,6 +25,11 @@ export class ManageGroupNode {
await this.footer.getByText('Close').click()
}
async getSelectedNodeType() {
const select = this.header.locator('select').first()
return await select.inputValue()
}
async selectNode(name: string) {
const list = this.root.locator('.comfy-group-manage-list-items')
const item = list.getByText(name)

View File

@@ -1001,7 +1001,7 @@ export class GroupNodeHandler {
},
{
content: 'Manage Group Node',
callback: manageGroupNodes
callback: () => manageGroupNodes(this.type)
}
)
}
@@ -1488,8 +1488,8 @@ function ungroupSelectedGroupNodes() {
}
}
function manageGroupNodes() {
new ManageGroupDialog(app).show()
function manageGroupNodes(type?: string) {
new ManageGroupDialog(app).show(type)
}
const id = 'Comfy.GroupNode'

View File

@@ -519,6 +519,7 @@ export class ManageGroupDialog extends ComfyDialog<HTMLDialogElement> {
this.element.addEventListener('close', () => {
this.draggable?.dispose()
this.element.remove()
})
}
}