mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(web): add conversation outline search (#1102)
* feat(web): add conversation outline search * fix(web): keep outline close action accessible
This commit is contained in:
@@ -46,7 +46,6 @@ function renderPanel(props: Partial<ComponentProps<typeof ConversationOutlinePan
|
||||
return render(
|
||||
<I18nProvider>
|
||||
<ConversationOutlinePanel
|
||||
title="project"
|
||||
items={outlineItems}
|
||||
hasMoreMessages={false}
|
||||
isLoadingMoreMessages={false}
|
||||
@@ -78,6 +77,41 @@ describe('ConversationOutlinePanel', () => {
|
||||
expect(onLoadMore).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('filters loaded outline items without hiding load earlier', () => {
|
||||
const onLoadMore = vi.fn()
|
||||
renderPanel({ hasMoreMessages: true, onLoadMore })
|
||||
|
||||
fireEvent.change(screen.getByRole('searchbox', { name: 'Search outline items' }), {
|
||||
target: { value: 'SECOND' }
|
||||
})
|
||||
|
||||
expect(screen.queryByText('Implement the panel')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('Second user prompt')).toBeInTheDocument()
|
||||
expect(screen.getByText('1 of 2 items')).toBeInTheDocument()
|
||||
fireEvent.click(screen.getByRole('button', { name: /Load earlier/ }))
|
||||
expect(onLoadMore).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('shows a search-specific empty state', () => {
|
||||
renderPanel()
|
||||
|
||||
fireEvent.change(screen.getByRole('searchbox', { name: 'Search outline items' }), {
|
||||
target: { value: 'missing' }
|
||||
})
|
||||
|
||||
expect(screen.getByText('No matching outline items')).toBeInTheDocument()
|
||||
expect(screen.queryByText('No outline items in loaded messages')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps an in-panel close action available', () => {
|
||||
const onClose = vi.fn()
|
||||
renderPanel({ onClose })
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('renders an empty state', () => {
|
||||
renderPanel({ items: [] })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user