fix(client): the audit round over the 4.3.1 release

Ride minutes and late marks follow an edited timetable instead of the routing
that fetched them; a landing day's join band reads as the ride it is rather
than a nine hour drive of no length; the refuel offer is there on the road
out of a terminal or a pick-up desk; the phone's stage map draws the ride;
the share page numbers its stops the way the planner does; the PDF lists a
day the way the day plan lists it, from both shells; a poster-less clip draws
its play badge everywhere, not only in the editor; the hero title has room
for its descenders and the list card keeps its badge clear; the release
notice keeps its close control in reach when it stacks; a link chip's actions
are thumb-sized and its delete asks first; the Google retry line and the
Google-only switch appear only where Google answers.
This commit is contained in:
Maurice
2026-09-22 12:10:21 +02:00
parent cb85ba915c
commit 85b5756e89
78 changed files with 2476 additions and 486 deletions
+1
View File
@@ -187,6 +187,7 @@ export function buildPlanner(overrides: Partial<TripPlanner> = {}): TripPlanner
// resolveVisibleConnectionIds returns an array, and consumers call .includes().
visibleConnections: [] as number[],
roadtripConnections: [] as number[],
toggleConnection: vi.fn(),
allConnectionsShown: false,
toggleAllConnections: vi.fn(),
@@ -347,6 +347,35 @@ describe('MAdminSettingsSection', () => {
expect(admin.setPlacesDetailsEnabledState).toHaveBeenLastCalledWith(true);
});
it('FE-MOB-ASET-018b: the Google-only row says what it needs without a key and toggles through the hook', async () => {
const user = userEvent.setup();
const admin = renderSettings();
await user.click(screen.getByRole('button', { name: 'What the key is used for' }));
expect(screen.getByText(/Needs a Google Maps API key/)).toBeInTheDocument();
expect(toggle('Search with Google only')).toHaveAttribute('aria-checked', 'false');
await user.click(toggle('Search with Google only'));
expect(admin.handleTogglePlacesGoogleOnly).toHaveBeenCalledTimes(1);
});
it('FE-MOB-ASET-018c: with a key the Google-only row explains what it changes, unless another provider holds the slot', async () => {
const user = userEvent.setup();
const { unmount } = render(<Harness admin={buildAdminHook({ hasMapsKey: true, placesGoogleOnly: true })} />);
await user.click(screen.getByRole('button', { name: 'What the key is used for' }));
expect(screen.getByText(/Every search and every suggestion goes to Google Places/)).toBeInTheDocument();
expect(toggle('Search with Google only')).toHaveAttribute('aria-checked', 'true');
unmount();
// The server ignores the switch under Amap or OpenStreetMap, and the row
// must not promise otherwise just because a key is stored.
render(<Harness admin={buildAdminHook({ hasMapsKey: true, placesGoogleOnly: true, placesProvider: 'amap' })} />);
await user.click(screen.getByRole('button', { name: 'What the key is used for' }));
expect(screen.queryByText(/Every search and every suggestion goes to Google Places/)).not.toBeInTheDocument();
expect(screen.queryByText(/Needs a Google Maps API key/)).not.toBeInTheDocument();
const row = toggle('Search with Google only').closest<HTMLElement>('.justify-between')!;
expect(row.textContent).toMatch(/provider/i);
});
it('FE-MOB-ASET-019: the API-keys card is about keys, and weather needs none', () => {
// The Open-Meteo panel left this card, as it did on the desktop tab: it takes
// no key and has nothing to configure, so it had no business in a card about
@@ -1,4 +1,4 @@
// FE-MOB-JDET-001 to FE-MOB-JDET-037
// FE-MOB-JDET-001 to FE-MOB-JDET-039
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { render, screen, fireEvent, waitFor, act } from '../../../helpers/render';
import MJourneyDetail from '../../../../src/mobile/screens/journey/MJourneyDetail';
@@ -317,6 +317,15 @@ describe('MJourneyDetail', () => {
expect(document.querySelector('.absolute.inset-0.flex.items-center')).toBeInTheDocument();
});
it('FE-MOB-JDET-039: a provider clip shows the poster the provider serves, as the desktop gallery does', () => {
// A provider row never records a local thumbnail path, so the check the desktop
// shares (posterlessVideo) must be the one used here too (#2341 follow-up).
const gallery = [buildGalleryPhoto({ media_type: 'video', provider: 'immich', asset_id: 'a1', thumbnail_path: null })];
setup({ view: 'gallery', current: buildDetail({ gallery }) });
expect(document.querySelector('img[src="/api/photos/900/thumbnail"]')).toBeInTheDocument();
expect(document.querySelector('svg.lucide-play')).toBeInTheDocument();
});
it('FE-MOB-JDET-014: uploading from the device sends the picked files and reloads', async () => {
const { hook, container } = setup({ view: 'gallery' });
const input = container.ownerDocument.querySelector('input[type="file"]') as HTMLInputElement;
@@ -1306,3 +1306,29 @@ describe('MJourneyEntrySheet external photos', () => {
expect(onSave.mock.calls[0][0]).toMatchObject({ type: 'entry' });
});
});
// FE-MOB-JENTRY-055 to FE-MOB-JENTRY-056: the phone half of the desktop editor's
// play badge for a clip that came up without a poster (#2341).
describe('MJourneyEntrySheet clips', () => {
it('FE-MOB-JENTRY-055: a linked clip without a poster is a play badge, not a request for its thumbnail', () => {
const clip = { ...buildPhoto(100), media_type: 'video', provider: 'local', thumbnail_path: null };
mountSheet(buildEntry({ id: 5, photos: [clip] }));
expect(document.querySelector('img[src="/api/photos/100/thumbnail"]')).not.toBeInTheDocument();
expect(document.querySelector('.h-16 svg.lucide-play')).toBeInTheDocument();
});
it('FE-MOB-JENTRY-056: the gallery picker draws the same badge, and a clip with a poster its poster', async () => {
const user = userEvent.setup();
const bare = { ...buildGalleryPhoto(200), media_type: 'video', provider: 'local', thumbnail_path: null };
const withPoster = { ...buildGalleryPhoto(201), media_type: 'video', provider: 'local', thumbnail_path: 'journey/poster.jpg' };
mountSheet(buildEntry(), { galleryPhotos: [bare, withPoster] });
await user.click(screen.getByRole('button', { name: 'From Gallery' }));
expect(document.querySelector('img[src="/api/photos/200/thumbnail"]')).not.toBeInTheDocument();
expect(document.querySelector('img[src="/api/photos/201/thumbnail"]')).toBeInTheDocument();
expect(document.querySelectorAll('svg.lucide-play')).toHaveLength(1);
});
});
@@ -94,6 +94,10 @@ describe('MExportSheet', () => {
expect(arg.trip).toBe(planner.trip)
expect(arg.days).toBe(planner.days)
expect(arg.places).toBe(planner.places)
// The raw store, not the hook's filtered list: the export applies the plan's
// own predicate, and the switch travels with it.
expect(arg.assignments).toBe(planner.storedAssignments)
expect(arg.showServiceStops).toBe(true)
expect(arg.reservations).toBe(planner.reservations)
expect(arg.categories).toBe(planner.categories)
// dayNotes come out of the store keyed by day, flattened with a numeric day_id.
@@ -14,7 +14,7 @@ import type { AlternativeOverlay } from '../../../../src/components/Roadtrip/alt
import type { LegAlternatives } from '../../../../src/components/Roadtrip/useRouteAlternatives'
import { RT_ALT_BAR_LIFT } from '../../../../src/mobile/screens/trip/roadtrip/useMRtAlternatives'
// FE-MOB-MAPAREA-001 to FE-MOB-MAPAREA-035
// FE-MOB-MAPAREA-001 to FE-MOB-MAPAREA-037
//
// The stage's pins come out of the trip store rather than the planner's map list, so the
// stage fixtures seed the store and leave `mapPlaces` to stand for what the plan tab shows.
@@ -764,4 +764,37 @@ describe('MMapArea', () => {
expect((mocks.props.places as Place[]).map(p => p.id)).toEqual([11, 20, 21])
expect(mocks.props.places).not.toBe(planner.roadtripMapPlaces)
})
it('FE-MOB-MAPAREA-037: on the stage a seamed ride draws as its booking, whether or not it was toggled on', () => {
// The ride's own leg carries no geometry (carrierLeg), so the booking's arc is the
// only thing that joins the two terminals on the map. The planner folds the seamed
// bookings into `roadtripConnections`; the stage has to read that list, not the
// plan tab's toggles, or the road ends at the departure gate and picks up again at
// the arrival with nothing between.
const base = stagePlanner(3)
const [hamburg] = stageDay().stops
const terminal = (role: 'departure' | 'arrival') => ({
...hamburg,
assignmentId: role === 'departure' ? -3000000140 : -3000000141,
placeId: -70,
name: role === 'departure' ? 'Hamburg Airport' : 'Munich Airport',
carrier: { reservationId: 70, type: 'flight', role, title: 'LH 2020', code: null, at: null },
})
const seamed = { ...stageDay(), stops: [hamburg, terminal('departure'), terminal('arrival')] } as unknown as RoadtripDay
const planner = {
...base,
roadtripRoutes: { ...base.roadtripRoutes, days: [seamed] },
visibleConnections: [],
roadtripConnections: [70],
} as TripPlanner
const shell = stageShell()
const { rerender } = render(<MMapArea planner={planner} shell={shell} />)
expect(mocks.props.visibleConnectionIds).toEqual([70])
// The plan tab keeps the traveller's own toggles, as the desktop does off road trip mode.
rerender(<MMapArea planner={planner} shell={{ ...shell, trTab: 'plan' }} />)
expect(mocks.props.visibleConnectionIds).toBe(planner.visibleConnections)
expect(mocks.props.visibleConnectionIds).toEqual([])
})
})
@@ -1,15 +1,15 @@
import { describe, expect, it, vi } from 'vitest'
import { fireEvent, render, screen } from '../../../helpers/render'
import {
RtAutoRow, RtDryRow, RtLegRow, RtSpillRow, RtStopRow, type RowChrome,
RtAutoRow, RtBookingChips, RtDryRow, RtLegRow, RtRideRow, RtSpillRow, RtStopRow, type RowChrome,
} from '../../../../src/mobile/screens/trip/roadtrip/MRoadtripRows'
import type { StopRow } from '../../../../src/components/Roadtrip/roadtripRowModel'
import type { RouteSegment, ScheduleWarning } from '@trek/shared/roadtrip'
import type { TranslationFn } from '../../../../src/types'
import type { RoadtripRow, StopRow } from '../../../../src/components/Roadtrip/roadtripRowModel'
import type { CarrierTerminal, RouteSegment, ScheduleWarning } from '@trek/shared/roadtrip'
import type { Reservation, TranslationFn } from '../../../../src/types'
import type { RefuelSearch } from '../../../../src/components/Roadtrip/useRefuelSearch'
import type { RefuelCandidate } from '../../../../src/components/Roadtrip/refuelSuggestion'
// FE-MOB-RTROW-001 to FE-MOB-RTROW-049
// FE-MOB-RTROW-001 to FE-MOB-RTROW-055
// Same echo strategy as tests/helpers/mobileTrip: assertions stay on keys, not copy.
const t: TranslationFn = (key, params) =>
@@ -237,6 +237,143 @@ describe('RtStopRow', () => {
expect(screen.getByText('roadtrip.warn.overnight')).toBeInTheDocument()
expect(container.querySelector('.lucide-moon')).not.toBeNull()
})
it('FE-MOB-RTROW-050: a hire desk is a row on the road: the booking\'s clock under it, no number, and a disc nobody can turn into a pump', () => {
const onPickKind = vi.fn()
const desk = stopRow({
number: null,
time: '09:00',
stop: { ...stopRow().stop, assignmentId: -3000000180, placeId: -90, name: 'Sixt Hauptbahnhof', carrier: carrier('pickup') },
})
const { container } = render(<RtStopRow row={desk} chrome={chrome} onOpen={vi.fn()} onPickKind={onPickKind} />)
expect(screen.getByText('Sixt Hauptbahnhof')).toBeInTheDocument()
expect(screen.getByText('roadtrip.ride.pickup:09:00')).toBeInTheDocument()
expect(screen.queryByText('2')).toBeNull()
// The booking's own icon on the disc, and the disc is not a control even for an
// editor: nobody turns a rental desk into a petrol station.
expect(container.querySelector('.lucide-car')).not.toBeNull()
expect(screen.queryByRole('button', { name: 'roadtrip.stop.makeService' })).toBeNull()
expect(screen.queryByRole('button', { name: 'roadtrip.stop.kind' })).toBeNull()
expect(screen.getAllByRole('button')).toHaveLength(1)
})
})
/** One end of a flight, or one desk of a hire car, as the routing round seams it in. */
function carrier(role: CarrierTerminal['role'], over: Partial<CarrierTerminal> = {}): CarrierTerminal {
const car = role === 'pickup' || role === 'return'
return {
reservationId: car ? 90 : 70,
type: car ? 'car' : 'flight',
role,
title: car ? 'Sixt Hamburg' : 'LH 2020',
code: role === 'departure' ? 'HAM' : role === 'arrival' ? 'MUC' : null,
at: { departure: '13:20', arrival: '14:30', pickup: '09:00', return: '11:30' }[role],
...over,
}
}
const FLIGHT_SEG = { ...SEG, distance: 0, duration: 4200, distanceText: '', durationText: '1 h 10 min' }
function rideRow(over: Partial<Extract<RoadtripRow, { kind: 'ride' }>> = {}): Extract<RoadtripRow, { kind: 'ride' }> {
const end = (role: 'departure' | 'arrival'): StopRow => stopRow({
number: null,
time: role === 'departure' ? '12:20' : '14:30',
pinned: true,
stop: {
...stopRow().stop,
assignmentId: role === 'departure' ? -3000000140 : -3000000141,
placeId: -70,
name: role === 'departure' ? 'Hamburg Airport' : 'Munich Airport',
carrier: carrier(role),
},
})
return { kind: 'ride', index: 1, carrier: carrier('departure'), seg: FLIGHT_SEG, departure: end('departure'), arrival: end('arrival'), ...over }
}
describe('RtRideRow', () => {
it('FE-MOB-RTROW-051: a ride is one block: the booking and its minutes over both terminals, each with its code, its timetable line and its clock', () => {
render(<RtRideRow row={rideRow()} chrome={chrome} />)
expect(screen.getByText('LH 2020 · 1 h 10 min')).toBeInTheDocument()
expect(screen.getByText('Hamburg Airport')).toBeInTheDocument()
expect(screen.getByText('HAM')).toBeInTheDocument()
expect(screen.getByText('roadtrip.ride.departure:13:20')).toBeInTheDocument()
expect(screen.getByText('12:20')).toBeInTheDocument()
expect(screen.getByText('Munich Airport')).toBeInTheDocument()
expect(screen.getByText('MUC')).toBeInTheDocument()
expect(screen.getByText('roadtrip.ride.arrival:14:30')).toBeInTheDocument()
expect(screen.getByText('14:30')).toBeInTheDocument()
// The terminals take no number: Hamburg is 1 and Munich is 2 either side of them.
expect(screen.queryByText('2')).toBeNull()
})
it('FE-MOB-RTROW-052: the block is one tap target that opens the booking, and plain without a handler', () => {
const onOpen = vi.fn()
const opens = render(<RtRideRow row={rideRow()} chrome={chrome} onOpen={onOpen} />)
// One control for the whole ride, not one per terminal.
expect(screen.getAllByRole('button')).toHaveLength(1)
fireEvent.click(screen.getByText('Hamburg Airport'))
fireEvent.click(screen.getByText('LH 2020 · 1 h 10 min'))
expect(onOpen).toHaveBeenCalledTimes(2)
opens.unmount()
render(<RtRideRow row={rideRow()} chrome={chrome} />)
expect(screen.queryByRole('button')).toBeNull()
expect(screen.getByText('Munich Airport')).toBeInTheDocument()
})
it('FE-MOB-RTROW-053: a ride the timetable gives no minutes for is still the booking, and its clocks follow the twelve hour setting', () => {
render(<RtRideRow row={rideRow({ seg: undefined })} chrome={{ ...chrome, is12h: true }} />)
expect(screen.getByText('LH 2020')).toBeInTheDocument()
expect(screen.queryByText(/LH 2020 ·/)).toBeNull()
expect(screen.getByText('roadtrip.ride.departure:1:20 PM')).toBeInTheDocument()
expect(screen.getByText('12:20 PM')).toBeInTheDocument()
expect(screen.queryByText('13:20')).toBeNull()
})
})
describe('RtBookingChips', () => {
const booking = (over: Partial<Reservation> = {}): Reservation =>
({ id: 11, trip_id: 1, title: 'Tisch Bullerei', type: 'restaurant', status: 'confirmed', day_id: 2, reservation_time: '2026-10-05T19:30', ...over }) as Reservation
it('FE-MOB-RTROW-054: a chip per booking with its name and its clock, each opening its booking, and plain without a handler', () => {
const onOpen = vi.fn()
const bookings = [booking(), booking({ id: 13, title: 'Elbphilharmonie', type: 'event', reservation_time: null })]
const opens = render(<RtBookingChips bookings={bookings} chrome={{ ...chrome, is12h: true }} canEdit onOpen={onOpen} />)
expect(screen.getByText('Tisch Bullerei')).toBeInTheDocument()
// The clock in the reader's own format, and none at all for a booking without one.
expect(screen.getByText('7:30 PM')).toBeInTheDocument()
expect(screen.queryByText('19:30')).toBeNull()
expect(screen.getByText('Elbphilharmonie')).toBeInTheDocument()
expect(screen.getAllByRole('button')).toHaveLength(2)
fireEvent.click(screen.getByText('Tisch Bullerei'))
expect(onOpen).toHaveBeenCalledWith(bookings[0])
opens.unmount()
render(<RtBookingChips bookings={bookings} chrome={chrome} canEdit />)
expect(screen.queryByRole('button')).toBeNull()
expect(screen.getByText('19:30')).toBeInTheDocument()
})
it('FE-MOB-RTROW-055: a reader who may not edit bookings gets a plain table chip and a transport chip that still opens', () => {
const onOpen = vi.fn()
const bookings = [booking(), booking({ id: 16, title: 'Taxi to the pier', type: 'taxi', reservation_time: null })]
render(<RtBookingChips bookings={bookings} chrome={chrome} canEdit={false} onOpen={onOpen} />)
// A transport has a detail view anybody may look at; a table has only its editor,
// so the chip stays a chip rather than a button that does nothing (#2012).
expect(screen.getByText('Tisch Bullerei').closest('button')).toBeNull()
fireEvent.click(screen.getByText('Tisch Bullerei'))
expect(onOpen).not.toHaveBeenCalled()
fireEvent.click(screen.getByText('Taxi to the pier'))
expect(onOpen).toHaveBeenCalledWith(bookings[1])
expect(screen.getAllByRole('button')).toHaveLength(1)
})
})
describe('RtLegRow', () => {
@@ -5,11 +5,11 @@ import { resetAllStores, seedStore } from '../../../helpers/store'
import { useTripStore } from '../../../../src/store/tripStore'
import MRoadtripTab from '../../../../src/mobile/screens/trip/roadtrip/MRoadtripTab'
import type { MTripShellApi, TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
import type { Day, Place } from '../../../../src/types'
import type { RoadtripDay, RoadtripRoutes, RouteSegment } from '@trek/shared/roadtrip'
import type { Day, Place, Reservation } from '../../../../src/types'
import type { CarrierTerminal, RoadtripDay, RoadtripRoutes, RoadtripStop, RouteSegment } from '@trek/shared/roadtrip'
import type { LegAlternatives } from '../../../../src/components/Roadtrip/useRouteAlternatives'
// FE-MOB-RTTAB-001 to FE-MOB-RTTAB-053
// FE-MOB-RTTAB-001 to FE-MOB-RTTAB-057
//
// The stage bar pictures the place its day ends at. It reads that place out of the trip
// store rather than the planner, the unfiltered list, so the picture tests seed the store.
@@ -734,6 +734,134 @@ describe('MRoadtripTab', () => {
})
})
// The rides and the hire car the routing round seams into the day, and the day's
// other bookings (#2428). The rows themselves are pinned in MRoadtripRows.test; this
// is the wiring: which sheet a tap on them opens, and for whom.
describe('a ride, a hire desk and the day\'s bookings', () => {
const entry = (arrival: string, departure: string | null = arrival) => ({ arrival, departure, anchored: true, dayOffset: 0 })
const real = (assignmentId: number, placeId: number, name: string): RoadtripStop => ({
assignmentId, ownerDayId: 2, ownerIndex: 0, placeId, name,
lat: 53.55, lng: 9.99, time: null, dwellMinutes: null, legMode: null, incomingLegMode: null, stopType: null,
} as unknown as RoadtripStop)
// A synthetic stop, keyed off its booking the way the routing round keys it.
const terminal = (carrier: CarrierTerminal, name: string): RoadtripStop => ({
...real(-(carrier.reservationId * 10 + (carrier.role === 'departure' || carrier.role === 'pickup' ? 0 : 1)), -carrier.reservationId, name),
carrier,
})
const flight = (role: 'departure' | 'arrival'): CarrierTerminal =>
({ reservationId: 70, type: 'flight', role, title: 'LH 2020', code: null, at: role === 'departure' ? '13:20' : '14:30' })
const desk = (role: 'pickup' | 'return'): CarrierTerminal =>
({ reservationId: 90, type: 'car', role, title: 'Sixt Hamburg', code: null, at: role === 'pickup' ? '09:00' : '11:30' })
/** Kyoto Station, a flight to Munich, then Munich: the ride is one block between two numbered stops. */
const flightStage = () => stage({
stops: [
real(503, 103, 'Kyoto Station'),
terminal(flight('departure'), 'Hamburg Airport'),
terminal(flight('arrival'), 'Munich Airport'),
real(505, 105, 'Munich'),
],
legs: [seg('12 km', '20 min'), { ...seg('', '1 h 10 min'), distance: 0, duration: 4200 }, seg('30 km', '35 min')],
schedule: { entries: [entry('09:00'), entry('12:20', '13:20'), entry('14:30'), entry('15:30')], warnings: [] },
legVias: [[], [], []], driveWarnings: [], spills: [], dryPoints: [],
})
/** A hire car picked up before the first stop: the desk is a row of its own on the road. */
const rentalStage = () => stage({
stops: [terminal(desk('pickup'), 'Sixt Hauptbahnhof'), real(503, 103, 'Kyoto Station'), real(505, 105, 'Munich')],
legs: [seg('12 km', '20 min'), seg('30 km', '35 min')],
schedule: { entries: [entry('09:00'), entry('09:20', '09:50'), entry('10:50')], warnings: [] },
legVias: [[], []], driveWarnings: [], spills: [], dryPoints: [],
})
const booking = (over: Partial<Reservation>): Reservation =>
({ id: 1, trip_id: 7, title: 'Booking', type: 'restaurant', status: 'confirmed', day_id: 2, ...over }) as Reservation
it('FE-MOB-RTTAB-054: a tap on a terminal opens its booking in the transport sheet, and no kind is offered on it', () => {
const { shell } = renderTab(planner({ roadtripRoutes: routes({ days: [rentalStage()] }) }))
fireEvent.click(screen.getByText('Sixt Hauptbahnhof'))
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 90 })
expect(shell.openSheet).not.toHaveBeenCalledWith('rtstop', expect.anything())
// The desk is unnumbered and its disc is no control: only the two real stops
// offer to become a stop on the way, and the count says two.
expect(screen.getAllByRole('button', { name: 'roadtrip.stop.makeService' })).toHaveLength(2)
expect(screen.getByText('roadtrip.ride.pickup:09:00')).toBeInTheDocument()
expect(screen.getByText('roadtrip.day.stopCount:2')).toBeInTheDocument()
})
it('FE-MOB-RTTAB-055: a ride is one block that opens its booking, between the two stops it joins', () => {
const { shell } = renderTab(planner({ roadtripRoutes: routes({ days: [flightStage()] }) }))
expect(screen.getByText('LH 2020 · 1 h 10 min')).toBeInTheDocument()
expect(screen.getByText('roadtrip.ride.departure:13:20')).toBeInTheDocument()
expect(screen.getByText('roadtrip.ride.arrival:14:30')).toBeInTheDocument()
// Kyoto is 1 and Munich is 2: the terminals between them take no number.
expect(screen.getByText('1')).toBeInTheDocument()
expect(screen.getByText('2')).toBeInTheDocument()
expect(screen.queryByText('3')).toBeNull()
fireEvent.click(screen.getByText('Munich Airport'))
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 70 })
expect(shell.openSheet).toHaveBeenCalledTimes(1)
})
it('FE-MOB-RTTAB-056: a table hangs under its stop as a chip, one booked for no stop is listed under the day, and the night is neither', () => {
const reservations = [
booking({ id: 11, title: 'Tisch Bullerei', reservation_time: '2026-05-02T19:30', assignment_id: 503 }),
booking({ id: 13, title: 'Elbphilharmonie', type: 'event', reservation_time: '2026-05-02T20:00', place_id: 999 }),
booking({ id: 14, title: 'Tomorrow', type: 'event', day_id: 1, place_id: 105 }),
booking({ id: 15, title: 'Hotel Hafen', type: 'hotel', place_id: 105 }),
]
const p = planner({ roadtripRoutes: routes({ days: [flightStage()] }), reservations })
const { shell } = renderTab(p)
const kyoto = screen.getByText('Kyoto Station').closest('[role="button"]') as HTMLElement
// The chip sits in the block right after its stop's row.
expect(within(kyoto.nextElementSibling as HTMLElement).getByText('Tisch Bullerei')).toBeInTheDocument()
expect(screen.getByText('19:30')).toBeInTheDocument()
expect(screen.getByText('roadtrip.bookings.loose')).toBeInTheDocument()
expect(screen.getByText('Elbphilharmonie')).toBeInTheDocument()
// Another day's booking is not this day's, and the night is the stay, not a chip.
expect(screen.queryByText('Tomorrow')).toBeNull()
expect(screen.queryByText('Hotel Hafen')).toBeNull()
// The chips are the stop's, not stops: the count stays at two.
expect(screen.getByText('roadtrip.day.stopCount:2')).toBeInTheDocument()
// A chip opens its booking in the editor, the way the place sheet opens a linked one.
fireEvent.click(screen.getByText('Tisch Bullerei'))
expect(p.setEditingReservation).toHaveBeenCalledWith(reservations[0])
expect(p.setShowReservationModal).toHaveBeenCalledWith(true)
expect(shell.openSheet).not.toHaveBeenCalled()
})
it('FE-MOB-RTTAB-057: a transport chip goes to the transport sheet, and a table is not even a button for a member who may not edit bookings', () => {
const reservations = [
booking({ id: 16, title: 'Taxi to the pier', type: 'taxi', reservation_time: '2026-05-02T08:15', assignment_id: 503 }),
booking({ id: 13, title: 'Elbphilharmonie', type: 'event', place_id: 999 }),
]
const p = planner({
roadtripRoutes: routes({ days: [flightStage()] }),
reservations,
can: (action: string) => action !== 'reservation_edit',
})
const { shell } = renderTab(p)
fireEvent.click(screen.getByText('Taxi to the pier'))
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 16 })
// The event has only its editor, which this member may not open, so the chip is a
// plain chip and not a control that does nothing when tapped (#2012).
expect(screen.getByText('Elbphilharmonie').closest('button')).toBeNull()
fireEvent.click(screen.getByText('Elbphilharmonie'))
expect(p.setEditingReservation).not.toHaveBeenCalled()
expect(p.setShowReservationModal).not.toHaveBeenCalled()
expect(shell.openSheet).toHaveBeenCalledTimes(1)
})
})
describe('day swipe', () => {
it('FE-MOB-RTTAB-027: steps the stage without refitting the map, and announces the day it landed on', () => {
const p = planner()
@@ -2,11 +2,13 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { HttpResponse, delay, http } from 'msw'
import PlPlaceSearch from '../../../../src/mobile/screens/trip/sheets/PlPlaceSearch'
import type { TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
import { useAuthStore } from '../../../../src/store/authStore'
import { buildPlanner } from '../../../helpers/mobileTrip'
import { server } from '../../../helpers/msw/server'
import { fireEvent, render, screen, waitFor } from '../../../helpers/render'
import { resetAllStores, seedStore } from '../../../helpers/store'
// FE-MOB-PLSRCH-001 to FE-MOB-PLSRCH-018
// FE-MOB-PLSRCH-001 to FE-MOB-PLSRCH-022b
// planner.t echoes the key, so labels/toasts are asserted as their keys.
const LOUVRE = {
@@ -41,6 +43,21 @@ function recordSearch(places: unknown[] = [LOUVRE]) {
})
}
/**
* The index answers with the wrong place; only a search sent to Google on
* purpose answers with the right one. The real source strings, so the test
* pins what the line under the list actually switches on.
*/
function recordGoogleRetry() {
return http.post('/api/maps/search', async ({ request }) => {
const body = await request.json() as Record<string, unknown>
searchBodies.push(body)
return body.provider === 'google'
? HttpResponse.json({ places: [{ name: 'Tokyo Station', address: 'Chiyoda', lat: 35.68, lng: 139.77 }], source: 'google' })
: HttpResponse.json({ places: [{ name: 'Weigh station', address: 'Ritzville', lat: 47.1, lng: -118.4 }], source: 'trek-places+openstreetmap' })
})
}
function setup(plannerOverrides: Partial<TripPlanner> = {}, locationBias?: Parameters<typeof PlPlaceSearch>[0]['locationBias']) {
const onPick = vi.fn()
const onResolvingChange = vi.fn()
@@ -54,6 +71,7 @@ function setup(plannerOverrides: Partial<TripPlanner> = {}, locationBias?: Param
describe('PlPlaceSearch', () => {
beforeEach(() => {
resetAllStores()
autocompleteBodies = []
searchBodies = []
})
@@ -410,4 +428,72 @@ describe('PlPlaceSearch', () => {
fireEvent.blur(input)
await waitFor(() => expect(screen.queryByText('Louvre')).not.toBeInTheDocument())
})
it('FE-MOB-PLSRCH-019: a list the index answered offers Google instead, and the line sends the same query there alone', async () => {
seedStore(useAuthStore, { hasMapsKey: true })
server.use(recordGoogleRetry())
const { input } = setup()
fireEvent.change(input, { target: { value: 'Tokyo Station' } })
fireEvent.keyDown(input, { key: 'Enter' })
expect(await screen.findByText('Weigh station')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'places.searchGoogleInstead' }))
expect(await screen.findByText('Tokyo Station')).toBeInTheDocument()
expect(searchBodies[0]).not.toHaveProperty('provider')
expect(searchBodies[1]).toMatchObject({ query: 'Tokyo Station', provider: 'google' })
// A list Google produced has nowhere further to go.
expect(screen.queryByRole('button', { name: 'places.searchGoogleInstead' })).not.toBeInTheDocument()
})
it('FE-MOB-PLSRCH-020: without a Google key the list offers nothing', async () => {
server.use(recordGoogleRetry())
const { input } = setup()
fireEvent.change(input, { target: { value: 'Tokyo Station' } })
fireEvent.keyDown(input, { key: 'Enter' })
expect(await screen.findByText('Weigh station')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'places.searchGoogleInstead' })).not.toBeInTheDocument()
})
it('FE-MOB-PLSRCH-021: a key alone is not enough: with Amap or OpenStreetMap picked the list offers nothing', async () => {
// The server only honours the request while Google holds the keyed slot;
// under another provider the line would re-run the same search and stay.
seedStore(useAuthStore, { hasMapsKey: true, placesProvider: 'amap' })
server.use(recordGoogleRetry())
const { input } = setup()
fireEvent.change(input, { target: { value: 'Tokyo Station' } })
fireEvent.keyDown(input, { key: 'Enter' })
expect(await screen.findByText('Weigh station')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'places.searchGoogleInstead' })).not.toBeInTheDocument()
})
it('FE-MOB-PLSRCH-022: the line sends the query the list came from, whatever the field holds by then', async () => {
seedStore(useAuthStore, { hasMapsKey: true })
server.use(recordAutocomplete([]), recordGoogleRetry())
const { input } = setup()
fireEvent.change(input, { target: { value: 'Tokyo Station' } })
fireEvent.keyDown(input, { key: 'Enter' })
expect(await screen.findByText('Weigh station')).toBeInTheDocument()
// The list stays while the field is retyped; the line still means this list.
fireEvent.change(input, { target: { value: 'Kyoto' } })
fireEvent.click(screen.getByRole('button', { name: 'places.searchGoogleInstead' }))
expect(await screen.findByText('Tokyo Station')).toBeInTheDocument()
expect(searchBodies).toHaveLength(2)
expect(searchBodies[1]).toMatchObject({ query: 'Tokyo Station', provider: 'google' })
})
it('FE-MOB-PLSRCH-022b: the line still works after the field was cleared', async () => {
seedStore(useAuthStore, { hasMapsKey: true })
server.use(recordGoogleRetry())
const { input } = setup()
fireEvent.change(input, { target: { value: 'Tokyo Station' } })
fireEvent.keyDown(input, { key: 'Enter' })
expect(await screen.findByText('Weigh station')).toBeInTheDocument()
// An empty field used to make the tap a silent no-op.
fireEvent.change(input, { target: { value: '' } })
fireEvent.click(screen.getByRole('button', { name: 'places.searchGoogleInstead' }))
expect(await screen.findByText('Tokyo Station')).toBeInTheDocument()
expect(searchBodies[1]).toMatchObject({ query: 'Tokyo Station', provider: 'google' })
})
})
@@ -1,5 +1,6 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { useTripStore } from '../../../src/store/tripStore';
import { applyStayStops } from '../../../src/store/stayStops';
import { resetAllStores } from '../../helpers/store';
import { buildDay, buildAssignment, buildPlace } from '../../helpers/factories';
import type { Assignment } from '../../../src/types';
@@ -237,13 +238,13 @@ describe('remoteEventHandler > assignments', () => {
});
it('FE-WSEVT-ASSIGN-014: assignment:moved drops a stale copy already sitting on the target day', () => {
const moved = buildAssignment({ id: 100, day_id: 20 });
const moved = buildAssignment({ id: 100, day_id: 20, order_index: 1 });
useTripStore.setState({
days: [buildDay({ id: 10 }), buildDay({ id: 20 })],
assignments: {
'10': [moved],
// The target day still holds the previous copy plus an unrelated item.
'20': [buildAssignment({ id: 100, day_id: 20 }), buildAssignment({ id: 200, day_id: 20 })],
'20': [buildAssignment({ id: 100, day_id: 20 }), buildAssignment({ id: 200, day_id: 20, order_index: 0 })],
},
});
useTripStore.getState().handleRemoteEvent({
@@ -254,9 +255,135 @@ describe('remoteEventHandler > assignments', () => {
});
const target = useTripStore.getState().assignments['20'];
expect(target.map(a => a.id)).toEqual([200, 100]);
expect(target.map(a => a.order_index)).toEqual([0, 1]);
expect(useTripStore.getState().assignments['10']).toHaveLength(0);
});
// #2410: a stop arrives with the seat the server gave it, and the client puts it
// there rather than at the end of the day, the way the local move reducer does.
describe('seating by order_index', () => {
const seedDay = () => {
useTripStore.setState({
days: [buildDay({ id: 10 })],
assignments: {
'10': [
buildAssignment({ id: 100, day_id: 10, order_index: 0 }),
buildAssignment({ id: 101, day_id: 10, order_index: 1 }),
],
},
});
};
const day = () => useTripStore.getState().assignments['10'];
it('FE-WSEVT-ASSIGN-017: assignment:created at index 0 lands first and the others move up one', () => {
seedDay();
useTripStore.getState().handleRemoteEvent({
type: 'assignment:created',
assignment: buildAssignment({ id: 200, day_id: 10, order_index: 0 }),
});
expect(day().map(a => a.id)).toEqual([200, 100, 101]);
expect(day().map(a => a.order_index)).toEqual([0, 1, 2]);
});
it('FE-WSEVT-ASSIGN-018: an index past the end appends, and the rows already seated keep their identity', () => {
seedDay();
const [first, second] = day();
useTripStore.getState().handleRemoteEvent({
type: 'assignment:created',
assignment: buildAssignment({ id: 200, day_id: 10, order_index: 9 }),
});
expect(day().map(a => a.id)).toEqual([100, 101, 200]);
expect(day().map(a => a.order_index)).toEqual([0, 1, 2]);
expect(day()[0]).toBe(first);
expect(day()[1]).toBe(second);
});
it('FE-WSEVT-ASSIGN-019: a day held out of order is sorted before the seat is counted', () => {
useTripStore.setState({
days: [buildDay({ id: 10 })],
assignments: {
'10': [
buildAssignment({ id: 101, day_id: 10, order_index: 1 }),
buildAssignment({ id: 100, day_id: 10, order_index: 0 }),
],
},
});
useTripStore.getState().handleRemoteEvent({
type: 'assignment:created',
assignment: buildAssignment({ id: 200, day_id: 10, order_index: 1 }),
});
expect(day().map(a => a.id)).toEqual([100, 200, 101]);
expect(day().map(a => a.order_index)).toEqual([0, 1, 2]);
});
it('FE-WSEVT-ASSIGN-020: assignment:moved seats the row on its new day the same way', () => {
useTripStore.setState({
days: [buildDay({ id: 10 }), buildDay({ id: 20 })],
assignments: {
'10': [buildAssignment({ id: 300, day_id: 10, order_index: 0 })],
'20': [
buildAssignment({ id: 100, day_id: 20, order_index: 0 }),
buildAssignment({ id: 101, day_id: 20, order_index: 1 }),
],
},
});
useTripStore.getState().handleRemoteEvent({
type: 'assignment:moved',
assignment: buildAssignment({ id: 300, day_id: 20, order_index: 0 }),
oldDayId: 10,
newDayId: 20,
});
const { assignments } = useTripStore.getState();
expect(assignments['10']).toEqual([]);
expect(assignments['20'].map(a => a.id)).toEqual([300, 100, 101]);
expect(assignments['20'].map(a => a.order_index)).toEqual([0, 1, 2]);
});
it('FE-WSEVT-ASSIGN-021: a night re-seated on its own day moves within it rather than doubling', () => {
// A check-in given a new hour arrives as assignment:moved with oldDayId === newDayId.
useTripStore.setState({
days: [buildDay({ id: 10 })],
assignments: {
'10': [
buildAssignment({ id: 100, day_id: 10, order_index: 0 }),
buildAssignment({ id: 12, day_id: 10, order_index: 1, accommodation_id: 7 }),
buildAssignment({ id: 101, day_id: 10, order_index: 2 }),
],
},
});
useTripStore.getState().handleRemoteEvent({
type: 'assignment:moved',
assignment: buildAssignment({ id: 12, day_id: 10, order_index: 0, accommodation_id: 7 }),
oldDayId: 10,
newDayId: 10,
});
expect(day().map(a => a.id)).toEqual([12, 100, 101]);
expect(day().map(a => a.order_index)).toEqual([0, 1, 2]);
});
it('FE-WSEVT-ASSIGN-022: the answer a session without a socket folds in seats the moved night as well', () => {
// The HTTP answer carries no assignment:reordered behind it, so the seat has to be
// right from the moved event alone.
useTripStore.setState({
days: [buildDay({ id: 10 }), buildDay({ id: 20 })],
assignments: {
'10': [buildAssignment({ id: 12, day_id: 10, order_index: 0, accommodation_id: 7 })],
'20': [
buildAssignment({ id: 100, day_id: 20, order_index: 0 }),
buildAssignment({ id: 101, day_id: 20, order_index: 1 }),
],
},
});
applyStayStops({
movedAssignment: { assignment: buildAssignment({ id: 12, day_id: 20, order_index: 0, accommodation_id: 7 }), oldDayId: 10 },
});
const { assignments } = useTripStore.getState();
expect(assignments['10']).toEqual([]);
expect(assignments['20'].map(a => a.id)).toEqual([12, 100, 101]);
expect(assignments['20'].map(a => a.order_index)).toEqual([0, 1, 2]);
});
});
it('FE-WSEVT-ASSIGN-015: assignment:reordered drops ids that are no longer on the day', () => {
useTripStore.setState({
days: [buildDay({ id: 10 })],