MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / fakeSource

Function fakeSource

graph-ui/src/projects/ProjectsPanel.test.tsx:48–96  ·  view source on GitHub ↗
(jobs: () => IndexJob[] = () => [])

Source from the content-addressed store, hash-verified

46});
47
48function fakeSource(jobs: () => IndexJob[] = () => []): ProjectsSource & { calls: Record<string, unknown[][]> } {
49 const calls: Record<string, unknown[][]> = {};
50 const record = <T,>(name: string, impl: (...args: never[]) => T) => (...args: never[]): T => {
51 (calls[name] ??= []).push(args);
52 return impl(...args);
53 };
54 return {
55 calls,
56 listProjects: record('listProjects', async () => PROJECTS),
57 projectHealth: record('projectHealth', async () => ({
58 status: 'healthy' as const,
59 nodes: 76,
60 edges: 179,
61 sizeBytes: 1572864,
62 reason: '',
63 })),
64 deleteProject: record('deleteProject', async () => undefined),
65 browse: record('browse', async (path: string) => ({
66 path: path.length > 0 ? path : '/home',
67 dirs: ['repo-a', 'repo-b'],
68 parent: '/',
69 roots: [],
70 })),
71 startIndex: record('startIndex', async (path: string) => ({ slot: 0, path })),
72 indexJobs: record('indexJobs', async () => jobs()),
73 adr: record('adr', async () => ({ hasAdr: true, content: '# old record', updatedAt: '2026-09-05 10:00' })),
74 saveAdr: record('saveAdr', async () => undefined),
75 logs: record('logs', async () => ({ lines: ['line one', 'line two'], total: 40 })),
76 uiLogTail: record('uiLogTail', async () => ({
77 path: '/cache/logs/ui.log',
78 previousPath: '',
79 sizeBytes: 512,
80 partial: false,
81 lines: [
82 '{"received":"2026-09-08T10:00:00Z","ts":"2026-09-08T10:00:00.000Z","level":"error","source":"rpc","message":"get_code_snippet: HTTP 500","detail":"oom"}',
83 'not json at all',
84 ],
85 total: 2,
86 })),
87 processes: record('processes', async () => ({
88 selfPid: 42,
89 selfRssMb: 120.5,
90 processes: [
91 { pid: 42, cpu: 0.2, rssMb: 120.5, elapsed: '00:10', command: 'codebase-memory-mcp', isSelf: true },
92 { pid: 43, cpu: 12.5, rssMb: 900, elapsed: '01:00', command: 'codebase-memory-mcp', isSelf: false },
93 ],
94 })),
95 };
96}
97
98beforeEach(() => {
99 (globalThis as unknown as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;

Callers 2

renderFunction · 0.70

Calls 1

recordFunction · 0.70

Tested by

no test coverage detected