From 939b13859d7c7f7ee493844ef263be7a9f42190a Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 10 Oct 2026 19:59:16 +0200 Subject: [PATCH] test(server): the booted test app stubs the Nominatim reverse lookup instead of rebuilding the photo capture service bootTestApp replaced JourneyPhotoCaptureService with a factory calling its constructor positionally, only to hand it an offline geocoder, so a dependency the service gained broke the boot of every MCP suite. The container now builds the service itself and the OsmClient's reverse lookup answers that nothing is known, which also keeps every other reverse lookup a booted suite reaches inside the process. --- server/scripts/test-new-service-baseline.json | 1 - server/tests/helpers/test-app.ts | 26 ++++++------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/server/scripts/test-new-service-baseline.json b/server/scripts/test-new-service-baseline.json index 9f3b986ae..99bc36d9b 100644 --- a/server/scripts/test-new-service-baseline.json +++ b/server/scripts/test-new-service-baseline.json @@ -8,7 +8,6 @@ "tests/helpers/sessions.ts": 1, "tests/helpers/storage-fixture.ts": 1, "tests/helpers/test-addons.ts": 1, - "tests/helpers/test-app.ts": 1, "tests/helpers/test-uow.ts": 3, "tests/integration/dayReorder.test.ts": 3, "tests/integration/mcp.test.ts": 2, diff --git a/server/tests/helpers/test-app.ts b/server/tests/helpers/test-app.ts index 3bff1e0a6..e1f27608a 100644 --- a/server/tests/helpers/test-app.ts +++ b/server/tests/helpers/test-app.ts @@ -13,8 +13,11 @@ * the same stand-ins the hand-built graphs used: * - RealtimeService: the suite's FakeRealtimeService (or a fresh one), so * broadcasts are recorded instead of delivered; - * - the reverse geocoder behind the journey photo capture, which would ask - * Nominatim for every attached provider photo; + * - the reverse geocoding OsmClient sends to Nominatim (the journey photo + * capture asks it for every attached provider photo): it answers that + * nothing is known. The instance's method is replaced after the build, so + * the container wires every consumer itself and a spy a suite sets on + * MapsService.prototype.reverseGeocode still wins; * - StorageService: a real local driver in a throwaway directory * (makeStorageFixture), so nothing a suite uploads lands in server/uploads. * @@ -25,22 +28,13 @@ * created on top of the module. */ import { AppModule } from '../../src/nest/app.module'; -import { JourneyDomainService } from '../../src/nest/journey/journey-domain.service'; -import { JourneyPhotoCaptureService } from '../../src/nest/journey/journey-photo-capture.service'; -import type { MapsService } from '../../src/nest/maps/maps.service'; -import { PhotoCaptureBackfillService } from '../../src/nest/memories/photo-capture-backfill.service'; +import { OsmClient } from '../../src/nest/maps/providers/osm.client'; import { RealtimeService } from '../../src/nest/realtime/realtime.service'; import { StorageService } from '../../src/nest/storage/storage.service'; import { FakeRealtimeService } from './fake-realtime'; import { makeStorageFixture } from './storage-fixture'; -import { MikroORM } from '@mikro-orm/core'; import { Test, type TestingModule } from '@nestjs/testing'; -/** The geocoder the capture asks for a place name: nothing known, without leaving the process. */ -const offlineGeocoder = { - reverseGeocode: async () => ({ name: null, address: null }), -} as unknown as MapsService; - const booted = new Map>(); async function boot(realtime: RealtimeService): Promise { @@ -49,13 +43,9 @@ async function boot(realtime: RealtimeService): Promise { .useValue(realtime) .overrideProvider(StorageService) .useValue(makeStorageFixture('').storage) - .overrideProvider(JourneyPhotoCaptureService) - .useFactory({ - factory: (backfill: PhotoCaptureBackfillService, journey: JourneyDomainService, orm: MikroORM) => - new JourneyPhotoCaptureService(backfill, journey, offlineGeocoder, orm), - inject: [PhotoCaptureBackfillService, JourneyDomainService, MikroORM], - }) .compile(); + // Reverse geocoding answers "nothing known" without leaving the process. + moduleRef.get(OsmClient, { strict: false }).reverse = async () => ({ name: null, address: null }); await moduleRef.init(); return moduleRef; }