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
fix(components): update memory tab tests to match new vendor API
Steven Enamakel94c26876234a
diff --git a/app/src/components/memory/MemoryAskTab.test.tsx b/app/src/components/memory/MemoryAskTab.test.tsxnew file mode 100644index 0000000000..afa0faf922--- /dev/null+++ b/app/src/components/memory/MemoryAskTab.test.tsx@@ -0,0 +1,116 @@+import { fireEvent, screen, waitFor, within } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { renderWithProviders } from '../../test/test-utils';+import MemoryAskTab from './MemoryAskTab';++const hoisted = vi.hoisted(() => ({ recall: vi.fn(), fetch: vi.fn() }));++vi.mock('../../services/api/memoryApi', async importOriginal => ({+ ...(await importOriginal<typeof import('../../services/api/memoryApi')>()),+ memoryRecall: (...a: unknown[]) => hoisted.recall(...a),+ memoryFetch: (...a: unknown[]) => hoisted.fetch(...a),+}));++beforeEach(() => {+ hoisted.recall.mockReset();+ hoisted.fetch.mockReset();+});++function ask(text: string) {+ fireEvent.change(screen.getByTestId('memory-ask-input'), { target: { value: text } });+ fireEvent.click(screen.getByTestId('memory-ask-submit'));+}++describe('MemoryAskTab', () => {+ it('disables Ask until there is a question', () => {+ renderWithProviders(<MemoryAskTab fetchModes={['hybrid']} />);+ expect(screen.getByTestId('memory-ask-submit')).toBeDisabled();+ });++ it('asks memory and shows the answer with its citations', async () => {+ hoisted.recall.mockResolvedValue({+ answer: 'We ship on **Friday**.',+ citations: [+ {+ id: 'c1',+ kind: 'document',+ snippet: 'Launch moved to Friday',+ meta: { file_path: '/notes/launch.md', url: 'https://example.com/launch' },+ score: 0.8,+ },+ {+ id: 'c2',+ kind: 'conversation',+ snippet: 'Agreed in chat',+ meta: { thread_id: 'thread-7' },+ },+ ],+ });+ renderWithProviders(<MemoryAskTab fetchModes={['hybrid']} />);+ ask('When do we ship?');++ await waitFor(() => expect(hoisted.recall).toHaveBeenCalledWith({ question: 'When do we ship?' }));+ const answer = await screen.findByTestId('memory-ask-answer');+ expect(answer).toHaveTextContent('We ship on Friday.');+ const c1 = screen.getByTestId('memory-citation-c1');+ expect(c1).toHaveTextContent('Document');+ expect(c1).toHaveTextContent('Launch moved to Friday');+ expect(within(c1).getByTestId('memory-meta-file')).toHaveTextContent('/notes/launch.md');+ expect(within(c1).getByTestId('memory-meta-url')).toHaveTextContent('https://example.com/launch');+ // Citations do not show a score; raw results do.+ expect(within(c1).queryByTestId('memory-hit-score')).not.toBeInTheDocument();+ const c2 = screen.getByTestId('memory-citation-c2');+ expect(within(c2).getByTestId('memory-meta-thread')).toHaveTextContent('thread-7');+ });++ it('runs a raw fetch with the chosen mode and lists scored hits', async () => {+ hoisted.fetch.mockResolvedValue({+ hits: [+ { id: 'h1', kind: 'learning', text: 'Prefers tabs', meta: { folder: '/notes' }, score: 0.912 },+ ],+ });+ renderWithProviders(<MemoryAskTab fetchModes={['keyword', 'vector']} />);+ fireEvent.click(screen.getByTestId('memory-ask-raw-toggle'));++ const mode = screen.getByTestId('memory-ask-mode');+ expect(within(mode).getAllByRole('option').map(o => o.textContent)).toEqual([+ 'Keyword',+ 'Semantic',+ ]);+ fireEvent.change(mode, { target: { value: 'vector' } });+ ask('tabs');++ await waitFor(() =>+ expect(hoisted.fetch).toHaveBeenCalledWith({ query: 'tabs', mode: 'vector', limit: 20 })+ );+ const hit = await screen.findByTestId('memory-hit-h1');+ expect(hit).toHaveTextContent('Learning');+ expect(within(hit).getByTestId('memory-hit-score')).toHaveTextContent('0.91');+ expect(within(hit).getByTestId('memory-meta-folder')).toHaveTextContent('/notes');+ expect(hoisted.recall).not.toHaveBeenCalled();+ });++ it('hides the mode picker when the engine lists no fetch modes', () => {+ renderWithProviders(<MemoryAskTab fetchModes={[]} />);+ fireEvent.click(screen.getByTestId('memory-ask-raw-toggle'));+ expect(screen.queryByTestId('memory-ask-mode')).not.toBeInTheDocument();+ });++ it('says so when a raw search finds nothing', async () => {+ hoisted.fetch.mockResolvedValue({ hits: [] });+ renderWithProviders(<MemoryAskTab fetchModes={['hybrid']} />);+ fireEvent.click(screen.getByTestId('memory-ask-raw-toggle'));+ ask('nothing');+ expect(await screen.findByTestId('memory-ask-hits')).toHaveTextContent(+ 'Nothing in memory matches that search.'+ );+ });++ it('shows a recall failure', async () => {+ hoisted.recall.mockRejectedValue(new Error('ENGINE: upstream timeout'));+ renderWithProviders(<MemoryAskTab fetchModes={['hybrid']} />);+ ask('anything');+ expect(await screen.findByTestId('memory-ask-error')).toHaveTextContent('upstream timeout');+ });+});diff --git a/app/src/components/memory/MemoryLearningsTab.test.tsx b/app/src/components/memory/MemoryLearningsTab.test.tsxnew file mode 100644index 0000000000..878b128394--- /dev/null+++ b/app/src/components/memory/MemoryLearningsTab.test.tsx@@ -0,0 +1,101 @@+import { fireEvent, screen, waitFor } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import type { Hit } from '../../services/api/memoryApi';+import { renderWithProviders } from '../../test/test-utils';+import MemoryLearningsTab from './MemoryLearningsTab';++const hoisted = vi.hoisted(() => ({ list: vi.fn(), learn: vi.fn(), forget: vi.fn() }));++vi.mock('../../services/api/memoryApi', async importOriginal => ({+ ...(await importOriginal<typeof import('../../services/api/memoryApi')>()),+ memoryItemsList: (...a: unknown[]) => hoisted.list(...a),+ memoryLearn: (...a: unknown[]) => hoisted.learn(...a),+ memoryForget: (...a: unknown[]) => hoisted.forget(...a),+}));++function learning(id: string, text: string): Hit {+ return { id, kind: 'learning', text, meta: {}, score: 0 };+}++beforeEach(() => {+ hoisted.list.mockReset();+ hoisted.learn.mockReset();+ hoisted.forget.mockReset();+});++describe('MemoryLearningsTab', () => {+ it('lists learnings filtered to the learning kind', async () => {+ hoisted.list.mockResolvedValue({ items: [learning('l1', 'Prefers dark mode')] });+ renderWithProviders(<MemoryLearningsTab />);+ expect(await screen.findByTestId('memory-learning-l1')).toHaveTextContent('Prefers dark mode');+ expect(hoisted.list).toHaveBeenCalledWith({+ filter: { kinds: ['learning'] },+ limit: 20,+ cursor: undefined,+ });+ });++ it('shows the empty state', async () => {+ hoisted.list.mockResolvedValue({ items: [] });+ renderWithProviders(<MemoryLearningsTab />);+ expect(await screen.findByTestId('memory-learnings-empty')).toBeInTheDocument();+ });++ it('pages with the cursor', async () => {+ hoisted.list+ .mockResolvedValueOnce({ items: [learning('l1', 'one')], next_cursor: 'c2' })+ .mockResolvedValueOnce({ items: [learning('l2', 'two')] });+ renderWithProviders(<MemoryLearningsTab />);+ fireEvent.click(await screen.findByTestId('memory-learnings-more'));+ expect(await screen.findByTestId('memory-learning-l2')).toBeInTheDocument();+ expect(screen.getByTestId('memory-learning-l1')).toBeInTheDocument();+ expect(hoisted.list).toHaveBeenLastCalledWith({+ filter: { kinds: ['learning'] },+ limit: 20,+ cursor: 'c2',+ });+ expect(screen.queryByTestId('memory-learnings-more')).not.toBeInTheDocument();+ });++ it('adds a learning with the chosen kind and reloads', async () => {+ hoisted.list+ .mockResolvedValueOnce({ items: [] })+ .mockResolvedValueOnce({ items: [learning('l9', 'Always use metric units')] });+ hoisted.learn.mockResolvedValue({ id: 'l9' });+ renderWithProviders(<MemoryLearningsTab />);+ await screen.findByTestId('memory-learnings-empty');++ fireEvent.change(screen.getByTestId('memory-learning-input'), {+ target: { value: 'Always use metric units' },+ });+ fireEvent.change(screen.getByTestId('memory-learning-kind'), {+ target: { value: 'preference' },+ });+ fireEvent.click(screen.getByTestId('memory-learning-add'));++ await waitFor(() =>+ expect(hoisted.learn).toHaveBeenCalledWith({+ text: 'Always use metric units',+ kind: 'preference',+ })+ );+ expect(await screen.findByTestId('memory-learning-l9')).toBeInTheDocument();+ expect(screen.getByTestId('memory-learning-input')).toHaveValue('');+ });++ it('deletes a learning', async () => {+ hoisted.list.mockResolvedValue({ items: [learning('l1', 'old')] });+ hoisted.forget.mockResolvedValue({ forgotten: 1 });+ renderWithProviders(<MemoryLearningsTab />);+ fireEvent.click(await screen.findByTestId('memory-learning-delete-l1'));+ await waitFor(() => expect(hoisted.forget).toHaveBeenCalledWith(['l1']));+ await waitFor(() => expect(screen.queryByTestId('memory-learning-l1')).not.toBeInTheDocument());+ });++ it('shows a load error', async () => {+ hoisted.list.mockRejectedValue(new Error('MEMORY_OFF: no engine'));+ renderWithProviders(<MemoryLearningsTab />);+ expect(await screen.findByTestId('memory-learnings-error')).toHaveTextContent('no engine');+ });+});diff --git a/vendor/tinymemory b/vendor/tinymemoryindex 9f1c80efb4..f8ea69e393 160000--- a/vendor/tinymemory+++ b/vendor/tinymemory@@ -1 +1 @@-Subproject commit 9f1c80efb4b86d9565e1e74ed2829e3c39655580+Subproject commit f8ea69e39335cca5e67bb817249c02776228b7ce