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(memory): cover memory page rendering and interactions
Steven Enamakel81c1b2430896
diff --git a/app/src/pages/__tests__/Memory.test.tsx b/app/src/pages/__tests__/Memory.test.tsxindex e0f47d29b8..16413a91ea 100644--- a/app/src/pages/__tests__/Memory.test.tsx+++ b/app/src/pages/__tests__/Memory.test.tsx@@ -18,37 +18,18 @@ vi.mock('../../services/api/memoryApi', async importOriginal => ({vi.mock('../../components/memory/MemoryEngineTab', () => ({default: () => <div data-testid="stub-engine" />,}));-vi.mock('../../components/memory/MemoryAskTab', () => ({- default: ({ fetchModes }: { fetchModes: string[] }) => (- <div data-testid="stub-ask">{fetchModes.join(',')}</div>- ),-}));-vi.mock('../../components/memory/MemoryExplorerTab', () => ({- default: () => <div data-testid="stub-explorer" />,-}));-vi.mock('../../components/memory/MemoryLearningsTab', () => ({- default: () => <div data-testid="stub-learnings" />,-}));vi.mock('../../components/memory/MemoryConversationsTab', () => ({default: () => <div data-testid="stub-conversations" />,}));+// The Files tab has its own suite; here it only reports its props.vi.mock('../../components/memory/MemoryBrainTab', () => ({- default: () => <div data-testid="stub-brain" />,-}));-vi.mock('../../components/memory/MemoryBackgroundTab', () => ({- default: () => <div data-testid="stub-background" />,-}));-vi.mock('../../components/memory/MemorySettingsTab', () => ({- default: () => <div data-testid="stub-settings" />,-}));-vi.mock('../../components/memory/MemoryImportBanner', () => ({- default: ({ engineLabel }: { engineLabel: string }) => (- <div data-testid="stub-import">{engineLabel}</div>+ default: ({ engineLabel, offState }: { engineLabel: string; offState?: ReactNode }) => (+ <div data-testid="stub-brain">+ {engineLabel}+ {offState}+ </div>),}));-vi.mock('../../components/memory/MemoryCortexAnnouncement', () => ({- default: () => <div data-testid="stub-announcement" />,-}));const ON: EngineState = {engine: 'tinyhumans',@@ -90,63 +71,44 @@ beforeEach(() => {});describe('Memory page', () => {- it('renders the nine chips', async () => {+ it('renders exactly the three tabs', async () => {renderAt('?tab=brain');- for (const chip of [- 'engine',- 'migration',- 'ask',- 'explorer',- 'learnings',- 'conversations',- 'brain',- 'background',- 'settings',- ]) {+ for (const chip of ['engine', 'conversations', 'brain']) {expect(await screen.findByTestId(`brain-tab-${chip}`)).toBeInTheDocument();}+ for (const gone of ['migration', 'ask', 'explorer', 'learnings', 'background', 'settings']) {+ expect(screen.queryByTestId(`brain-tab-${gone}`)).not.toBeInTheDocument();+ }+ expect(screen.getByTestId('brain-tab-brain')).toHaveTextContent('Files');});- it('defaults to Engine when an engine is active', async () => {+ it('defaults to Provider when an engine is active', async () => {renderAt('?tab=brain');expect(await screen.findByTestId('stub-engine')).toBeInTheDocument();- expect(screen.queryByTestId('stub-ask')).not.toBeInTheDocument();- expect(screen.queryByTestId('stub-import')).not.toBeInTheDocument();+ expect(screen.queryByTestId('stub-brain')).not.toBeInTheDocument();});- it('defaults to Engine when memory is off', async () => {+ it('defaults to Provider when memory is off', async () => {hoisted.engineGet.mockResolvedValue(OFF);renderAt('?tab=brain');expect(await screen.findByTestId('stub-engine')).toBeInTheDocument();- expect(screen.queryByTestId('stub-import')).not.toBeInTheDocument();});- it('keeps the import flow and announcement on the Migration chip only', async () => {- renderAt('?tab=brain&brain=migration');- expect(await screen.findByTestId('stub-import')).toHaveTextContent('TinyHumans');- expect(screen.getByTestId('stub-announcement')).toBeInTheDocument();-- fireEvent.click(screen.getByTestId('brain-tab-ask'));- expect(await screen.findByTestId('stub-ask')).toBeInTheDocument();- expect(screen.queryByTestId('stub-import')).not.toBeInTheDocument();- expect(screen.queryByTestId('stub-announcement')).not.toBeInTheDocument();+ it('hands the Files tab the active engine label', async () => {+ renderAt('?tab=brain&brain=brain');+ expect(await screen.findByTestId('stub-brain')).toHaveTextContent('TinyHumans');});- it('shows the announcement and the off state on Migration while memory is off', async () => {+ it('passes the off state to the Files tab while memory is off', async () => {hoisted.engineGet.mockResolvedValue(OFF);- renderAt('?tab=brain&brain=migration');- expect(await screen.findByTestId('memory-off-state')).toBeInTheDocument();- expect(screen.getByTestId('stub-announcement')).toBeInTheDocument();- expect(screen.queryByTestId('stub-import')).not.toBeInTheDocument();+ renderAt('?tab=brain&brain=brain');+ const brain = await screen.findByTestId('stub-brain');+ expect(brain).toContainElement(screen.getByTestId('memory-off-state'));});it.each([- ['explorer', 'stub-explorer'],- ['learnings', 'stub-learnings'],['conversations', 'stub-conversations'],['brain', 'stub-brain'],- ['background', 'stub-background'],- ['settings', 'stub-settings'],['engine', 'stub-engine'],])('opens the %s chip from ?brain=', async (chip, testId) => {renderAt(`?tab=brain&brain=${chip}`);@@ -154,13 +116,19 @@ describe('Memory page', () => {});it.each([- ['graph', 'ask', 'stub-ask'],- ['goals', 'ask', 'stub-ask'],+ ['migration', 'brain', 'stub-brain'],+ ['ask', 'conversations', 'stub-conversations'],+ ['explorer', 'conversations', 'stub-conversations'],+ ['learnings', 'conversations', 'stub-conversations'],+ ['background', 'conversations', 'stub-conversations'],+ ['settings', 'conversations', 'stub-conversations'],+ ['graph', 'conversations', 'stub-conversations'],+ ['goals', 'conversations', 'stub-conversations'],+ ['context', 'conversations', 'stub-conversations'],['sources', 'brain', 'stub-brain'],['sync', 'brain', 'stub-brain'],['history', 'brain', 'stub-brain'],['documents', 'brain', 'stub-brain'],- ['context', 'ask', 'stub-ask'],])('rewrites legacy ?brain=%s to %s', async (legacy, chip, testId) => {renderAt(`?tab=brain&brain=${legacy}&view=history`);expect(await screen.findByTestId(testId)).toBeInTheDocument();@@ -170,7 +138,7 @@ describe('Memory page', () => {expect(screen.getByTestId('where').textContent).not.toContain('view=');});- it('rewrites an unknown ?brain= value to the Engine chip', async () => {+ it('rewrites an unknown ?brain= value to the Provider chip', async () => {renderAt('?tab=brain&brain=bogus');expect(await screen.findByTestId('stub-engine')).toBeInTheDocument();await waitFor(() =>@@ -180,20 +148,20 @@ describe('Memory page', () => {});it('switches chips through the URL', async () => {- renderAt('?tab=brain&brain=ask');- await screen.findByTestId('stub-ask');- fireEvent.click(screen.getByTestId('brain-tab-learnings'));- expect(await screen.findByTestId('stub-learnings')).toBeInTheDocument();- expect(screen.getByTestId('where')).toHaveTextContent('brain=learnings');+ renderAt('?tab=brain&brain=conversations');+ await screen.findByTestId('stub-conversations');+ fireEvent.click(screen.getByTestId('brain-tab-brain'));+ expect(await screen.findByTestId('stub-brain')).toBeInTheDocument();+ expect(screen.getByTestId('where')).toHaveTextContent('brain=brain');});- it('shows the off state on non-engine chips and links to the Engine chip', async () => {+ it('shows the off state on Conversations and links to the Provider chip', async () => {hoisted.engineGet.mockResolvedValue(OFF);- renderAt('?tab=brain&brain=brain');+ renderAt('?tab=brain&brain=conversations');expect(await screen.findByTestId('memory-off-state')).toHaveTextContent('Sign in or add a CortexDB key');- expect(screen.queryByTestId('stub-brain')).not.toBeInTheDocument();+ expect(screen.queryByTestId('stub-conversations')).not.toBeInTheDocument();fireEvent.click(screen.getByTestId('memory-off-open-engine'));expect(await screen.findByTestId('stub-engine')).toBeInTheDocument();expect(screen.getByTestId('where')).toHaveTextContent('brain=engine');@@ -201,12 +169,12 @@ describe('Memory page', () => {it('treats an unreadable engine as off, says why, and retries', async () => {hoisted.engineGet.mockRejectedValueOnce(new Error('core unreachable'));- renderAt('?tab=brain&brain=ask');+ renderAt('?tab=brain&brain=conversations');expect(await screen.findByTestId('memory-load-error')).toHaveTextContent('core unreachable');expect(screen.getByTestId('memory-off-state')).toBeInTheDocument();fireEvent.click(screen.getByTestId('memory-load-retry'));- expect(await screen.findByTestId('stub-ask')).toBeInTheDocument();+ expect(await screen.findByTestId('stub-conversations')).toBeInTheDocument();expect(screen.queryByTestId('memory-load-error')).not.toBeInTheDocument();});});