From af85d3979976ef8f12fc5aad05b85441dc7e3864 Mon Sep 17 00:00:00 2001 From: jubnl Date: Mon, 17 Aug 2026 06:32:32 +0200 Subject: [PATCH] test(server): close slice-4 gaps surfaced by the full tier --- server/tests/unit/nest/collab.service.test.ts | 19 +++++++++++++++++++ .../nest/place-enrichment.service.test.ts | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/server/tests/unit/nest/collab.service.test.ts b/server/tests/unit/nest/collab.service.test.ts index ecb0cee68..d85d84854 100644 --- a/server/tests/unit/nest/collab.service.test.ts +++ b/server/tests/unit/nest/collab.service.test.ts @@ -461,6 +461,25 @@ describe('hardening', () => { expect(testDb.prepare('SELECT COUNT(*) as c FROM collab_notes WHERE id = ?').get(note.id)).toEqual({ c: 1 }); }); + it('COLLAB-SVC-036: a failing storage delete is swallowed — note + file deletes still succeed', async () => { + const { user1, trip } = setup(); + const dbs = new DatabaseService(testDb); + const failingStorage = { delete: vi.fn().mockRejectedValue(new Error('EACCES')) }; + const failing = new CollabService(dbs, new PermissionsService(dbs), new RealtimeService(), notificationsStub(), failingStorage as unknown as import('../../../src/nest/storage/storage.service').StorageService); + const note = failing.createNote(trip.id, user1.id, { title: 'Sticky file' }); + testDb.prepare('INSERT INTO trip_files (trip_id, note_id, filename, original_name) VALUES (?, ?, ?, ?)') + .run(trip.id, note.id, 'stuck.pdf', 'stuck.pdf'); + const fileId = (testDb.prepare('SELECT id FROM trip_files WHERE note_id = ?').get(note.id) as { id: number }).id; + + expect(await failing.deleteNoteFile(trip.id, note.id, fileId)).toBe(true); + expect(testDb.prepare('SELECT COUNT(*) as c FROM trip_files WHERE id = ?').get(fileId)).toEqual({ c: 0 }); + + testDb.prepare('INSERT INTO trip_files (trip_id, note_id, filename, original_name) VALUES (?, ?, ?, ?)') + .run(trip.id, note.id, 'stuck2.pdf', 'stuck2.pdf'); + expect(await failing.deleteNote(trip.id, note.id)).toBe(true); + expect(testDb.prepare('SELECT COUNT(*) as c FROM collab_notes WHERE id = ?').get(note.id)).toEqual({ c: 0 }); + }); + it('COLLAB-SVC-036: getFormattedNoteById is trip-scoped and null-safe', () => { const { user1, trip } = setup(); const otherTrip = createTrip(testDb, user1.id); diff --git a/server/tests/unit/nest/place-enrichment.service.test.ts b/server/tests/unit/nest/place-enrichment.service.test.ts index 7754088a4..ba1e62555 100644 --- a/server/tests/unit/nest/place-enrichment.service.test.ts +++ b/server/tests/unit/nest/place-enrichment.service.test.ts @@ -668,17 +668,17 @@ describe('creditLine', () => { ); }); - it('ENRICH-029: reads a stored credit back by cache key', () => { + it('ENRICH-029: reads a stored credit back by cache key', async () => { const cache = cacheStub({ get: vi.fn((key: string) => - key === 'ChIJmuseum~p0' ? { photoUrl: '/x', filePath: '/tmp/x', attribution: 'Alice · CC BY-SA 4.0' } : null, + key === 'ChIJmuseum~p0' ? { photoUrl: '/x', attribution: 'Alice · CC BY-SA 4.0' } : null, ), }); const svc = make(mapsStub(), cache); - expect(svc.credit('ChIJmuseum~p0')).toEqual({ credit: 'Alice · CC BY-SA 4.0' }); + expect(await svc.credit('ChIJmuseum~p0')).toEqual({ credit: 'Alice · CC BY-SA 4.0' }); // An uploaded image or a key that was swept has nothing to name. - expect(svc.credit('unknown')).toEqual({ credit: null }); + expect(await svc.credit('unknown')).toEqual({ credit: null }); }); });