mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
fix(mobile): a booking opens its detail sheet first, as a transport and the desktop do; Wallet and Map buttons read short
Bookings in the Bookings tab, the day sheet, a place's sheet and the road trip opened their editor straight away, while a transport showed its details with a pencil to edit. Every booking now opens the same detail sheet; its edit and delete follow the booking's own permission (reservation_edit for a stay, a table or a ticket, day_edit for a transport). Notes keep opening for editing, as on the desktop. The wallet button reads "Wallet" (its accessible name still says which one), and "On map" reads "Map" in every language.
This commit is contained in:
@@ -201,13 +201,12 @@ describe('MBookingsTab', () => {
|
||||
expect(within(card).getAllByText('—')).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('FE-MOB-BKTAB-012: opens the reservation editor from the row', () => {
|
||||
it('FE-MOB-BKTAB-012: a tap on the card shows the booking first, as a transport and the desktop do', () => {
|
||||
const p = planner()
|
||||
renderTab(p)
|
||||
const { shell } = renderTab(p)
|
||||
fireEvent.click(screen.getByText('Sushi Saito'))
|
||||
expect(p.can).toHaveBeenCalledWith('reservation_edit', p.trip)
|
||||
expect(p.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 202 }))
|
||||
expect(p.setShowReservationModal).toHaveBeenCalledWith(true)
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 202 })
|
||||
expect(p.setShowReservationModal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-BKTAB-013: opens the same editor from the pencil', () => {
|
||||
@@ -217,10 +216,11 @@ describe('MBookingsTab', () => {
|
||||
expect(p.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 201 }))
|
||||
})
|
||||
|
||||
it('FE-MOB-BKTAB-014: a read-only member gets no editor and no actions', () => {
|
||||
it('FE-MOB-BKTAB-014: a read-only member may look at a booking but gets no editor and no actions', () => {
|
||||
const p = planner({ can: vi.fn(() => false) as unknown as TripPlanner['can'] })
|
||||
renderTab(p)
|
||||
const { shell } = renderTab(p)
|
||||
fireEvent.click(screen.getByText('Sushi Saito'))
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 202 })
|
||||
expect(p.setShowReservationModal).not.toHaveBeenCalled()
|
||||
expect(screen.queryByRole('button', { name: 'common.edit' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'common.delete' })).not.toBeInTheDocument()
|
||||
|
||||
@@ -315,14 +315,14 @@ describe('MDaySheet', () => {
|
||||
expect(screen.queryByText('Opera (other day)')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Hotel Sacher booking')).not.toBeInTheDocument()
|
||||
|
||||
// Each booking opens its detail sheet first, with the pencil there, as on the desktop.
|
||||
fireEvent.click(screen.getByText('Train to Salzburg'))
|
||||
expect(planner.setEditingTransport).toHaveBeenCalledWith(expect.objectContaining({ id: 22 }))
|
||||
expect(planner.setShowTransportModal).toHaveBeenCalledWith(true)
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 22 })
|
||||
|
||||
fireEvent.click(screen.getByText('Dinner at Figlmueller'))
|
||||
expect(planner.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 21 }))
|
||||
expect(planner.setShowReservationModal).toHaveBeenCalledWith(true)
|
||||
expect(shell.closeSheet).toHaveBeenCalledTimes(2)
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 21 })
|
||||
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
|
||||
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-DAYSH-021: a booking row does nothing without the matching permission', async () => {
|
||||
@@ -332,7 +332,7 @@ describe('MDaySheet', () => {
|
||||
fireEvent.click(screen.getByText('Train to Salzburg'))
|
||||
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
|
||||
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
|
||||
expect(shell.closeSheet).not.toHaveBeenCalled()
|
||||
expect(shell.openSheet).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-DAYSH-022: renders notes sorted, splits a leading time off the detail line, and routes taps', async () => {
|
||||
|
||||
@@ -494,29 +494,26 @@ describe('MPlaceSheet', () => {
|
||||
expect(screen.getByText('Ferry to Corfu')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLSH-028: a transport booking opens the transport editor, not the reservation modal', () => {
|
||||
it('FE-MOB-PLSH-028: a transport booking opens its detail sheet, not an editor', () => {
|
||||
const planner = bookingPlanner({ id: 7, assignment_id: 11, title: 'Ferry to Corfu', status: 'pending', type: 'ferry', day_id: 2 })
|
||||
renderSheet(planner)
|
||||
const { shell } = renderSheet(planner)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Edit Reservation' }))
|
||||
fireEvent.click(screen.getByText('Ferry to Corfu').closest('button') as HTMLButtonElement)
|
||||
|
||||
expect(planner.setEditingTransport).toHaveBeenCalledWith(expect.objectContaining({ id: 7 }))
|
||||
expect(planner.setTransportModalDayId).toHaveBeenCalledWith(2)
|
||||
expect(planner.setShowTransportModal).toHaveBeenCalledWith(true)
|
||||
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 7 })
|
||||
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
|
||||
// and the place sheet gets out of the way
|
||||
expect(planner.setSelectedPlaceId).toHaveBeenCalledWith(null)
|
||||
})
|
||||
|
||||
it('FE-MOB-PLSH-029: a non-transport booking opens the reservation modal', () => {
|
||||
it('FE-MOB-PLSH-029: a non-transport booking opens the same detail sheet first, as on the desktop', () => {
|
||||
const planner = bookingPlanner({ id: 8, assignment_id: 11, title: 'Museum tour', status: 'confirmed', type: 'activity' })
|
||||
renderSheet(planner)
|
||||
const { shell } = renderSheet(planner)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Edit Reservation' }))
|
||||
fireEvent.click(screen.getByText('Museum tour').closest('button') as HTMLButtonElement)
|
||||
|
||||
expect(planner.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 8 }))
|
||||
expect(planner.setShowReservationModal).toHaveBeenCalledWith(true)
|
||||
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 8 })
|
||||
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLSH-030: a viewer without edit rights sees the booking but gets no live button', () => {
|
||||
@@ -529,7 +526,6 @@ describe('MPlaceSheet', () => {
|
||||
|
||||
// Still readable — just not a control that would do nothing when pressed.
|
||||
expect(screen.getByText('Ferry to Corfu')).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Edit Reservation' })).not.toBeInTheDocument()
|
||||
const row = screen.getByText('Ferry to Corfu').closest('button') as HTMLButtonElement
|
||||
expect(row.disabled).toBe(true)
|
||||
})
|
||||
|
||||
@@ -899,11 +899,10 @@ describe('MRoadtripTab', () => {
|
||||
// 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.
|
||||
// A chip opens its booking's detail sheet, 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()
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: reservations[0].id })
|
||||
expect(p.setShowReservationModal).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', () => {
|
||||
@@ -992,9 +991,8 @@ describe('MRoadtripTab', () => {
|
||||
const editor = planner({ roadtripRoutes: routes({ days: [hotelStage()] }), reservations: [hotelBooking] })
|
||||
const first = renderTab(editor)
|
||||
fireEvent.click(screen.getByText('roadtrip.bookend.back'))
|
||||
expect(editor.setEditingReservation).toHaveBeenCalledWith(hotelBooking)
|
||||
expect(editor.setShowReservationModal).toHaveBeenCalledWith(true)
|
||||
expect(first.shell.openSheet).not.toHaveBeenCalled()
|
||||
expect(first.shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: hotelBooking.id })
|
||||
expect(editor.setShowReservationModal).not.toHaveBeenCalled()
|
||||
first.unmount()
|
||||
|
||||
const dayEditor = planner({
|
||||
|
||||
@@ -181,7 +181,7 @@ describe('MTransportSheet', () => {
|
||||
const planner = makePlanner()
|
||||
const shell = makeShell({ trTab: 'transports', view: 'plan' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
const btn = screen.getByRole('button', { name: 'On map' })
|
||||
const btn = screen.getByRole('button', { name: 'Map' })
|
||||
expect(btn).toHaveAttribute('aria-pressed', 'false')
|
||||
fireEvent.click(btn)
|
||||
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
|
||||
@@ -194,7 +194,7 @@ describe('MTransportSheet', () => {
|
||||
const planner = makePlanner({ visibleConnections: [7] })
|
||||
const shell = makeShell({ trTab: 'plan', view: 'map' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
const btn = screen.getByRole('button', { name: 'On map' })
|
||||
const btn = screen.getByRole('button', { name: 'Map' })
|
||||
expect(btn).toHaveAttribute('aria-pressed', 'true')
|
||||
fireEvent.click(btn)
|
||||
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
|
||||
@@ -253,7 +253,7 @@ describe('MTransportSheet', () => {
|
||||
render(<MTransportSheet planner={planner} shell={makeShell()} />)
|
||||
expect(screen.queryByRole('button', { name: 'Edit' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Delete' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: 'On map' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: 'Map' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-021: keeps the last booking on screen while the sheet animates out', () => {
|
||||
@@ -323,7 +323,7 @@ describe('MTransportSheet', () => {
|
||||
const shell = makeShell({ trTab: 'transports', view: 'plan' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
|
||||
|
||||
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
|
||||
expect(planner.handleSelectDay).toHaveBeenCalledWith(3, false)
|
||||
@@ -338,7 +338,7 @@ describe('MTransportSheet', () => {
|
||||
const shell = makeShell({ trTab: 'transports', view: 'map' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
|
||||
|
||||
expect(shell.toggleView).not.toHaveBeenCalled()
|
||||
expect(planner.handleSelectDay).toHaveBeenCalledWith(3, false)
|
||||
@@ -351,7 +351,7 @@ describe('MTransportSheet', () => {
|
||||
const planner = makePlanner({ days: DAYS, selectedDayId: 4, reservations: [overnight] })
|
||||
render(<MTransportSheet planner={planner} shell={makeShell({ trTab: 'plan', view: 'plan' })} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
|
||||
|
||||
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
|
||||
expect(planner.handleSelectDay).not.toHaveBeenCalled()
|
||||
@@ -362,13 +362,13 @@ describe('MTransportSheet', () => {
|
||||
const unbound = { ...FLIGHT, day_id: null, end_day_id: null } as unknown as Reservation
|
||||
const allDays = makePlanner({ days: DAYS, selectedDayId: null })
|
||||
const { unmount } = render(<MTransportSheet planner={allDays} shell={makeShell({ trTab: 'transports', view: 'map' })} />)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
|
||||
expect(allDays.handleSelectDay).not.toHaveBeenCalled()
|
||||
unmount()
|
||||
|
||||
const noDay = makePlanner({ days: DAYS, selectedDayId: 5, reservations: [unbound] })
|
||||
render(<MTransportSheet planner={noDay} shell={makeShell({ trTab: 'transports', view: 'plan' })} />)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
|
||||
expect(noDay.toggleConnection).toHaveBeenCalledWith(7)
|
||||
expect(noDay.handleSelectDay).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -381,7 +381,7 @@ describe('MTransportSheet', () => {
|
||||
const shell = makeShell({ trTab: 'transports', view: 'plan' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
|
||||
const btn = screen.getByRole('button', { name: 'On map' })
|
||||
const btn = screen.getByRole('button', { name: 'Map' })
|
||||
expect(btn).toHaveAttribute('aria-pressed', 'false')
|
||||
fireEvent.click(btn)
|
||||
|
||||
@@ -398,7 +398,7 @@ describe('MTransportSheet', () => {
|
||||
const shell = makeShell({ trTab: 'plan', view: 'map' })
|
||||
render(<MTransportSheet planner={planner} shell={shell} />)
|
||||
|
||||
const btn = screen.getByRole('button', { name: 'On map' })
|
||||
const btn = screen.getByRole('button', { name: 'Map' })
|
||||
expect(btn).toHaveAttribute('aria-pressed', 'true')
|
||||
fireEvent.click(btn)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user