fix: update tests for multi-tab architecture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
程序员阿江(Relakkes) 2026-04-09 00:46:25 +08:00
parent 9bfbadd170
commit 942df9d362
2 changed files with 29 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import { ToolInspection } from '../pages/ToolInspection'
// Layout components (chrome is now here, not in pages)
import { AppShell } from '../components/layout/AppShell'
import { Sidebar } from '../components/layout/Sidebar'
import { UserMessage } from '../components/chat/UserMessage'
import { useChatStore } from '../stores/chatStore'
import { useTabStore } from '../stores/tabStore'
@ -36,12 +37,37 @@ describe('Content-only pages render without errors', () => {
})
it('ActiveSession renders with chat components', () => {
const SESSION_ID = 'test-active-session'
useTabStore.setState({ tabs: [{ sessionId: SESSION_ID, title: 'Test', status: 'idle' }], activeTabId: SESSION_ID })
useChatStore.setState({
sessions: {
[SESSION_ID]: {
messages: [],
chatState: 'idle',
connectionState: 'connected',
streamingText: '',
streamingToolInput: '',
activeToolUseId: null,
activeToolName: null,
activeThinkingId: null,
pendingPermission: null,
tokenUsage: { input_tokens: 0, output_tokens: 0 },
elapsedSeconds: 0,
statusVerb: '',
slashCommands: [],
elapsedTimer: null,
},
},
})
const { container } = render(<ActiveSession />)
// Should have the title area and chat input
expect(container.innerHTML).toContain('Untitled Session')
// ChatInput has a textarea
expect(container.querySelector('textarea')).toBeInTheDocument()
expect(container.innerHTML).not.toContain('Preview')
// Cleanup
useTabStore.setState({ tabs: [], activeTabId: null })
useChatStore.setState({ sessions: {} })
})
it('ActiveSession shows a single primary action button while a turn is active', () => {
@ -123,11 +149,11 @@ describe('Chat attachments', () => {
describe('AppShell layout renders chrome', () => {
it('AppShell renders sidebar and session shell', () => {
const { container } = render(<AppShell />)
const { container } = render(<Sidebar />)
expect(container.querySelector('aside')).toBeInTheDocument()
expect(container.innerHTML).toContain('New session')
expect(container.innerHTML).toContain('Scheduled')
expect(container.innerHTML).toContain('Select a project')
expect(container.innerHTML).toContain('All projects')
})
})

View File

@ -108,6 +108,6 @@ describe('chat blocks', () => {
expect(container.textContent).toContain('Allow')
// react-diff-viewer-continued uses styled-components tables that don't
// fully render in jsdom, so we verify the DiffViewer wrapper is mounted
expect(container.querySelector('[class*="rounded-lg"]')).toBeTruthy()
expect(container.querySelector('[class*="rounded-[var(--radius-lg)]"]')).toBeTruthy()
})
})