mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 21:54:50 +00:00
Node library custom bookmark folder (#631)
* Add new folder button * Add tree util test * nit * Support empty folder in node library * Drag to bookmark folder * Use bookmark icon for bookmark folder * Highlight on dragover * nit * Auto-expand on item added * Extract bookmark system as store * Add context menu on bookmark folder * Add editable text * Fix reactivity * Plumb editable text * refactor * Rename node * Fix focus * Prevent name collision * nit * Add new folder * nested folder support * Change drag behavior * Add basic playwright tests * nit * Target tree-node-content instead of tree-node
This commit is contained in:
63
tests-ui/tests/utils/treeUtilTest.test.ts
Normal file
63
tests-ui/tests/utils/treeUtilTest.test.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { buildTree } from '@/utils/treeUtil'
|
||||
|
||||
describe('buildTree', () => {
|
||||
it('should handle empty folder items correctly', () => {
|
||||
const items = [
|
||||
{ path: 'a/b/c/' },
|
||||
{ path: 'a/b/d.txt' },
|
||||
{ path: 'a/e/' },
|
||||
{ path: 'f.txt' }
|
||||
]
|
||||
|
||||
const tree = buildTree(items, (item) => item.path.split('/'))
|
||||
|
||||
expect(tree).toEqual({
|
||||
key: 'root',
|
||||
label: 'root',
|
||||
children: [
|
||||
{
|
||||
key: 'root/a',
|
||||
label: 'a',
|
||||
leaf: false,
|
||||
children: [
|
||||
{
|
||||
key: 'root/a/b',
|
||||
label: 'b',
|
||||
leaf: false,
|
||||
children: [
|
||||
{
|
||||
key: 'root/a/b/c',
|
||||
label: 'c',
|
||||
leaf: false,
|
||||
children: [],
|
||||
data: { path: 'a/b/c/' }
|
||||
},
|
||||
{
|
||||
key: 'root/a/b/d.txt',
|
||||
label: 'd.txt',
|
||||
leaf: true,
|
||||
children: [],
|
||||
data: { path: 'a/b/d.txt' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'root/a/e',
|
||||
label: 'e',
|
||||
leaf: false,
|
||||
children: [],
|
||||
data: { path: 'a/e/' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'root/f.txt',
|
||||
label: 'f.txt',
|
||||
leaf: true,
|
||||
children: [],
|
||||
data: { path: 'f.txt' }
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user