test(journey): pin the capture hint through the upload routes and the shared contract

This commit is contained in:
Maurice
2026-11-30 14:39:39 +01:00
parent 78c0f65de4
commit e59cd23e60
4 changed files with 31 additions and 4 deletions
+17
View File
@@ -5,6 +5,8 @@ import {
journeyContributorRequestSchema,
journeyContributorUpdateRequestSchema,
journeyPhotosDeleteToolSchema,
journeyEntryPhotoUploadRequestSchema,
journeyGalleryPhotoUploadRequestSchema,
journeyProviderPhotosRequestSchema,
journeyShareLinkRequestSchema,
journeyUpdateRequestSchema,
@@ -91,6 +93,21 @@ describe('journeyContributorUpdateRequestSchema', () => {
});
});
describe('photo upload capture fields (#3120)', () => {
it('takes the capture fields as strings beside the file, and no body at all', () => {
const fields = { taken_at: '2026-05-30T13:52:19.000Z', lat: '64.1466000', lng: '-21.9426000' };
expect(journeyGalleryPhotoUploadRequestSchema.safeParse(fields).success).toBe(true);
expect(journeyGalleryPhotoUploadRequestSchema.safeParse(undefined).success).toBe(true);
expect(journeyEntryPhotoUploadRequestSchema.safeParse({ caption: 'x', ...fields }).success).toBe(true);
});
it('refuses a field that is not a string or is far too long to be a time or a coordinate', () => {
expect(journeyGalleryPhotoUploadRequestSchema.safeParse({ lat: 64.1 }).success).toBe(false);
expect(journeyGalleryPhotoUploadRequestSchema.safeParse({ taken_at: 'x'.repeat(41) }).success).toBe(false);
expect(journeyEntryPhotoUploadRequestSchema.safeParse({ lng: 'y'.repeat(33) }).success).toBe(false);
});
});
describe('journeyPhotosDeleteToolSchema', () => {
it('takes one journey and 1 to 100 photo ids', () => {
expect(journeyPhotosDeleteToolSchema.safeParse({ journeyId: 1, journey_photo_ids: [2, 3] }).success).toBe(true);