test(host): cover the cancel path that keeps an intact preview

This commit is contained in:
creatixchu
2026-07-29 00:39:07 +08:00
parent b0d120efa8
commit 8ba0647c2c
@@ -355,6 +355,17 @@ describe('DirectoryBrowser', () => {
expect(screen.queryByText('harness')).toBeNull()
})
it('keeps an intact selection preview when a path edit is cancelled', async () => {
mount()
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })
fireEvent.click(rowButton(screen.getByRole('listitem')))
await waitFor(() => { expect(columns()).toHaveLength(2) })
fireEvent.click(screen.getByRole('button', { name: 'browser.editPath' }))
fireEvent.keyDown(screen.getByLabelText('browser.editPath'), { key: 'Escape' })
// Nothing was superseded: the two-pane view survives the cancel.
expect(columns()).toHaveLength(2)
})
it('falls back to the single-pane level when a path edit superseded the preview and was cancelled', async () => {
const pending: ((listing: DirectoryListing) => void)[] = []
const b = mount()