Files
factory/lib/projects-meta-mcp/tests/tools/workers.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

50 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { makeWorkersTools } from '../../src/tools/workers.js';
describe('worker.register (stub)', () => {
const tool = makeWorkersTools().find((t) => t.name === 'worker.register')!;
it('exists and documents itself as a stub', () => {
expect(tool).toBeDefined();
expect(tool.description.toLowerCase()).toContain('stub');
});
it('returns a 501 not-implemented verdict for valid input', async () => {
const r = await tool.handler({
machine: 'win11',
runtime: 'claude-opus',
capabilities: ['needs-db'],
});
expect(r.isError).toBe(true);
const body = JSON.parse(r.content[0].text);
expect(body.ok).toBe(false);
expect(body.reason).toBe('not-implemented');
expect(typeof body.hint).toBe('string');
expect(body.hint.length).toBeGreaterThan(0);
});
it('keeps the verdict for optional endpoint + confirm (no side-effects)', async () => {
const r = await tool.handler({
machine: 'win11',
runtime: 'claude-opus',
capabilities: [],
endpoint: 'https://node/agent',
confirm: true,
});
const body = JSON.parse(r.content[0].text);
expect(body.reason).toBe('not-implemented');
});
it('rejects malformed input — missing machine', async () => {
await expect(
tool.handler({ runtime: 'claude-opus', capabilities: [] }),
).rejects.toThrow();
});
it('rejects malformed input — capabilities not an array', async () => {
await expect(
tool.handler({ machine: 'm', runtime: 'r', capabilities: 'nope' }),
).rejects.toThrow();
});
});