diff --git a/client/src/components/Planner/bookings/useReservationListFilter.ts b/client/src/components/Planner/bookings/useReservationListFilter.ts index 104e9cb3e..ac8ff4c2e 100644 --- a/client/src/components/Planner/bookings/useReservationListFilter.ts +++ b/client/src/components/Planner/bookings/useReservationListFilter.ts @@ -1,7 +1,20 @@ import { useState } from 'react'; import type { Day, Reservation } from '../../../types'; -import { groupTransports, onTravelers } from './bookingsModel'; +import { groupTransports, onTravelers, type StatusGroups } from './bookingsModel'; + +/** + * The status sections both tabs list, in their order, leaving out the empty ones. + * Bookings never fill `transit`, so that section only ever shows among transports. + */ +export function listSections(groups: StatusGroups, t: (key: string) => string) { + return [ + { id: 'confirmed', label: t('reservations.confirmed'), rows: groups.confirmed }, + { id: 'pending', label: t('reservations.pending'), rows: groups.pending }, + { id: 'transit', label: t('reservations.type.transit'), rows: groups.transit }, + { id: 'past', label: t('reservations.past'), rows: groups.past }, + ].filter((s) => s.rows.length > 0); +} /** * The traveller filter and the folded sections of the phone's bookings and diff --git a/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx b/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx index 6890790a6..79e3c6e69 100644 --- a/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx +++ b/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx @@ -10,7 +10,7 @@ import { CardGrid, Field, ReservationPluginSlots, SectionHeader, StatusDot, TabS import { STATUS_COLOR, type MTabScreenProps } from './tabModel' import { cardWhen, parseTransportMeta, timeRange } from './transportsModel' import { BOOKING_TYPE_COLOR, hotelStayTimes } from '../../../../components/Planner/bookings/bookingsModel' -import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter' +import { listSections, useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter' import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard' import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs' import { filesFor } from '../../../../utils/reservationFiles' @@ -33,11 +33,7 @@ export default function MBookingsTab({ planner, shell }: MTabScreenProps) { } = useReservationListFilter(allBookings, days, planner.tripMembers.length) const canEdit = planner.can('reservation_edit', planner.trip) - const sections = [ - { id: 'confirmed', label: t('reservations.confirmed'), rows: groups.confirmed }, - { id: 'pending', label: t('reservations.pending'), rows: groups.pending }, - { id: 'past', label: t('reservations.past'), rows: groups.past }, - ].filter(s => s.rows.length > 0) + const sections = listSections(groups, t) return ( diff --git a/client/src/mobile/screens/trip/tabs/MTransportsTab.tsx b/client/src/mobile/screens/trip/tabs/MTransportsTab.tsx index 1db470c3c..b1b57fe09 100644 --- a/client/src/mobile/screens/trip/tabs/MTransportsTab.tsx +++ b/client/src/mobile/screens/trip/tabs/MTransportsTab.tsx @@ -8,7 +8,7 @@ import { CardGrid, Field, ReservationPluginSlots, SectionHeader, StatusDot, TabS import { STATUS_COLOR, type MTabScreenProps } from './tabModel' import { cardWhen, parseTransportMeta } from './transportsModel' import { TRANSPORT_TYPE_COLOR } from '../../../../components/Planner/bookings/bookingsModel' -import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter' +import { listSections, useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter' import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard' import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs' import { filesFor } from '../../../../utils/reservationFiles' @@ -30,12 +30,7 @@ export default function MTransportsTab({ planner, shell }: MTabScreenProps) { } = useReservationListFilter(allTransports, days, planner.tripMembers.length) const canEdit = planner.can('day_edit', planner.trip) - const sections = [ - { id: 'confirmed', label: t('reservations.confirmed'), rows: groups.confirmed }, - { id: 'pending', label: t('reservations.pending'), rows: groups.pending }, - { id: 'transit', label: t('reservations.type.transit'), rows: groups.transit }, - { id: 'past', label: t('reservations.past'), rows: groups.past }, - ].filter(s => s.rows.length > 0) + const sections = listSections(groups, t) return ( diff --git a/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx b/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx index 4562fd658..08ba32b64 100644 --- a/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx +++ b/client/tests/unit/mobile/collections/MCollPlaceSheet.test.tsx @@ -204,6 +204,8 @@ describe('MCollPlaceSheet', () => { ], category_id: 3, label_ids: [11, 12], + // No notes on this place, and none written (#3168). + notes: null, })) // Back to the read view. await waitFor(() => expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument()) diff --git a/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx b/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx index 9f4dafa8f..39f4e8196 100644 --- a/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx +++ b/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx @@ -1011,13 +1011,14 @@ describe('MJourneyEntrySheet reading view', () => { it('FE-MOB-JENTRY-062: the photos of a saved entry can be dragged into order, a reader cannot move them (#2851)', () => { const entry = buildEntry({ id: 5, photos: [buildPhoto(100), buildPhoto(101)] }); - const { container, unmount } = mountSheet(entry); - expect(container.querySelector('[data-touch-drag]')).not.toBeNull(); - expect(container.querySelectorAll('[draggable="true"]').length).toBeGreaterThanOrEqual(2); + // The sheet is portalled to the body, so the rendered container holds none of it. + const { unmount } = mountSheet(entry); + expect(document.querySelector('[data-touch-drag]')).not.toBeNull(); + expect(document.querySelectorAll('[draggable="true"]').length).toBeGreaterThanOrEqual(2); unmount(); - const read = mountSheet(entry, { readOnly: true }); - expect(read.container.querySelector('[data-touch-drag]')).toBeNull(); + mountSheet(entry, { readOnly: true }); + expect(document.querySelector('[data-touch-drag]')).toBeNull(); }); it('FE-MOB-JENTRY-061: a viewer without the editor keeps the locked sheet it always had', () => {