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(share): sweep tests in the thumbnail job, tx and strict baselines follow the resolver split

Maurice09316025c3fc
diff --git a/client/scripts/strict-baseline.json b/client/scripts/strict-baseline.json
index 5e95cff2c..7776d1193 100644
--- a/client/scripts/strict-baseline.json
+++ b/client/scripts/strict-baseline.json
@@ -113,7 +113,6 @@
"src/pages/AtlasPage.tsx": 6,
"src/pages/FilesPage.tsx": 1,
"src/pages/JourneyDetailPage.tsx": 1,
- "src/pages/JourneyPublicPage.test.tsx": 1,
"src/pages/LoginPage.tsx": 1,
"src/pages/VacayPage.tsx": 1,
"src/pages/admin/useAdmin.ts": 4,
diff --git a/server/scripts/tx-writes-baseline.json b/server/scripts/tx-writes-baseline.json
index 91f80552f..717860f31 100644
--- a/server/scripts/tx-writes-baseline.json
+++ b/server/scripts/tx-writes-baseline.json
@@ -33,7 +33,6 @@
"src/nest/integrations/dawarich-sync.service.ts#DawarichSyncService.syncUserOnce": 3,
"src/nest/journey/journey.controller.ts#JourneyController.uploadEntryPhotos": 4,
"src/nest/memories/photo-resolver.service.ts#PhotoResolverService.streamCachedThumbnail": 3,
- "src/nest/memories/photo-resolver.service.ts#PhotoResolverService.streamPhoto": 2,
"src/nest/memories/synology.service.ts#SynologyService._fetchAllSynologyAlbums": 2,
"src/nest/memories/synology.service.ts#SynologyService._getSynologySession": 2,
"src/nest/memories/synology.service.ts#SynologyService._requestSynologyApi": 3,
diff --git a/server/src/nest/memories/photo-resolver.service.ts b/server/src/nest/memories/photo-resolver.service.ts
index 95038e6be..ace31f3a1 100644
--- a/server/src/nest/memories/photo-resolver.service.ts
+++ b/server/src/nest/memories/photo-resolver.service.ts
@@ -137,7 +137,12 @@ export class PhotoResolverService {
return true;
}
- /** The thumbnail row path, generated for a raster image that has none yet. */
+ /**
+ * The thumbnail row path, generated for a raster image that has none yet.
+ *
+ * @txStandalone an idempotent lazy provision: the row only records a
+ * thumbnail that already exists in storage, whatever the caller does next.
+ */
private async localThumbnail(photo: TrekPhoto): Promise<string | null> {
if (photo.thumbnail_path) return photo.thumbnail_path;
// Only raster images get a lazily-generated Jimp thumbnail; Jimp can't decode
diff --git a/server/tests/unit/nest/cache-sweep-jobs.test.ts b/server/tests/unit/nest/cache-sweep-jobs.test.ts
index 1c5a9054f..37ec6d07f 100644
--- a/server/tests/unit/nest/cache-sweep-jobs.test.ts
+++ b/server/tests/unit/nest/cache-sweep-jobs.test.ts
@@ -123,25 +123,6 @@ describe('PlacePhotoCacheJob', () => {
expect(() => job.sweep()).not.toThrow();
expect(logMock.logError).toHaveBeenCalledWith('Place-photo cache cleanup: fs down');
- const thumbsDown = make(
- () => {
- throw new Error('storage down');
- },
- true,
- 4,
- );
- await thumbsDown.job.sweep();
- // The copies are still swept after the thumbnail pass failed.
- expect(thumbsDown.publicMedia.sweepOrphans).toHaveBeenCalledTimes(1);
- expect(logMock.logInfo).toHaveBeenCalledWith(
- 'Public media cleanup: removed 4 location-free copies of deleted media',
- );
-
- await make(0, true, () => {
- throw new Error('bucket throttled');
- }).job.sweep();
- expect(logMock.logError).toHaveBeenCalledWith('Public media cleanup: bucket throttled');
-
const gated = make(0, false);
gated.job.onApplicationBootstrap();
expect(gated.cache.sweepOrphans).not.toHaveBeenCalled();
@@ -198,6 +179,25 @@ describe('JourneyThumbsJob', () => {
await job.sweep();
expect(logMock.logError).toHaveBeenCalledWith('Journey thumbnail cleanup: storage down');
+ const thumbsDown = make(
+ () => {
+ throw new Error('storage down');
+ },
+ true,
+ 4,
+ );
+ await thumbsDown.job.sweep();
+ // The copies are still swept after the thumbnail pass failed.
+ expect(thumbsDown.publicMedia.sweepOrphans).toHaveBeenCalledTimes(1);
+ expect(logMock.logInfo).toHaveBeenCalledWith(
+ 'Public media cleanup: removed 4 location-free copies of deleted media',
+ );
+
+ await make(0, true, () => {
+ throw new Error('bucket throttled');
+ }).job.sweep();
+ expect(logMock.logError).toHaveBeenCalledWith('Public media cleanup: bucket throttled');
+
const gated = make(0, false);
gated.job.onApplicationBootstrap();
expect(gated.thumbnails.sweepOrphanThumbs).not.toHaveBeenCalled();