Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(mem0): use the real bundled binding in hook reload control
Co-authored-by: Qwen-Coder <[email protected]>
  • Loading branch information
yiliang114 and qwencoder committed Sep 29, 2026
commit cc0b66000fd3bca92dcd855c93dc909c933f8abb
24 changes: 16 additions & 8 deletions packages/cli/src/ui/commands/hooksCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ import { hooksCommand } from './hooksCommand.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';

import { SettingScope } from '../../config/settings.js';
import { createBundledMem0Server } from '../../config/mem0-settings.js';

vi.mock('node:fs', async (importOriginal) => {
const actual = await importOriginal<typeof import('node:fs')>();
return {
...actual,
existsSync: (path: string) =>
path.replaceAll('\\', '/').endsWith('/mem0/main.js') ||
actual.existsSync(path),
};
});

describe('hooksCommand', () => {
let mockContext: ReturnType<typeof createMockCommandContext>;
Expand Down Expand Up @@ -201,17 +212,14 @@ describe('hooksCommand', () => {

it('does not file a repository-authored external-context server under system hooks', async () => {
const { context, config } = makeReloadContext();
// Control arm first: an unscoped entry — the shape
// createBundledMem0Server returns — *is* merged, which proves the reload
// Control arm first: the actual bundled server *is* merged, proving reload
// path really reads getMcpServers()['external-context'] and the negative
// arm below is not passing vacuously.
config.getMcpServers.mockReturnValue({
'external-context': {
command: process.execPath,
args: ['/bundle/mem0/main.js'],
env: { QWEN_BUNDLED_MEM0_CONFIG: '{}' },
includeTools: ['context_search', 'context_remember'],
},
'external-context': createBundledMem0Server(
{ baseUrl: 'https://mem0.example', enableWrites: true },
process.cwd(),
),
});

await hooksCommand.action!(context, '');
Expand Down
Loading