mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 00:20:07 +00:00
feat(mobile): one Maps button for every map app, actions as one glass group
The day plan offered Google Maps and CoMaps as two tiles. One Maps button now opens the day in whichever app the traveller picks: Google Maps, Apple Maps with the stops between as waypoints, CoMaps, Waze and on Android any other map app, the last two to the first stop, which they say. The preferred map app from the settings opens straight away. The day's actions sit together on one glass surface as round icons over their labels, and the up-next card wears the same surface as the timeline card under it.
This commit is contained in:
@@ -8,6 +8,8 @@ import type { PlanRow, TransitMeta, TransportEntry } from '../../../../src/mobil
|
||||
import type { MergedItem } from '../../../../src/utils/dayMerge'
|
||||
import type { Assignment, Day, DayNote, Place, RouteSegment } from '../../../../src/types'
|
||||
import MPlanTimeline from '../../../../src/mobile/screens/trip/plan/MPlanTimeline'
|
||||
import { resetAllStores, seedStore } from '../../../helpers/store'
|
||||
import { useSettingsStore } from '../../../../src/store/settingsStore'
|
||||
|
||||
// FE-MOB-PLTL-001 to FE-MOB-PLTL-049
|
||||
|
||||
@@ -113,6 +115,11 @@ function buildTl(over: Record<string, unknown> = {}): MPlanTimelineController {
|
||||
canExportRoute: true,
|
||||
exportGoogleMaps: vi.fn(),
|
||||
exportCoMaps: vi.fn(),
|
||||
routeTargets: [
|
||||
{ id: 'google', label: 'Google Maps', url: 'https://www.google.com/maps/dir/1,2/3,4' },
|
||||
{ id: 'comaps', label: 'CoMaps', url: 'https://comaps.at/route?x' },
|
||||
{ id: 'waze', label: 'Waze', url: 'https://waze.com/ul?ll=1,2&navigate=yes', firstStopOnly: true },
|
||||
],
|
||||
renameDay: vi.fn(),
|
||||
fullPlaceOf: vi.fn(() => undefined as Place | undefined),
|
||||
routeModeOptions: [
|
||||
@@ -145,6 +152,7 @@ function renderTimeline(
|
||||
|
||||
describe('MPlanTimeline', () => {
|
||||
beforeEach(() => {
|
||||
resetAllStores()
|
||||
mocks.schedule = EMPTY_SCHEDULE
|
||||
})
|
||||
|
||||
@@ -625,23 +633,46 @@ describe('MPlanTimeline', () => {
|
||||
fireEvent.click(screen.getByText('mobileTrip.addBookingShort'))
|
||||
fireEvent.click(screen.getByText('mobileTrip.addTransportShort'))
|
||||
fireEvent.click(screen.getByText('dayplan.optimize'))
|
||||
fireEvent.click(screen.getByText('mobileTrip.googleMaps'))
|
||||
|
||||
expect(mocks.tl.addPlace).toHaveBeenCalledTimes(1)
|
||||
expect(shell.openSheet).toHaveBeenCalledWith('note', { dayId: 2 })
|
||||
expect(mocks.tl.addBooking).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.tl.addTransport).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.tl.optimize).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.tl.exportGoogleMaps).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-049: a day with no route to hand over offers no Google Maps or CoMaps tile (#2476)', () => {
|
||||
it('FE-MOB-PLTL-033b: one Maps tile asks which app gets the day, and the pick opens it', async () => {
|
||||
const open = vi.spyOn(window, 'open').mockReturnValue(null)
|
||||
renderTimeline({}, {}, { mode: 'edit' })
|
||||
|
||||
fireEvent.click(screen.getByText('mobileTrip.maps'))
|
||||
const sheet = await screen.findByRole('dialog', { name: 'mobileTrip.openRouteIn' })
|
||||
// The app that only takes one place says so.
|
||||
expect(within(sheet).getByText('mobileTrip.firstStopOnly')).toBeInTheDocument()
|
||||
fireEvent.click(within(sheet).getByText('Google Maps'))
|
||||
|
||||
expect(open).toHaveBeenCalledWith('https://www.google.com/maps/dir/1,2/3,4', '_blank', 'noopener,noreferrer')
|
||||
open.mockRestore()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-033c: with a preferred map app set, the Maps tile opens it straight away (#2423)', () => {
|
||||
const open = vi.spyOn(window, 'open').mockReturnValue(null)
|
||||
seedStore(useSettingsStore, { settings: { preferred_nav_app: 'comaps' } })
|
||||
renderTimeline({}, {}, { mode: 'edit' })
|
||||
|
||||
fireEvent.click(screen.getByText('mobileTrip.maps'))
|
||||
|
||||
expect(open).toHaveBeenCalledWith('https://comaps.at/route?x', '_blank', 'noopener,noreferrer')
|
||||
expect(screen.queryByRole('dialog', { name: 'mobileTrip.openRouteIn' })).not.toBeInTheDocument()
|
||||
open.mockRestore()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-049: a day with no route to hand over offers no Maps tile (#2476)', () => {
|
||||
// A moving day whose only content is the flight: the export would be a drive
|
||||
// from one hotel to the other, so the two tiles are left out, not left dead.
|
||||
// from one hotel to the other, so the tile is left out, not left dead.
|
||||
renderTimeline({ canExportRoute: false }, {}, { mode: 'edit' })
|
||||
|
||||
expect(screen.queryByText('mobileTrip.googleMaps')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('mobileTrip.coMaps')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('mobileTrip.maps')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.optimize')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
|
||||
@@ -148,6 +148,13 @@ describe('useMPlanTimeline', () => {
|
||||
expect(weatherApi.get).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-005b: offers the map apps for the selected day, and none without one', async () => {
|
||||
const { result } = await renderTimeline(makePlanner())
|
||||
expect(result.current.routeTargets.map(t => t.id)).toEqual(expect.arrayContaining(['google', 'comaps', 'waze']))
|
||||
const none = await renderTimeline(makePlanner({ selectedDayId: null }))
|
||||
expect(none.result.current.routeTargets).toEqual([])
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTL-006: keeps every day-scoped action inert without a selected day', async () => {
|
||||
const planner = makePlanner({ selectedDayId: null })
|
||||
const { result } = await renderTimeline(planner)
|
||||
|
||||
Reference in New Issue
Block a user