The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test: add missing test coverage for chat sources, queue, and todo list
Steven Enamakelb067e1963e95
diff --git a/app/src/features/conversations/aui/TodoListPart.test.tsx b/app/src/features/conversations/aui/TodoListPart.test.tsxnew file mode 100644index 0000000000..0e3d2befa5--- /dev/null+++ b/app/src/features/conversations/aui/TodoListPart.test.tsx@@ -0,0 +1,78 @@+import { render, screen } from '@testing-library/react';+import { describe, expect, it } from 'vitest';++import { mapCoreTodoStatus, TodoListPart, toAuiTodoItems } from './TodoListPart';++describe('mapCoreTodoStatus', () => {+ it('maps in_progress to active', () => {+ expect(mapCoreTodoStatus('in_progress')).toBe('active');+ });+ it('maps completed to done', () => {+ expect(mapCoreTodoStatus('completed')).toBe('done');+ });+ it('maps pending to pending', () => {+ expect(mapCoreTodoStatus('pending')).toBe('pending');+ });+ it('maps an unknown status to pending', () => {+ expect(mapCoreTodoStatus('bogus')).toBe('pending');+ expect(mapCoreTodoStatus(undefined)).toBe('pending');+ });+});++describe('toAuiTodoItems', () => {+ it('maps core wire items to TodoItem, using content+index as a stable id', () => {+ const items = toAuiTodoItems([+ { content: 'Write tests', status: 'pending' },+ { content: 'Ship it', status: 'completed' },+ ]);+ expect(items).toEqual([+ { id: '0-Write tests', text: 'Write tests', status: 'pending' },+ { id: '1-Ship it', text: 'Ship it', status: 'done' },+ ]);+ });++ it('drops items with no non-empty content', () => {+ expect(toAuiTodoItems([{ content: '', status: 'pending' }, { status: 'pending' }])).toEqual([]);+ });++ it('returns an empty array for a non-array payload', () => {+ expect(toAuiTodoItems(undefined)).toEqual([]);+ expect(toAuiTodoItems({})).toEqual([]);+ });+});++const baseProps = {+ type: 'tool-call' as const,+ toolName: 'todo',+ toolCallId: 'call-1',+ argsText: '{}',+ addResult: () => {},+ resume: () => {},+ respondToApproval: async () => {},+};++describe('TodoListPart', () => {+ it('renders the todo list from the tool result', () => {+ render(+ <TodoListPart+ {...baseProps}+ args={{} as never}+ result={{ todos: [{ content: 'Write tests', status: 'in_progress' }] } as never}+ status={{ type: 'complete' }}+ />+ );+ expect(screen.getByText('Write tests')).toBeInTheDocument();+ });++ it('renders nothing when there are no items', () => {+ const { container } = render(+ <TodoListPart+ {...baseProps}+ args={{ todos: [] } as never}+ result={undefined}+ status={{ type: 'running' }}+ />+ );+ expect(container).toBeEmptyDOMElement();+ });+});diff --git a/app/src/features/conversations/components/aui/ChatSources.test.tsx b/app/src/features/conversations/components/aui/ChatSources.test.tsxindex 780438156b..b63ce2617f 100644--- a/app/src/features/conversations/components/aui/ChatSources.test.tsx+++ b/app/src/features/conversations/components/aui/ChatSources.test.tsx@@ -5,7 +5,7 @@* groups them into its `SourceGroup` slot, which `/chat` fills with* `ChatSources`.*- * Four things are under test, and the second is the one that matters:+ * Five things are under test, and the second is the one that matters:** 1. the list renders the turn's `http(s)` sources;* 2. it is actually **reached from the live `/chat` surface** — mounted through@@ -23,14 +23,20 @@* 4. the turn is drawn once. A settled answer used to carry a second summary* of its own reasoning and tools under it (a "N steps · M tools" footer and* a sources list both read from a duplicate `processTrail`); only the inline- * parts remain.+ * parts remain;+ * 5. a memory citation on the message's `extraMetadata.citations`+ * (`ChatDoneEvent.citations` / `ChatSegmentEvent.citations`) renders+ * alongside the `url` sources as a `document` source badge, with no href.+ *+ * Every row now renders through the vendored `sources.aui` element's+ * primitives directly (no collapsible disclosure — see `ChatSources.tsx`),+ * so there is no "expand" step left to drive.** Only the RPC is stubbed — the boundary a unit test should stub. Everything* between it and the DOM is production code.*/import { combineReducers, configureStore } from '@reduxjs/toolkit';import { render, screen, waitFor } from '@testing-library/react';-import userEvent from '@testing-library/user-event';import { Provider } from 'react-redux';import { beforeEach, describe, expect, it, vi } from 'vitest';diff --git a/app/src/store/__tests__/chatRuntimeSlice.queue.test.ts b/app/src/store/__tests__/chatRuntimeSlice.queue.test.tsindex 864a346e6e..4899589598 100644--- a/app/src/store/__tests__/chatRuntimeSlice.queue.test.ts+++ b/app/src/store/__tests__/chatRuntimeSlice.queue.test.ts@@ -3,12 +3,9 @@ import { describe, expect, it } from 'vitest';import reducer, {beginInferenceTurn,clearAllChatRuntime,- clearFollowupsForThread,clearQueueStatusForThread,clearRuntimeForThread,endInferenceTurn,- enqueueFollowup,- removeFollowup,setQueueStatusForThread,} from '../chatRuntimeSlice';@@ -116,74 +113,3 @@ describe('chatRuntimeSlice — queue status', () => {expect(state.queueStatusByThread['thread-1']).toBeDefined();});});--describe('chatRuntimeSlice — queued follow-ups', () => {- const enq = (threadId: string, id: string, text: string) =>- enqueueFollowup({- threadId,- message: {- id,- content: text,- type: 'text',- extraMetadata: {},- sender: 'user',- createdAt: '2026-01-01T00:00:00.000Z',- },- label: text,- });-- it('enqueues follow-ups in order per thread', () => {- let state = reducer(undefined, enq('t1', 'a', 'first'));- state = reducer(state, enq('t1', 'b', 'second'));-- expect(state.queuedFollowupsByThread['t1'].map(f => f.message.id)).toEqual(['a', 'b']);- expect(state.queuedFollowupsByThread['t1'].map(f => f.label)).toEqual(['first', 'second']);- expect(state.queuedFollowupsByThread['t1'][0].message.content).toBe('first');- });-- it('keeps follow-up queues isolated per thread', () => {- let state = reducer(undefined, enq('t1', 'a', 'one'));- state = reducer(state, enq('t2', 'b', 'two'));-- expect(state.queuedFollowupsByThread['t1']).toHaveLength(1);- expect(state.queuedFollowupsByThread['t2']).toHaveLength(1);- });-- it('removeFollowup drops one entry by message id and prunes empty buckets', () => {- let state = reducer(undefined, enq('t1', 'a', 'one'));- state = reducer(state, enq('t1', 'b', 'two'));-- state = reducer(state, removeFollowup({ threadId: 't1', id: 'a' }));- expect(state.queuedFollowupsByThread['t1'].map(f => f.message.id)).toEqual(['b']);-- state = reducer(state, removeFollowup({ threadId: 't1', id: 'b' }));- expect(state.queuedFollowupsByThread['t1']).toBeUndefined();- });-- it('clearFollowupsForThread drops all entries for the thread', () => {- let state = reducer(undefined, enq('t1', 'a', 'one'));- state = reducer(state, clearFollowupsForThread({ threadId: 't1' }));-- expect(state.queuedFollowupsByThread['t1']).toBeUndefined();- });-- it('endInferenceTurn clears the thread follow-up queue (it is being dispatched)', () => {- let state = reducer(undefined, enq('t1', 'a', 'one'));- state = reducer(state, beginInferenceTurn({ threadId: 't1' }));- state = reducer(state, endInferenceTurn({ threadId: 't1' }));-- expect(state.queuedFollowupsByThread['t1']).toBeUndefined();- });-- it('clearRuntimeForThread and clearAllChatRuntime drop follow-up queues', () => {- let state = reducer(undefined, enq('t1', 'a', 'one'));- state = reducer(state, enq('t2', 'b', 'two'));-- const perThread = reducer(state, clearRuntimeForThread({ threadId: 't1' }));- expect(perThread.queuedFollowupsByThread['t1']).toBeUndefined();- expect(perThread.queuedFollowupsByThread['t2']).toBeDefined();-- const all = reducer(state, clearAllChatRuntime());- expect(Object.keys(all.queuedFollowupsByThread)).toHaveLength(0);- });-});