Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: add test files for intelligence components

Steven Enamakela12a7b946d41
diff --git a/app/src/components/intelligence/__tests__/IntelligenceTabs.test.tsx b/app/src/components/intelligence/__tests__/IntelligenceTabs.test.tsx
deleted file mode 100644
index 73ce452152..0000000000
--- a/app/src/components/intelligence/__tests__/IntelligenceTabs.test.tsx
+++ /dev/null
@@ -1,163 +0,0 @@
-import { fireEvent, screen } from '@testing-library/react';
-import type React from 'react';
-import { describe, expect, it, vi } from 'vitest';
-
-import { renderWithProviders } from '../../../test/test-utils';
-import type { ActionableItem, TimeGroup } from '../../../types/intelligence';
-import IntelligenceMemoryTab from '../IntelligenceMemoryTab';
-
-vi.mock('../ActionableCard', () => ({
- ActionableCard: ({
- item,
- onComplete,
- onDismiss,
- onSnooze,
- }: {
- item: ActionableItem;
- onComplete: (item: ActionableItem) => Promise<void>;
- onDismiss: (item: ActionableItem) => void;
- onSnooze: (item: ActionableItem, duration: number) => Promise<void>;
- }) => (
- <div data-testid={`actionable-card-${item.id}`}>
- <span>{item.title}</span>
- <button type="button" onClick={() => void onComplete(item)}>
- Complete {item.title}
- </button>
- <button type="button" onClick={() => onDismiss(item)}>
- Dismiss {item.title}
- </button>
- <button type="button" onClick={() => void onSnooze(item, 1000)}>
- Snooze {item.title}
- </button>
- </div>
- ),
-}));
-
-function makeItem(overrides: Partial<ActionableItem> = {}): ActionableItem {
- const createdAt = new Date('2026-05-16T10:00:00Z');
- return {
- id: 'item-1',
- title: 'Reply to Alice',
- description: 'Send the launch note.',
- source: 'email',
- priority: 'important',
- status: 'active',
- createdAt,
- updatedAt: createdAt,
- actionable: true,
- ...overrides,
- };
-}
-
-function renderMemoryTab(
- overrides: Partial<React.ComponentProps<typeof IntelligenceMemoryTab>> = {}
-) {
- const props = renderMemoryTabProps(overrides);
- renderWithProviders(<IntelligenceMemoryTab {...props} />);
- return props;
-}
-
-describe('Intelligence tab panels', () => {
- it('wires search and source filters', () => {
- const props = renderMemoryTab();
-
- fireEvent.change(screen.getByLabelText(/Search (actionable items|memory)/i), {
- target: { value: 'alice' },
- });
- fireEvent.change(screen.getByLabelText('Filter by source'), { target: { value: 'calendar' } });
-
- expect(props.setSearchFilter).toHaveBeenCalledWith('alice');
- expect(props.setSourceFilter).toHaveBeenCalledWith('calendar');
- });
-
- it('shows the loading state before memory-backed items are ready', () => {
- renderMemoryTab({ itemsLoading: true, usingMemoryData: false });
-
- expect(
- screen.getByRole('heading', { name: /Loading (Intelligence|Memory)/i })
- ).toBeInTheDocument();
- expect(
- screen.getByText(/Fetching (your actionable items|your memory entries)/i)
- ).toBeInTheDocument();
- });
-
- it('shows the running empty state while analysis is in progress', () => {
- renderMemoryTab({ isRunning: true, items: [] });
-
- expect(
- screen.getByRole('heading', { name: /Analyzing (your data|Memory)/i })
- ).toBeInTheDocument();
- expect(
- screen.getByText(/reviewing your connected skills|Processing your memories/i)
- ).toBeInTheDocument();
- });
-
- it('shows the no-analysis call to action and invokes analyze now', () => {
- const props = renderMemoryTab();
-
- expect(screen.getByRole('heading', { name: /No Analysis Yet/i })).toBeInTheDocument();
- fireEvent.click(screen.getByRole('button', { name: 'Analyze Now' }));
-
- expect(props.handleAnalyzeNow).toHaveBeenCalledTimes(1);
- });
-
- it('explains empty filtered and memory-backed states', () => {
- const { rerender } = renderWithProviders(
- <IntelligenceMemoryTab
- {...renderMemoryTabProps({ searchFilter: 'missing' })}
- timeGroups={[]}
- />
- );
-
- expect(screen.getByRole('heading', { name: /No Matches/i })).toBeInTheDocument();
-
- rerender(
- <IntelligenceMemoryTab
- {...renderMemoryTabProps({ searchFilter: '', usingMemoryData: true })}
- timeGroups={[]}
- />
- );
-
- expect(screen.getByRole('heading', { name: /All caught up/i })).toBeInTheDocument();
- });
-
- it('renders grouped actionable cards and forwards item actions', () => {
- const item = makeItem();
- const timeGroups: TimeGroup[] = [{ label: 'Today', count: 1, items: [item] }];
- const props = renderMemoryTab({ isRunning: true, items: [item], timeGroups });
-
- expect(screen.getByText(/Analyzing (your data|Memory)/i)).toBeInTheDocument();
- expect(screen.getByRole('heading', { name: 'Today' })).toBeInTheDocument();
- expect(screen.getByText('1')).toBeInTheDocument();
- expect(screen.getByTestId('actionable-card-item-1')).toBeInTheDocument();
-
- fireEvent.click(screen.getByRole('button', { name: 'Complete Reply to Alice' }));
- fireEvent.click(screen.getByRole('button', { name: 'Dismiss Reply to Alice' }));
- fireEvent.click(screen.getByRole('button', { name: 'Snooze Reply to Alice' }));
-
- expect(props.handleComplete).toHaveBeenCalledWith(item);
- expect(props.handleDismiss).toHaveBeenCalledWith(item);
- expect(props.handleSnooze).toHaveBeenCalledWith(item, 1000);
- });
-});
-
-function renderMemoryTabProps(
- overrides: Partial<React.ComponentProps<typeof IntelligenceMemoryTab>> = {}
-): React.ComponentProps<typeof IntelligenceMemoryTab> {
- return {
- handleAnalyzeNow: vi.fn().mockResolvedValue(undefined),
- handleComplete: vi.fn().mockResolvedValue(undefined),
- handleDismiss: vi.fn(),
- handleSnooze: vi.fn().mockResolvedValue(undefined),
- isRunning: false,
- items: [],
- itemsLoading: false,
- searchFilter: '',
- setSearchFilter: vi.fn(),
- setSourceFilter: vi.fn(),
- sourceFilter: 'all',
- timeGroups: [],
- usingMemoryData: false,
- ...overrides,
- };
-}
diff --git a/app/src/components/intelligence/__tests__/MemoryOverview.test.tsx b/app/src/components/intelligence/__tests__/MemoryOverview.test.tsx
index 9b3f4d7e49..81464806e1 100644
--- a/app/src/components/intelligence/__tests__/MemoryOverview.test.tsx
+++ b/app/src/components/intelligence/__tests__/MemoryOverview.test.tsx
@@ -3,8 +3,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { Chunk, EntityRef, GraphRelation, Source } from '../../../utils/tauriCommands';
import { MemoryHeatmap } from '../MemoryHeatmap';
-import { MemoryInsights } from '../MemoryInsights';
-import { MemoryNavigator, type NavigatorSelection } from '../MemoryNavigator';
function localDayAt(daysAgo: number, hour: number, minute = 0): number {
const d = new Date(Date.now());
@@ -107,82 +105,4 @@ describe('memory overview components', () => {
expect(screen.getByRole('heading', { name: 'Ingestion Activity' })).toBeInTheDocument();
expect(container.querySelector('.animate-pulse')).toBeInTheDocument();
});
-
- it('groups insights by predicate category and expands long groups', () => {
- const relations = [
- makeRelation({ object: 'morning updates', evidenceCount: 4 }),
- makeRelation({ subject: 'Bob', object: 'brief summaries' }),
- makeRelation({ subject: 'Carol', object: 'async notes' }),
- makeRelation({ subject: 'Dana', object: 'voice memos' }),
- makeRelation({ subject: 'Alice', predicate: 'knows', object: 'Bob', evidenceCount: 1 }),
- makeRelation({
- subject: 'Alice',
- predicate: 'skilled',
- object: 'Rust',
- attrs: { entity_types: { object: 'technology' } },
- }),
- ];
-
- render(<MemoryInsights relations={relations} />);
-
- expect(screen.getByRole('heading', { name: /Insights/i })).toBeInTheDocument();
- expect(screen.getByText(paragraphMatching(/6.*relations/i))).toBeInTheDocument();
- expect(screen.getByText('Preferences')).toBeInTheDocument();
- expect(screen.getByText('Relationships')).toBeInTheDocument();
- expect(screen.getByText(/Skills/)).toBeInTheDocument();
- expect(screen.getByText('x4')).toBeInTheDocument();
- expect(screen.getByText('+1 more')).toBeInTheDocument();
-
- fireEvent.click(screen.getByText('Preferences').closest('button')!);
- expect(screen.getByText('voice memos')).toBeInTheDocument();
- expect(screen.getAllByText('person')[0]).toBeInTheDocument();
- });
-
- it('renders loading and empty insight states', () => {
- const { rerender, container } = render(<MemoryInsights relations={[]} loading />);
-
- expect(screen.getByRole('heading', { name: /Insights/i })).toBeInTheDocument();
- expect(container.querySelector('.animate-pulse')).toBeInTheDocument();
-
- rerender(<MemoryInsights relations={[]} />);
- expect(screen.getByText(/No insights yet/)).toBeInTheDocument();
- });
-
- it('wires navigator search, source selection, and entity selection', async () => {
- const onSearchChange = vi.fn();
- const onSelectionChange = vi.fn();
- const selection: NavigatorSelection = { sourceIds: [], entityIds: [] };
-
- render(
- <MemoryNavigator
- chunks={[
- makeChunk({ id: 'today', timestamp_ms: localDayAt(0, 9) }),
- makeChunk({ id: 'week', timestamp_ms: localDayAt(3, 9) }),
- ]}
- sources={[makeSource()]}
- topPeople={[makeEntity()]}
- topTopics={[makeEntity({ entity_id: 'topic:Atlas', kind: 'topic', surface: 'Atlas' })]}
- selection={selection}
- onSelectionChange={onSelectionChange}
- searchQuery=""
- onSearchChange={onSearchChange}
- />
- );
-
- fireEvent.change(screen.getByLabelText(/Search memor/i), { target: { value: 'atlas' } });
- expect(onSearchChange).toHaveBeenCalledWith('atlas');
-
- expect(screen.getByText('Today 1')).toBeInTheDocument();
- expect(screen.getByText('This Week 2')).toBeInTheDocument();
-
- fireEvent.click(screen.getByRole('button', { name: /Email/ }));
- fireEvent.click(screen.getByRole('button', { name: /Alice Inbox/ }));
- expect(onSelectionChange).toHaveBeenCalledWith({
- sourceIds: ['gmail:[email protected]'],
- entityIds: [],
- });
-
- fireEvent.click(screen.getByTitle('Alice').closest('button')!);
- expect(onSelectionChange).toHaveBeenCalledWith({ sourceIds: [], entityIds: ['person:Alice'] });
- });
});
diff --git a/app/src/components/intelligence/__tests__/MemoryPresentation.test.tsx b/app/src/components/intelligence/__tests__/MemoryPresentation.test.tsx
index 3c7c277cf0..8d43b738fd 100644
--- a/app/src/components/intelligence/__tests__/MemoryPresentation.test.tsx
+++ b/app/src/components/intelligence/__tests__/MemoryPresentation.test.tsx
@@ -5,7 +5,6 @@ import type { ActionableItem } from '../../../types/intelligence';
import type { Chunk } from '../../../utils/tauriCommands';
import { ActionableCard } from '../ActionableCard';
import { MemoryEmptyPlaceholder } from '../MemoryEmptyPlaceholder';
-import { MemoryResultList } from '../MemoryResultList';
import { MemoryStatsBar } from '../MemoryStatsBar';
function makeChunk(overrides: Partial<Chunk> = {}): Chunk {
@@ -97,55 +96,6 @@ describe('memory presentation components', () => {
expect(screen.getByText(/^2[,.]048 tokens$/)).toBeInTheDocument();
});
- it('groups memory chunks by age and calls the selection handler', () => {
- const onSelectChunk = vi.fn();
- const chunks = [
- makeChunk({
- id: 'today',
- timestamp_ms: localDayAt(0, 9, 15),
- content_preview: 'Review launch checklist. Include final QA notes.',
- }),
- makeChunk({
- id: 'yesterday',
- timestamp_ms: localDayAt(1, 14, 30),
- source_kind: 'chat',
- source_id: 'slack:product',
- content_preview: 'Discussed onboarding metrics with the team.',
- }),
- makeChunk({
- id: 'week',
- timestamp_ms: localDayAt(3, 8, 45),
- content_preview: 'Draft roadmap priorities for next sprint.',
- }),
- makeChunk({ id: 'older', timestamp_ms: localDayAt(9, 16, 0), content_preview: '' }),
- ];
-
- render(
- <MemoryResultList chunks={chunks} selectedChunkId="yesterday" onSelectChunk={onSelectChunk} />
- );
-
- const list = screen.getByTestId('memory-result-list');
- expect(within(list).getByText('TODAY')).toBeInTheDocument();
- expect(within(list).getByText('YESTERDAY')).toBeInTheDocument();
- expect(within(list).getByText('THIS WEEK')).toBeInTheDocument();
- expect(within(list).getByText('OLDER')).toBeInTheDocument();
- expect(within(list).getByText('Review launch checklist.')).toBeInTheDocument();
- expect(within(list).getByText('older')).toBeInTheDocument();
-
- const selectedRow = within(list).getByText('Discussed onboarding metrics with the team.');
- expect(selectedRow.closest('button')).toHaveAttribute('aria-pressed', 'true');
-
- fireEvent.click(within(list).getByText('Review launch checklist.'));
- expect(onSelectChunk).toHaveBeenCalledWith('today');
- });
-
- it('renders an empty result-list state', () => {
- render(<MemoryResultList chunks={[]} selectedChunkId={null} onSelectChunk={vi.fn()} />);
-
- expect(screen.getByTestId('memory-result-list')).toBeInTheDocument();
- expect(screen.getByText(/No matching chunks|No memories found/i)).toBeInTheDocument();
- });
-
it('renders actionable item details and fires direct actions', () => {
const item = makeActionableItem();
const onComplete = vi.fn();
diff --git a/app/src/components/intelligence/__tests__/MemoryTextAndDetail.test.tsx b/app/src/components/intelligence/__tests__/MemoryTextAndDetail.test.tsx
index 242362d01a..a42db88ba3 100644
--- a/app/src/components/intelligence/__tests__/MemoryTextAndDetail.test.tsx
+++ b/app/src/components/intelligence/__tests__/MemoryTextAndDetail.test.tsx
@@ -7,7 +7,6 @@ import type {
MemoryRetrievalEntity,
ScoreBreakdown,
} from '../../../utils/tauriCommands';
-import { MemoryChunkDetail } from '../MemoryChunkDetail';
import { MemoryTextWithEntities } from '../MemoryTextWithEntities';
const rpcMocks = vi.hoisted(() => ({
@@ -86,56 +85,3 @@ describe('MemoryTextWithEntities', () => {
expect(screen.getByText(/owns Atlas/)).toBeInTheDocument();
});
});
-
-describe('MemoryChunkDetail', () => {
- beforeEach(() => {
- vi.clearAllMocks();
- rpcMocks.memoryTreeEntityIndexFor.mockResolvedValue(ENTITIES);
- rpcMocks.memoryTreeChunkScore.mockResolvedValue(SCORE);
- });
-
- it('loads chunk entities and score details for the letter view', async () => {
- const onSelectEntity = vi.fn();
- render(<MemoryChunkDetail chunk={BASE_CHUNK} onSelectEntity={onSelectEntity} />);
-
- expect(screen.getByTestId('memory-chunk-detail')).toBeInTheDocument();
- expect(screen.getByRole('heading', { name: 'Project Atlas kickoff' })).toBeInTheDocument();
- expect(screen.getByTitle('Entity type: PERSON')).toHaveTextContent('PERSON');
- expect(screen.getByTitle('Entity type: PROJECT')).toHaveTextContent('PROJECT');
-
- await waitFor(() => {
- expect(rpcMocks.memoryTreeEntityIndexFor).toHaveBeenCalledWith(BASE_CHUNK.id);
- expect(rpcMocks.memoryTreeChunkScore).toHaveBeenCalledWith(BASE_CHUNK.id);
- });
-
- const mentioned = await screen.findByTestId('memory-chunk-mentioned');
- expect(within(mentioned).getByText('Alice')).toBeInTheDocument();
- expect(within(mentioned).getByText('2 chunks')).toBeInTheDocument();
- expect(within(mentioned).getByText('Atlas')).toBeInTheDocument();
- expect(within(mentioned).getByText('1 chunk')).toBeInTheDocument();
-
- fireEvent.click(within(mentioned).getByText('Alice'));
- expect(onSelectEntity).toHaveBeenCalledWith(ENTITIES[0]);
-
- expect(screen.getByTestId('memory-chunk-scorebars')).toBeInTheDocument();
- expect(screen.getByText('recency')).toBeInTheDocument();
- expect(screen.getByLabelText('recency score 80 percent')).toBeInTheDocument();
- expect(screen.getByText('gmail://msg/abc')).toBeInTheDocument();
- expect(screen.getByRole('button', { name: /chunk 12345678/i })).toBeInTheDocument();
- expect(screen.getByText('bge-m3 1024dim')).toBeInTheDocument();
- });
-
- it('copies the full chunk id from the footer button', async () => {
- const writeText = vi.fn().mockResolvedValue(undefined);
- Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
-
- render(<MemoryChunkDetail chunk={BASE_CHUNK} onSelectEntity={vi.fn()} />);
-
- fireEvent.click(screen.getByTitle('Copy chunk id'));
-
- await waitFor(() => {
- expect(writeText).toHaveBeenCalledWith(BASE_CHUNK.id);
- });
- expect(await screen.findByText('copied')).toBeInTheDocument();
- });
-});