Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(server): the booted test app stubs the Nominatim reverse lookup instead of rebuilding the photo capture service

Maurice939b13859d7c
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<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;
}