commit
This commit is contained in:
@@ -94,3 +94,35 @@ describe('Stage + commit', () => {
|
||||
await waitFor(() => expect(find(c, '.toast', 'Committed')).toBeTruthy())
|
||||
})
|
||||
})
|
||||
|
||||
describe('Explorer background menu', () => {
|
||||
it('right-clicking the empty space offers New file + Show in Finder only', async () => {
|
||||
const c = renderApp()
|
||||
const body = await waitFor(() => {
|
||||
const b = c.querySelector<HTMLElement>('.tree-body')
|
||||
if (!b || !b.querySelector('.tree-row')) throw new Error('tree not ready')
|
||||
return b
|
||||
})
|
||||
fireEvent.contextMenu(body)
|
||||
const labels = await waitFor(() => {
|
||||
const items = Array.from(c.querySelectorAll<HTMLElement>('.ctx-item')).map((el) => el.textContent)
|
||||
if (!items.length) throw new Error('menu not open')
|
||||
return items
|
||||
})
|
||||
expect(labels).toEqual(['New file', 'Show in Finder'])
|
||||
// the root is never renameable or deletable — that would mean the project
|
||||
expect(labels.some((l) => l?.includes('Delete'))).toBe(false)
|
||||
})
|
||||
|
||||
it('a row right-click still shows the file menu, not the root one', async () => {
|
||||
const c = renderApp()
|
||||
const row = await waitFor(() => {
|
||||
const r = find(c, '.tree-row', 'package.json')
|
||||
if (!r) throw new Error('tree not ready')
|
||||
return r
|
||||
})
|
||||
fireEvent.contextMenu(row)
|
||||
await waitFor(() => expect(find(c, '.ctx-item', 'Rename file')).toBeTruthy())
|
||||
expect(find(c, '.ctx-item', 'Copy file name')).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user