/
GreyCat
/
openhuman
Обзор
Документация
Войти
/
GreyCat
/
openhuman
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/src/components/intelligence/NamespaceOverviewTab.test.tsx
49 строк
2 KB
Aashir Athar
feat(intelligence): add Namespace Overview (#2964)
30 май 2026, 19:45
Не верифицирован
30 май 2026, 19:45
6c3ad63
Код
Авторство
О чём код?
import { render, screen, waitFor } from '@testing-library/react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { computeNamespaceOverview } from '../../lib/memory/namespaceOverview'; import type { GraphRelation } from '../../utils/tauriCommands/memory'; import NamespaceOverviewTab from './NamespaceOverviewTab'; const mockLoad = vi.fn(); vi.mock('../../services/api/namespaceOverviewApi', () => ({ loadNamespaceOverview: (...args: unknown[]) => mockLoad(...args), })); function rel(namespace: string | null, subject: string, object: string): GraphRelation { return { namespace, subject, predicate: 'p', object, attrs: {}, updatedAt: 0, evidenceCount: 1, orderIndex: null, documentIds: [], chunkIds: [], }; } const report = computeNamespaceOverview([rel('work', 'A', 'B')]); describe('<NamespaceOverviewTab />', () => { beforeEach(() => { mockLoad.mockReset(); mockLoad.mockResolvedValue(report); }); it('loads on mount and renders the per-namespace list', async () => { render(<NamespaceOverviewTab />); await waitFor(() => expect(screen.getByText('By namespace')).toBeInTheDocument()); expect(mockLoad).toHaveBeenCalledTimes(1); }); it('surfaces an error when the load fails', async () => { mockLoad.mockReset(); mockLoad.mockRejectedValueOnce(new Error('graph unavailable')); render(<NamespaceOverviewTab />); await waitFor(() => expect(screen.getByRole('alert').textContent).toMatch(/graph unavailable/)); }); });