feat(host): show-hidden toggle in the directory browser footer

This commit is contained in:
creatixchu
2026-07-29 12:52:59 +08:00
parent 75b32f7d76
commit cdcdd2221e
5 changed files with 67 additions and 4 deletions

View File

@@ -162,6 +162,8 @@ describe('directory-picker-browse client half', () => {
// zh is the shipped default locale.
expect(injected.t('browser.title')).toBe('选择工作区目录')
expect(injected.t('browser.newFolder')).toBe('新建文件夹')
expect(injected.t('browser.showHidden')).toBe('显示隐藏文件')
expect(injected.t('browser.hideHidden')).toBe('隐藏隐藏文件')
})
it('drives the injected browse calls through the hole entry', async () => {

View File

@@ -103,6 +103,23 @@ describe('DirectoryBrowser', () => {
expect(screen.queryByRole('button', { name: '/' })).toBeNull()
})
it('shows hidden entries when the toggle is on and hides them again on close', async () => {
const b = mount()
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })
expect(screen.queryByText('.config')).toBeNull()
// Toggle hidden files on.
fireEvent.click(screen.getByRole('button', { name: 'browser.showHidden' }))
expect(screen.getByText('.config')).toBeTruthy()
// Toggle hidden files off.
fireEvent.click(screen.getByRole('button', { name: 'browser.hideHidden' }))
expect(screen.queryByText('.config')).toBeNull()
// Close resets the toggle.
b.view.rerender(<DirectoryBrowser {...b.props} open={false} />)
b.view.rerender(<DirectoryBrowser {...b.props} open />)
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })
expect(screen.queryByText('.config')).toBeNull()
})
it('selects a row into the two-pane view: children preview right, crumbs follow the selection', async () => {
const b = mount()
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })