mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
feat(client): show Dawarich stays, routes and marks where they belong
The trip planner and the journal get a "From Dawarich" list: the stays recorded for those dates, each one a row that can be dismissed or turned into a place or an entry after a review step that shows time, name, note and day. A place that came from a recording carries the Dawarich mark next to its name so its origin stays visible afterwards. The recorded route lies over the trip and journal maps as an overlay, coloured per day and cut along the reader's own timezone rather than UTC. It is fetched for the window on screen and never stored. The Atlas gets its own panel beside the map for the countries and cities the recordings prove, and the wish list is ticked off there, on the day of the visit, undoably. The phone has its own take on all of it, in the mobile shell's colours and with native sheets.
This commit is contained in:
@@ -512,13 +512,16 @@ describe('DayPlanSidebar', () => {
|
||||
const onToggleConnection = vi.fn()
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], reservations: [res as any], onOpenTransit: vi.fn(), onToggleConnection, visibleConnectionIds: [] })} />)
|
||||
// No map-connections toggle on transit rows — the expander replaces it.
|
||||
expect(screen.queryByTitle(/connections/i)).not.toBeInTheDocument()
|
||||
expect(screen.queryByLabelText(/connections/i)).not.toBeInTheDocument()
|
||||
// Collapsed: no stop names beyond the chips.
|
||||
expect(screen.queryByText('Alexanderplatz')).not.toBeInTheDocument()
|
||||
await user.click(screen.getByLabelText('Expand'))
|
||||
expect(await screen.findByText('Alexanderplatz')).toBeInTheDocument()
|
||||
expect(screen.getByText(/Platform 2/)).toBeInTheDocument()
|
||||
await user.click(screen.getByLabelText('Collapse'))
|
||||
// The day's own chevron carries the same accessible name, so pick the one
|
||||
// that is not in the day's action block.
|
||||
const rowCollapse = screen.getAllByLabelText('Collapse').find(el => !el.closest('.dp-day-actions'))!
|
||||
await user.click(rowCollapse)
|
||||
expect(screen.queryByText('Alexanderplatz')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -2159,7 +2162,7 @@ describe('DayPlanSidebar', () => {
|
||||
days: [day], places: [place], assignments: { '10': [assignment] }, reservations: [res],
|
||||
onEditReservation, onEditTransport,
|
||||
})} />)
|
||||
const pencil = screen.getByTitle(/edit/i)
|
||||
const pencil = screen.getByLabelText(/edit/i)
|
||||
await user.click(pencil)
|
||||
expect(onEditReservation).toHaveBeenCalledWith(res)
|
||||
expect(onEditTransport).not.toHaveBeenCalled()
|
||||
@@ -2177,7 +2180,7 @@ describe('DayPlanSidebar', () => {
|
||||
days: [day], places: [place], assignments: { '10': [assignment] }, reservations: [res],
|
||||
onEditReservation, onEditTransport,
|
||||
})} />)
|
||||
const pencil = screen.getByTitle(/edit/i)
|
||||
const pencil = screen.getByLabelText(/edit/i)
|
||||
await user.click(pencil)
|
||||
expect(onEditTransport).toHaveBeenCalledWith(res)
|
||||
expect(onEditReservation).not.toHaveBeenCalled()
|
||||
@@ -3435,7 +3438,7 @@ describe('DayPlanSidebar', () => {
|
||||
const { rerender } = render(<DayPlanSidebar {...makeDefaultProps({
|
||||
days: [day], reservations: [flight], onToggleConnection,
|
||||
})} />)
|
||||
const show = screen.getByTitle('Show booking routes')
|
||||
const show = screen.getByLabelText('Show booking routes')
|
||||
await user.click(show)
|
||||
expect(onToggleConnection).toHaveBeenCalledWith(510)
|
||||
fireEvent.mouseEnter(show)
|
||||
@@ -3444,7 +3447,7 @@ describe('DayPlanSidebar', () => {
|
||||
rerender(<DayPlanSidebar {...makeDefaultProps({
|
||||
days: [day], reservations: [flight], onToggleConnection, visibleConnectionIds: [510],
|
||||
})} />)
|
||||
expect(screen.getByTitle('Hide booking routes')).toBeInTheDocument()
|
||||
expect(screen.getByLabelText('Hide booking routes')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-PLANNER-DAYPLAN-157: a non-transport booking row opens the reservation editor, unless read-only', async () => {
|
||||
@@ -3560,9 +3563,9 @@ describe('DayPlanSidebar', () => {
|
||||
})} />)
|
||||
expect(screen.getByText('08:30 – 10:05')).toBeInTheDocument()
|
||||
expect(screen.getByText('Air France AF1235')).toBeInTheDocument()
|
||||
await user.click(screen.getByTitle('Show booking routes'))
|
||||
await user.click(screen.getByLabelText('Show booking routes'))
|
||||
expect(onToggleConnection).toHaveBeenCalledWith(520)
|
||||
const edit = screen.getByTitle('Edit')
|
||||
const edit = screen.getByLabelText('Edit')
|
||||
fireEvent.mouseEnter(edit)
|
||||
fireEvent.mouseLeave(edit)
|
||||
await user.click(edit)
|
||||
@@ -3608,7 +3611,7 @@ describe('DayPlanSidebar', () => {
|
||||
expect(screen.getByText(/Reservation confirmed/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/Reservation pending/)).toBeInTheDocument()
|
||||
// Earliest first, so the first pencil belongs to the parking pass.
|
||||
await user.click(screen.getAllByTitle('Edit')[0])
|
||||
await user.click(screen.getAllByLabelText('Edit')[0])
|
||||
expect(onEditReservation).toHaveBeenCalledWith(parking)
|
||||
})
|
||||
|
||||
@@ -3636,12 +3639,12 @@ describe('DayPlanSidebar', () => {
|
||||
days: [day], places: [place], assignments: { '10': [a] }, onAddBookingToAssignment,
|
||||
})} />)
|
||||
const row = dragRow(screen.getByText('Hover place'))
|
||||
expect(screen.queryByTitle('Add booking')).not.toBeInTheDocument()
|
||||
expect(screen.queryByLabelText('Add booking')).not.toBeInTheDocument()
|
||||
fireEvent.mouseEnter(row)
|
||||
await user.click(screen.getByTitle('Add booking'))
|
||||
await user.click(screen.getByLabelText('Add booking'))
|
||||
expect(onAddBookingToAssignment).toHaveBeenCalledWith(10, 11)
|
||||
fireEvent.mouseLeave(row)
|
||||
expect(screen.queryByTitle('Add booking')).not.toBeInTheDocument()
|
||||
expect(screen.queryByLabelText('Add booking')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-PLANNER-DAYPLAN-166: the lock tooltip switches once a stop is pinned, and unlocking clears it', async () => {
|
||||
@@ -3797,7 +3800,7 @@ describe('DayPlanSidebar', () => {
|
||||
],
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments, selectedDayId: 10, routeShown: true })} />)
|
||||
const connector = await screen.findByTitle('Change travel mode')
|
||||
const connector = await screen.findByLabelText('Change travel mode')
|
||||
await user.click(connector)
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Walking' }))
|
||||
expect(vi.mocked(assignmentsApi.updateTransport)).toHaveBeenCalledWith(1, 11, 'walking')
|
||||
@@ -3805,7 +3808,7 @@ describe('DayPlanSidebar', () => {
|
||||
'10': [expect.objectContaining({ id: 11, leg_transport_mode: 'walking' }), expect.objectContaining({ id: 12 })],
|
||||
})
|
||||
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Use day default' }))
|
||||
expect(vi.mocked(assignmentsApi.updateTransport)).toHaveBeenLastCalledWith(1, 11, null)
|
||||
})
|
||||
@@ -3821,7 +3824,7 @@ describe('DayPlanSidebar', () => {
|
||||
],
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments, selectedDayId: 10, routeShown: true, onPlanTransitLeg })} />)
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Public transit' }))
|
||||
// Origin/destination + this stop's departure time, resolved back from the leg coords.
|
||||
expect(onPlanTransitLeg).toHaveBeenCalledWith({
|
||||
@@ -3842,7 +3845,7 @@ describe('DayPlanSidebar', () => {
|
||||
],
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments, selectedDayId: 10, routeShown: true })} />)
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
expect(contextMenu().queryByRole('button', { name: 'Public transit' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -3866,7 +3869,7 @@ describe('DayPlanSidebar', () => {
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days, assignments, accommodations, selectedDayId: 11, routeShown: true, onPlanTransitLeg })} />)
|
||||
// The morning bookend (hotel -> first stop) is the first connector in the list.
|
||||
const connectors = await screen.findAllByTitle('Change travel mode')
|
||||
const connectors = await screen.findAllByLabelText('Change travel mode')
|
||||
await user.click(connectors[0])
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Public transit' }))
|
||||
expect(onPlanTransitLeg).toHaveBeenCalledWith(expect.objectContaining({
|
||||
@@ -3898,7 +3901,7 @@ describe('DayPlanSidebar', () => {
|
||||
],
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days, assignments, selectedDayId: 11, routeShown: true, onPlanTransitLeg })} />)
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Public transit' }))
|
||||
// Day 11's own 16:30, not day 10's 09:00 (a trip-wide coord index would leak it).
|
||||
expect(onPlanTransitLeg).toHaveBeenCalledWith(expect.objectContaining({ dayId: 11, time: '16:30' }))
|
||||
@@ -3918,7 +3921,7 @@ describe('DayPlanSidebar', () => {
|
||||
],
|
||||
}
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments, selectedDayId: 10, routeShown: true })} />)
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
await user.click(contextMenu().getByRole('button', { name: 'Driving' }))
|
||||
await waitFor(() => expect(mockToast.error).toHaveBeenCalledWith('nope'))
|
||||
expect(refreshDays).toHaveBeenCalledWith(1)
|
||||
@@ -3942,7 +3945,7 @@ describe('DayPlanSidebar', () => {
|
||||
})} />)
|
||||
await user.click(screen.getByRole('button', { name: 'EV eco' }))
|
||||
expect(onSetRouteProfile).toHaveBeenCalledWith('plugin:ev/eco')
|
||||
await user.click(await screen.findByTitle('Change travel mode'))
|
||||
await user.click(await screen.findByLabelText('Change travel mode'))
|
||||
expect(contextMenu().getByRole('button', { name: 'EV eco' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -4025,7 +4028,7 @@ describe('DayPlanSidebar', () => {
|
||||
const day = buildDay({ id: 10, date: '2025-06-01', title: 'Day 1' })
|
||||
const onAddTransport = vi.fn()
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], onAddTransport })} />)
|
||||
await user.click(screen.getByTitle('Add transport'))
|
||||
await user.click(screen.getByLabelText('Add transport'))
|
||||
expect(onAddTransport).toHaveBeenCalledWith(10)
|
||||
})
|
||||
|
||||
@@ -4244,7 +4247,7 @@ describe('DayPlanSidebar', () => {
|
||||
fireEvent.mouseEnter(expand)
|
||||
fireEvent.mouseLeave(expand)
|
||||
await user.click(expand)
|
||||
expect(screen.getByLabelText('Collapse')).toBeInTheDocument()
|
||||
expect(screen.getAllByLabelText('Collapse').some(el => !el.closest('.dp-day-actions'))).toBe(true)
|
||||
await user.click(cardRow(screen.getByText('U2 to Zoo')))
|
||||
expect(await screen.findByText('Alexanderplatz')).toBeInTheDocument()
|
||||
})
|
||||
@@ -4490,10 +4493,13 @@ describe('the day route-tools row', () => {
|
||||
it('keeps the optimize action reachable by name without printing it', () => {
|
||||
render(<DayPlanSidebar {...makeDefaultProps(dayWithTwoStops())} />)
|
||||
const btn = screen.getByRole('button', { name: /optimize/i })
|
||||
// The assertion that pins the change: named, but no visible label.
|
||||
// The assertion that pins the change: named, but no visible label. The name
|
||||
// is `aria-label` rather than `title` — the hover text is TREK's own tooltip
|
||||
// now, and a browser tooltip is not an accessible name anyway.
|
||||
expect(btn).toBeInTheDocument()
|
||||
expect(btn.textContent?.trim()).toBe('')
|
||||
expect(btn.getAttribute('title')).toBeTruthy()
|
||||
expect(btn.getAttribute('aria-label')).toBeTruthy()
|
||||
expect(btn.getAttribute('title')).toBeNull()
|
||||
})
|
||||
|
||||
/* The click itself is already pinned by FE-PLANNER-DAYPLAN-038 above, which
|
||||
|
||||
Reference in New Issue
Block a user