mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fd48169219
Add and extend tests across 32 files (+10 595 lines) covering Admin panels (AuditLog, Backup, DevNotifications, GitHub), Collab (Chat, Notes, Panel, Polls), Planner (DayDetailPanel, DayPlanSidebar), Settings (DisplaySettings, Integrations, MapSettings), Files (FileManager, FilesPage), Map, Layout (DemoBanner, InAppNotificationBell), shared pickers (CustomDateTimePicker, CustomTimePicker), Vacay holidays, pages (Dashboard, Login), unit stores (authStore, inAppNotificationStore), API (authUrl, client integration), and i18n. Also updates sonar-project.properties and MSW trip handlers to support the new cases.
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import { http, HttpResponse } from 'msw';
|
|
import { buildTrip, buildDay, buildUser } from '../../factories';
|
|
|
|
export const tripsHandlers = [
|
|
// List all trips (active or archived)
|
|
http.get('/api/trips', ({ request }) => {
|
|
const url = new URL(request.url);
|
|
const archived = url.searchParams.get('archived');
|
|
if (archived) {
|
|
return HttpResponse.json({ trips: [] });
|
|
}
|
|
const trip1 = buildTrip({ title: 'Paris Adventure', start_date: '2026-07-01', end_date: '2026-07-10' });
|
|
const trip2 = buildTrip({ title: 'Tokyo Trip', start_date: '2026-09-01', end_date: '2026-09-15' });
|
|
return HttpResponse.json({ trips: [trip1, trip2] });
|
|
}),
|
|
|
|
http.get('/api/trips/:id', ({ params }) => {
|
|
const trip = buildTrip({ id: Number(params.id) });
|
|
return HttpResponse.json({ trip });
|
|
}),
|
|
|
|
http.get('/api/trips/:id/days', ({ params }) => {
|
|
const tripId = Number(params.id);
|
|
const day1 = buildDay({ trip_id: tripId, assignments: [], notes_items: [] });
|
|
const day2 = buildDay({ trip_id: tripId, assignments: [], notes_items: [] });
|
|
return HttpResponse.json({ days: [day1, day2] });
|
|
}),
|
|
|
|
http.put('/api/trips/:id', async ({ params, request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
const trip = buildTrip({ id: Number(params.id), ...body });
|
|
return HttpResponse.json({ trip });
|
|
}),
|
|
|
|
http.post('/api/trips', async ({ request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
const trip = buildTrip({ ...body });
|
|
return HttpResponse.json({ trip });
|
|
}),
|
|
|
|
http.get('/api/trips/:id/members', ({ params }) => {
|
|
const owner = buildUser();
|
|
return HttpResponse.json({ owner, members: [] });
|
|
}),
|
|
|
|
http.get('/api/trips/:id/accommodations', () => {
|
|
return HttpResponse.json({ accommodations: [] });
|
|
}),
|
|
|
|
http.delete('/api/trips/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/trips/:id/copy', async ({ params, request }) => {
|
|
const body = await request.json() as Record<string, unknown>;
|
|
const trip = buildTrip({ id: Number(params.id) + 1000, ...body });
|
|
return HttpResponse.json({ trip });
|
|
}),
|
|
];
|