Fix group node bookmarking (#950)

* Resolves #926 group node bookmark

* Remove expect outside scope of test

* Update unit tests

* Update group node manager path separators

* Update group node path sepator in fixture
This commit is contained in:
bymyself
2024-09-24 00:26:02 -07:00
committed by GitHub
parent b21c0f59f9
commit 6b9c1b70ba
5 changed files with 77 additions and 32 deletions

View File

@@ -707,7 +707,6 @@ export class ComfyPage {
})
await this.canvas.press('Control+a')
const node = await this.getFirstNodeRef()
expect(node).not.toBeNull()
await node!.clickContextMenuOption('Convert to Group Node')
await this.nextFrame()
}
@@ -874,7 +873,7 @@ class NodeReference {
await this.clickContextMenuOption('Convert to Group Node')
await this.comfyPage.nextFrame()
const nodes = await this.comfyPage.getNodeRefsByType(
`workflow/${groupNodeName}`
`workflow>${groupNodeName}`
)
if (nodes.length !== 1) {
throw new Error(`Did not find single group node (found=${nodes.length})`)

View File

@@ -7,36 +7,82 @@ test.describe('Group Node', () => {
})
test.describe('Node library sidebar', () => {
const groupNodeName = 'DefautWorkflowGroupNode'
const groupNodeCategory = 'group nodes>workflow'
const groupNodeBookmarkName = `workflow>${groupNodeName}`
let libraryTab
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.UseNewMenu', 'Top')
libraryTab = comfyPage.menu.nodeLibraryTab
await comfyPage.convertAllNodesToGroupNode(groupNodeName)
await libraryTab.open()
})
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)
expect(await libraryTab.getFolder('group nodes').count()).toBe(1)
})
test('Can be added to canvas using node library sidebar', async ({
comfyPage
}) => {
const groupNodeName = 'DefautWorkflowGroupNode'
await comfyPage.convertAllNodesToGroupNode(groupNodeName)
const initialNodeCount = await comfyPage.getGraphNodesCount()
// 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()
await libraryTab.getFolder(groupNodeCategory).first().click()
await libraryTab.getNode(groupNodeName).first().click()
// Verify the node is added to the canvas
expect(await comfyPage.getGraphNodesCount()).toBe(initialNodeCount + 1)
})
test('Can be bookmarked and unbookmarked', async ({ comfyPage }) => {
await libraryTab.getFolder(groupNodeCategory).click()
await libraryTab
.getNode(groupNodeName)
.locator('.bookmark-button')
.first()
.click()
// Verify the node is added to the bookmarks tab
expect(
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
).toEqual([groupNodeBookmarkName])
// Verify the bookmark node with the same name is added to the tree
expect(await libraryTab.getNode(groupNodeName).count()).not.toBe(0)
// Unbookmark the node
await libraryTab
.getNode(groupNodeName)
.locator('.bookmark-button')
.first()
.click()
// Verify the node is removed from the bookmarks tab
expect(
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
).toHaveLength(0)
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [])
})
test('Displays preview on bookmark hover', async ({ comfyPage }) => {
await libraryTab.getFolder(groupNodeCategory).click()
await libraryTab
.getNode(groupNodeName)
.locator('.bookmark-button')
.first()
.click()
await comfyPage.page.hover('.p-tree-node-label.tree-explorer-node-label')
expect(await comfyPage.page.isVisible('.node-lib-node-preview')).toBe(
true
)
await libraryTab
.getNode(groupNodeName)
.locator('.bookmark-button')
.first()
.click()
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [])
})
})
test('Can be added to canvas using search', async ({ comfyPage }) => {