Fix unbookmark node in node library (#639)

* Add unbookmark test

* Fix unbookmark
This commit is contained in:
Chenlei Hu
2024-08-26 11:04:08 -04:00
committed by GitHub
parent 03ac6eea19
commit a69858c87a
2 changed files with 23 additions and 1 deletions

View File

@@ -206,7 +206,7 @@ test.describe('Menu', () => {
)
})
test('Can unbookmark node', async ({ comfyPage }) => {
test('Can unbookmark node (Top level bookmark)', async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
'KSampler (Advanced)'
])
@@ -219,6 +219,24 @@ test.describe('Menu', () => {
[]
)
})
test('Can unbookmark node (Library node bookmark)', async ({
comfyPage
}) => {
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
'KSampler (Advanced)'
])
const tab = comfyPage.menu.nodeLibraryTab
await tab.getFolder('sampling').click()
await comfyPage.page
.locator(tab.nodeSelector('KSampler (Advanced)'))
.nth(1)
.locator('.bookmark-button')
.click()
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
[]
)
})
})
test('Can change canvas zoom speed setting', async ({ comfyPage }) => {

View File

@@ -30,6 +30,10 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
const toggleBookmark = (node: ComfyNodeDefImpl) => {
if (isBookmarked(node)) {
deleteBookmark(node.nodePath)
// Delete the bookmark at the top level if it exists
// This is used for clicking the bookmark button in the node library, i.e.
// the node is inside original/standard node library tree node
deleteBookmark(node.display_name)
} else {
addBookmark(node.display_name)
}