Files
factory/lib/wiki-graph/tests/resolver.test.ts
vitya ca669d96e1 feat(lib): bundle MCP servers from .common/lib into factory/lib/
Copies source (no node_modules, dist, .tasks, .wiki, __pycache__) for:
- projects-meta-mcp v2.25.0 (TypeScript/Node)
- wiki-graph v0.3.1 (TypeScript/Node)
- interns-mcp v0.3.3 (Python/FastMCP)

.gitignore: exclude lib build artefacts (node_modules, dist, .venv, __pycache__, *.pyc)
bootstrap.ps1: add MCP build step — npm install+build for TS servers, venv+pip for Python

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 13:17:29 +03:00

47 lines
1.4 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import { buildSlugIndex, resolveTarget, type FileRef } from '../src/resolver.js';
const refs: FileRef[] = [
{ slug: 'clock-modulation', dir: 'concepts' },
{ slug: 'euclidean-rhythms', dir: 'concepts' },
{ slug: 'clock', dir: 'concepts' },
{ slug: 'clock', dir: 'entities' },
];
describe('resolveTarget', () => {
const index = buildSlugIndex(refs);
test('resolves an exact slug to its node id', () => {
expect(resolveTarget('euclidean-rhythms', 'concepts', index)).toEqual({
node: 'euclidean-rhythms',
collision: false,
});
});
test('matches case-insensitively, normalizing node id to lowercase', () => {
expect(resolveTarget('Clock-Modulation', 'concepts', index)).toEqual({
node: 'clock-modulation',
collision: false,
});
});
test('returns null for an unresolved (dangling) target', () => {
expect(resolveTarget('<todo-module>', 'concepts', index)).toBeNull();
expect(resolveTarget('does-not-exist', 'concepts', index)).toBeNull();
});
test('on basename collision prefers same-dir and flags collision', () => {
expect(resolveTarget('clock', 'entities', index)).toEqual({
node: 'clock',
collision: true,
});
});
test('on collision with no same-dir match still resolves and flags collision', () => {
expect(resolveTarget('clock', 'packages', index)).toEqual({
node: 'clock',
collision: true,
});
});
});