test(desktop): cover workspace pane reveal in selectSidebarItem

Adds a regression test for #72602: navigating to a sidebar route now calls navigate() and fronts the workspace pane (noteActiveTreeGroup(null) + revealTreePane('workspace')).

Mocks @/components/pane-shell/tree/store to assert the calls without depending on real pane-tree DOM state.
This commit is contained in:
alelpoan 2026-07-27 16:02:49 +03:00 committed by Brooklyn Nicholson
parent 9cef5496eb
commit 5ecc666146

View file

@ -3,6 +3,7 @@ import type { MutableRefObject } from 'react'
import { useEffect } from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { noteActiveTreeGroup, revealTreePane } from '@/components/pane-shell/tree/store'
import { getSession, getSessionMessages, type SessionInfo } from '@/hermes'
import { createClientSessionState } from '@/lib/chat-runtime'
import { clearSessionDraft, stashSessionDraft, takeSessionDraft } from '@/store/composer'
@ -55,6 +56,12 @@ vi.mock('@/store/profile', async importOriginal => ({
ensureGatewayProfile: vi.fn().mockResolvedValue(undefined)
}))
vi.mock('@/components/pane-shell/tree/store', async importOriginal => ({
...(await importOriginal<Record<string, unknown>>()),
noteActiveTreeGroup: vi.fn(),
revealTreePane: vi.fn()
}))
const RUNTIME_SESSION_ID = 'rt-new-001'
function deferred<T>() {
@ -69,7 +76,7 @@ function deferred<T>() {
type HarnessHandle = Pick<
ReturnType<typeof useSessionActions>,
'createBackendSessionForSend' | 'startFreshSessionDraft'
'createBackendSessionForSend' | 'selectSidebarItem' | 'startFreshSessionDraft'
>
function storedSession(overrides: Partial<SessionInfo> = {}): SessionInfo {
@ -1590,3 +1597,21 @@ describe('createBackendSessionForSend workspace target', () => {
expect(params).toMatchObject({ cwd: '/clicked-workspace' })
})
})
describe('selectSidebarItem', () => {
it('fronts the workspace pane when navigating to a sidebar route (issue #72602)', async () => {
const navigate = vi.fn()
const requestGateway = vi.fn(async () => ({}) as never)
let handle: HarnessHandle | null = null
render(<Harness navigate={navigate} onReady={value => (handle = value)} requestGateway={requestGateway} />)
await waitFor(() => expect(handle).not.toBeNull())
act(() => {
handle!.selectSidebarItem({ icon: (() => null) as never, id: 'skills', label: 'Capabilities', route: '/skills' })
})
expect(navigate).toHaveBeenCalledWith('/skills', undefined)
expect(noteActiveTreeGroup).toHaveBeenCalledWith(null)
expect(revealTreePane).toHaveBeenCalledWith('workspace')
})
})