mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-30 04:50:04 +00:00
* 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
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
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' }
|
|
}
|
|
]
|
|
})
|
|
})
|
|
})
|