Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(desktop-app): r1-l3 derive ChatSwitcher fixture from chatViewTabs producers

Diego Zacarias7e1a0f8e6106
diff --git a/desktop-app/ui/src/components/ChatSwitcher/ChatSwitcher.test.tsx b/desktop-app/ui/src/components/ChatSwitcher/ChatSwitcher.test.tsx
index 3d8b16b66..1ef3b4a4e 100644
--- a/desktop-app/ui/src/components/ChatSwitcher/ChatSwitcher.test.tsx
+++ b/desktop-app/ui/src/components/ChatSwitcher/ChatSwitcher.test.tsx
@@ -4,22 +4,38 @@ import { makeTaskKey } from '@contexts/AgentTaskTrackerContext/types'
import { ChatListProvider } from '@contexts/ChatListContext'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { createSessionFsmStore, projectSessionState } from '@hooks/domain/sessionFsm'
+import {
+ addBlankChatViewTab,
+ createChatViewTabsState,
+ openPersistedChatViewTab,
+} from '@lib/chatViewTabs'
import { ChatSwitcher } from '.'
afterEach(cleanup)
-const tabs = [
- { id: 'one', agentRef: 'alpha', chatId: 'chat-1', title: 'First chat' },
- { id: 'two', agentRef: 'alpha', chatId: 'chat-2', title: 'Second chat' },
- { id: 'blank', agentRef: 'alpha', chatId: null, title: 'New chat' },
-]
+// Derive the tab list from the real chatViewTabs producers instead of hand-writing
+// ChatViewTab objects — if the tab shape changes, this fixture stops compiling
+// against the real form (T1). Two persisted chats (chat-1/chat-2, agent 'alpha')
+// plus a trailing blank tab. Ids resolve to 'one' (the seed blank reused for the
+// first persisted view), 'two' (view id), and 'blank', matching the assertions.
+const tabs = addBlankChatViewTab(
+ openPersistedChatViewTab(
+ openPersistedChatViewTab(createChatViewTabsState('one', 'alpha'), {
+ id: 'chat-1-tab',
+ agentRef: 'alpha',
+ chatId: 'chat-1',
+ title: 'First chat',
+ }),
+ { id: 'two', agentRef: 'alpha', chatId: 'chat-2', title: 'Second chat' }
+ ),
+ 'blank',
+ 'alpha'
+).tabs
describe('ChatSwitcher', () => {
it('shows the active chat in the trigger and lists open chats on demand', () => {
const onSelect = vi.fn()
- render(
- <ChatSwitcher tabs={tabs} activeTabId="one" onSelect={onSelect} onNewChat={vi.fn()} />
- )
+ render(<ChatSwitcher tabs={tabs} activeTabId="one" onSelect={onSelect} onNewChat={vi.fn()} />)
const trigger = screen.getByRole('button', { name: 'Open chats' })
expect(trigger.textContent).toContain('First chat')
@@ -43,9 +59,7 @@ describe('ChatSwitcher', () => {
it('exposes a new-chat action that closes the menu', () => {
const onNewChat = vi.fn()
- render(
- <ChatSwitcher tabs={tabs} activeTabId="one" onSelect={vi.fn()} onNewChat={onNewChat} />
- )
+ render(<ChatSwitcher tabs={tabs} activeTabId="one" onSelect={vi.fn()} onNewChat={onNewChat} />)
fireEvent.click(screen.getByRole('button', { name: 'Open chats' }))
fireEvent.click(screen.getByRole('button', { name: '+ New chat' }))
expect(onNewChat).toHaveBeenCalledTimes(1)