fix(client): preserve sidebar drag ordering

This commit is contained in:
_Kerman
2026-08-11 16:49:21 +08:00
parent 5b1da441d5
commit fcbe3ac836
7 changed files with 76 additions and 26 deletions

View File

@@ -661,6 +661,28 @@ describe('WorkspaceBrowser', () => {
expect(insertWorkspaceBefore).toHaveBeenCalledWith(wid('tail'), wid('beta'))
})
it('draws the first Workspace insertion boundary on the scroll container', () => {
mount({
useWorkspaces: hook(workspaceState([
workspace('alpha', []),
workspace('beta', []),
])),
})
const source = screen.getByText('beta').closest('[role="treeitem"]') as HTMLElement
let firstSection = screen.getByText('alpha').closest('[role="treeitem"]')?.parentElement as HTMLElement
while (firstSection.parentElement?.getAttribute('role') !== 'tree') {
firstSection = firstSection.parentElement as HTMLElement
}
firstSection.getBoundingClientRect = () => ({
top: 100, bottom: 134, left: 0, right: 200, width: 200, height: 34, x: 0, y: 100, toJSON: () => ({}),
})
fireEvent.dragStart(source, { dataTransfer: dragData() })
fireDrag(firstSection, 'dragOver', 105)
expect(firstSection.parentElement?.className).toContain('listTopDropActive')
const marker = firstSection.parentElement?.previousElementSibling
expect(marker?.className).toContain('listTopDropIndicator')
})
it('accepts a document-level drop and commits the last Workspace marker on drag end', () => {
const insertWorkspaceBefore = vi.fn(async () => {})
mount({