chore: sync SidebarParts dragHandle removal from main
This commit is contained in:
@@ -766,71 +766,6 @@ describe('Sidebar', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('context menu — customize icon & color', () => {
|
||||
const onCustomizeType = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 1280 })
|
||||
Object.defineProperty(window, 'innerHeight', { writable: true, configurable: true, value: 800 })
|
||||
})
|
||||
|
||||
it('shows context menu when right-clicking a section header', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 200 })
|
||||
expect(screen.getByText('Customize icon & color…')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('closes context menu and opens customize popover when clicking menu item', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 200 })
|
||||
fireEvent.click(screen.getByText('Customize icon & color…'))
|
||||
expect(screen.queryByText('Customize icon & color…')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('Done')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('calls onCustomizeType when a color is selected in the popover', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 200 })
|
||||
fireEvent.click(screen.getByText('Customize icon & color…'))
|
||||
const colorButtons = screen.getAllByTitle(/red|blue|green|purple|yellow|orange|teal|pink/i)
|
||||
fireEvent.click(colorButtons[0])
|
||||
expect(onCustomizeType).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('positions context menu above click point when near bottom of viewport', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
// Click near the bottom — y=780, menu height=48, so 780+48>800 → flip above
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 780 })
|
||||
const menu = screen.getByText('Customize icon & color…').parentElement!
|
||||
const menuTop = parseInt(menu.style.top, 10)
|
||||
// Should be flipped up to 780-48=732
|
||||
expect(menuTop).toBe(732)
|
||||
})
|
||||
|
||||
it('positions context menu at click point when not near bottom', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 200 })
|
||||
const menu = screen.getByText('Customize icon & color…').parentElement!
|
||||
expect(parseInt(menu.style.top, 10)).toBe(200)
|
||||
})
|
||||
|
||||
it('customize popover appears at clamped position near the right-click point', () => {
|
||||
render(<Sidebar entries={mockEntries} selection={defaultSelection} onSelect={() => {}} onCustomizeType={onCustomizeType} />)
|
||||
fireEvent.contextMenu(screen.getByText('Projects'), { clientX: 100, clientY: 200 })
|
||||
fireEvent.click(screen.getByText('Customize icon & color…'))
|
||||
// Find the popover wrapper div (parent of TypeCustomizePopover content)
|
||||
const doneButton = screen.getByText('Done')
|
||||
// Walk up to find the fixed positioned div
|
||||
let el: HTMLElement | null = doneButton
|
||||
while (el && !el.style.left) el = el.parentElement
|
||||
expect(el).not.toBeNull()
|
||||
// Position should be near (100, 200), clamped to viewport
|
||||
expect(parseInt(el!.style.left, 10)).toBeGreaterThanOrEqual(8)
|
||||
expect(parseInt(el!.style.top, 10)).toBeGreaterThanOrEqual(8)
|
||||
})
|
||||
})
|
||||
|
||||
describe('section ordering by type order property', () => {
|
||||
const entriesWithOrder: VaultEntry[] = [
|
||||
...mockEntries,
|
||||
|
||||
Reference in New Issue
Block a user