mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
fix(ci): the calendar query DTO as the contract it publishes, and two typed tests
feeds and trips import the calendar query DTO, so it lives in calendar.contract.ts rather than as calendar's internal dto file. The places controller tests pass the KML service in every call, and the revisit pill test builds a whole list.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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' } });
|
||||
|
||||
Reference in New Issue
Block a user