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.
This commit is contained in:
Maurice
2026-10-10 19:59:16 +02:00
parent ac918d362f
commit 939b13859d
2 changed files with 8 additions and 19 deletions
@@ -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,
+8 -18
View File
@@ -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<RealtimeService, Promise<TestingModule>>();
async function boot(realtime: RealtimeService): Promise<TestingModule> {
@@ -49,13 +43,9 @@ async function boot(realtime: RealtimeService): Promise<TestingModule> {
.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;
}