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.

fix(ci): the calendar query DTO as the contract it publishes, and two typed tests

Mauriced6799d12058f
diff --git a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
index d965bd944..0188a6a32 100644
--- a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
+++ b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
@@ -58,7 +58,10 @@ describe('collection answer cards', () => {
});
it('FE-AI-COLL-040: the places to revisit have a pill of their own in the head, in the visited tone (#2567)', () => {
- draw([placesCard({ list: { ...placesCard().list, counts: { idea: 3, want: 5, visited: 4, revisit: 7 } } })]);
+ const list = { ...placesCard().list, counts: { idea: 3, want: 5, visited: 4, revisit: 7 } } as NonNullable<
+ ReturnType<typeof placesCard>['list']
+ >;
+ draw([placesCard({ list })]);
const card = screen.getByRole('region', { name: 'Saved places in Paris food' });
const pill = within(card).getByText('Want to revisit').parentElement as HTMLElement;
expect(within(pill).getByText('7')).toBeInTheDocument();
diff --git a/server/src/nest/calendar/calendar.dto.ts b/server/src/nest/calendar/calendar.contract.ts
similarity index 100%
rename from server/src/nest/calendar/calendar.dto.ts
rename to server/src/nest/calendar/calendar.contract.ts
diff --git a/server/src/nest/feeds/feeds.controller.ts b/server/src/nest/feeds/feeds.controller.ts
index ee8ff443b..5b033cfb5 100644
--- a/server/src/nest/feeds/feeds.controller.ts
+++ b/server/src/nest/feeds/feeds.controller.ts
@@ -4,7 +4,7 @@ import type { User } from '../../types';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { Public } from '../auth-core/public.decorator';
-import { TripCalendarQueryDto } from '../calendar/calendar.dto';
+import { TripCalendarQueryDto } from '../calendar/calendar.contract';
import { calendarOptionsFromQuery } from '../calendar/calendar.service';
import { contentDisposition } from '../common/content-disposition';
import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';
diff --git a/server/src/nest/trips/trips.controller.ts b/server/src/nest/trips/trips.controller.ts
index 3fe78f521..2f647eb2f 100644
--- a/server/src/nest/trips/trips.controller.ts
+++ b/server/src/nest/trips/trips.controller.ts
@@ -5,7 +5,7 @@ import { AuditService } from '../audit/audit.service';
import { getClientIp } from '../audit/client-ip';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
-import { TripCalendarQueryDto } from '../calendar/calendar.dto';
+import { TripCalendarQueryDto } from '../calendar/calendar.contract';
import { CalendarService, calendarOptionsFromQuery } from '../calendar/calendar.service';
import { contentDisposition } from '../common/content-disposition';
import { isDemoWriteBlocked, DEMO_WRITE_ERROR } from '../common/demo-write';
diff --git a/server/tests/unit/nest/places.controller.test.ts b/server/tests/unit/nest/places.controller.test.ts
index 96d58e977..03c581e52 100644
--- a/server/tests/unit/nest/places.controller.test.ts
+++ b/server/tests/unit/nest/places.controller.test.ts
@@ -109,6 +109,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ canEdit: vi.fn().mockReturnValue(false) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).create(user, '5', { name: 'Spot' }),
),
).toEqual({ status: 403, body: { error: 'No permission' } });
@@ -164,6 +165,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ importGpx: vi.fn().mockReturnValue(null) } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).importGpx(user, '5', file, {}),
),
).toEqual({
@@ -469,6 +471,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ removeMany } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).bulkDelete(user, '5', { ids: [] }),
).toEqual({ deleted: [], count: 0, tourPlaceIds: [] });
expect(removeMany).not.toHaveBeenCalled();
@@ -599,6 +602,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ verifyTripAccess: vi.fn().mockReturnValue(undefined) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).bulkUpdate(user, '5', { ids: [1], category_id: 3 }),
),
).toEqual({ status: 404, body: { error: 'Trip not found' } });
@@ -608,6 +612,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ canEdit: vi.fn().mockReturnValue(false) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).bulkUpdate(user, '5', { ids: [1], category_id: 3 }),
),
).toEqual({ status: 403, body: { error: 'No permission' } });
@@ -631,6 +636,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ updateMany } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).bulkUpdate(user, '5', { ids: [] }),
).toEqual({ updated: [], count: 0 });
expect(updateMany).not.toHaveBeenCalled();
@@ -672,6 +678,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ get: vi.fn().mockReturnValue(undefined) } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).get(user, '5', '9'),
),
).toEqual({ status: 404, body: { error: 'Place not found' } });
@@ -688,6 +695,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ update: vi.fn().mockReturnValue(null) } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).update(user, '5', '9', { name: 'X' }),
),
).toEqual({ status: 404, body: { error: 'Place not found' } });
@@ -769,6 +777,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ update } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).update(user, '5', '9', { route_color: null });
expect(update).toHaveBeenLastCalledWith('5', '9', expect.objectContaining({ route_color: null }), undefined);
});
@@ -780,6 +789,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ update } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).update(user, '5', '9', { route_color: '#abc' }),
).toEqual({ place: { id: 9 } });
});
@@ -906,6 +916,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ remove, onDeleted } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).remove(user, '5', '9'),
),
).toEqual({ status: 404, body: { error: 'Place not found' } });
@@ -1025,6 +1036,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ verifyTripAccess: vi.fn().mockReturnValue(undefined) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).uploadImage(user, '5', '9', file),
),
).toEqual({ status: 404, body: { error: 'Trip not found' } });
@@ -1034,6 +1046,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ canEdit: vi.fn().mockReturnValue(false) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).uploadImage(user, '5', '9', file),
),
).toEqual({ status: 403, body: { error: 'No permission' } });
@@ -1059,6 +1072,7 @@ describe('PlacesController (parity with the legacy /api/trips/:tripId/places rou
svc({ update: vi.fn().mockReturnValue(null) } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).uploadImage(user, '5', '9', file),
),
).toEqual({ status: 404, body: { error: 'Place not found' } });
@@ -1116,6 +1130,7 @@ describe('PUT /:id/image/from-file (#1242)', () => {
svc({ setImageFromFile: vi.fn().mockResolvedValue(result), ...extra } as Partial<PlacesService>),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
);
expect(await thrownAsync(() => make('not_found').imageFromFile(user, '5', '9', { file_id: 3 }))).toEqual({
status: 404,
@@ -1155,6 +1170,7 @@ describe('PUT /:id/image/from-file (#1242)', () => {
svc({ canEdit: vi.fn().mockReturnValue(false) }),
new RuntimeEnvService(),
storageStub,
+ kmlStub,
).imageFromFile(user, '5', '9', { file_id: 3 }),
),
).toEqual({ status: 403, body: { error: 'No permission' } });