Skip to content

Commit

Permalink
Fix group node manage opening to wrong node type (#1754)
Browse files Browse the repository at this point in the history
Remove dialog from DOM when closed
Add test
  • Loading branch information
pythongosssss authored Dec 2, 2024
1 parent 9b07993 commit 5c6eecd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
30 changes: 30 additions & 0 deletions browser_tests/groupNode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) => {
Expand Down
7 changes: 7 additions & 0 deletions browser_tests/helpers/manageGroupNode.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/core/groupNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ export class GroupNodeHandler {
},
{
content: 'Manage Group Node',
callback: manageGroupNodes
callback: () => manageGroupNodes(this.type)
}
)
}
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions src/extensions/core/groupNodeManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ export class ManageGroupDialog extends ComfyDialog<HTMLDialogElement> {

this.element.addEventListener('close', () => {
this.draggable?.dispose()
this.element.remove()
})
}
}

0 comments on commit 5c6eecd

Please sign in to comment.