Files
TREK/server/tests/helpers/mcp-test-controllers.ts
Maurice 6ce15157a1 test(server): MCP suites run on the booted container and unit suites take services from their module
createTestModule (tests/helpers/test-module.ts) builds a Nest testing module of the domain modules under test over the suite's test db, with a FakeRealtimeService and provider overrides for the collaborators a suite controls. bootTestApp (tests/helpers/test-app.ts) boots AppModule once per file, with recording realtime, fixture storage and an offline geocoder, and the MCP harness takes McpRegistryService from it inside a request context instead of hand-wiring roughly eighty services. The days, day removal and day notes service suites take their subjects from DaysModule and DayNotesModule.
2026-10-10 20:16:11 +02:00

21 lines
999 B
TypeScript

import { McpRegistryService, type McpRegistry } from '../../src/nest-mcp';
import type { RealtimeService } from '../../src/nest/realtime/realtime.service';
import { bootTestApp } from './test-app';
/**
* The MCP registry the MCP harness attaches, taken from the booted
* application container (tests/helpers/test-app.ts): the same
* McpRegistryService production builds, with every @McpController the
* container discovers and the policy AppModule hands McpModule.forRoot (the
* access policy, the demo tool gate, the error mapper).
*
* It used to be a hand-wired copy of that graph, one positional constructor
* call per service, which every new dependency broke. Booting the container
* once per file costs about what building the copy did per harness.
*
* Pass the suite's FakeRealtimeService to assert on broadcasts.
*/
export async function createMcpTestRegistry(realtime?: RealtimeService): Promise<McpRegistry> {
return (await bootTestApp(realtime)).get(McpRegistryService);
}