Files
TREK/client/src/components/Planner/placeCoMaps.test.ts
T
Konstantinos Thermos 8065af28ef feat(planner): open places and day routes in CoMaps
Add CoMaps, the offline OpenStreetMap navigator, alongside the existing
map integrations. A geolocated place gains a CoMaps entry in its
navigation menu, and a day's route toolbar gains a button that hands the
day's bookended stops to CoMaps in that day's travel mode.

CoMaps' route link carries only a start and a destination, so a two-stop
day goes as a route and a longer one as named pins rather than silently
losing the stops in between. Links use the https form so a device without
CoMaps installed lands on comaps.at instead of a dead scheme.

The hotel-bookend logic behind the Google Maps export was duplicated
between desktop and mobile; both now share dayExportStops so the two
links cannot disagree about which hotel legs are real.

Addresses discussion #1904
2026-08-14 10:24:14 +03:00

33 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getCoMapsUrlForPlace } from './placeCoMaps'
import type { Place } from '../../types'
// FE-PLANNER-COMAPS-001 to FE-PLANNER-COMAPS-004
function place(overrides: Partial<Place> = {}): Place {
return { name: 'Stephansdom', lat: 48.2038, lng: 16.3616, ...overrides } as unknown as Place
}
describe('getCoMapsUrlForPlace', () => {
it('FE-PLANNER-COMAPS-001: drops a named pin at the place', () => {
expect(getCoMapsUrlForPlace(place()))
.toBe('https://comaps.at/map?v=1&ll=48.2038,16.3616&n=Stephansdom')
})
it('FE-PLANNER-COMAPS-002: links over https, so an install-less device lands somewhere', () => {
// The cm:// scheme opens the app but dead-ends in a browser without it;
// comaps.at is both the app link and the install page.
expect(getCoMapsUrlForPlace(place())).toMatch(/^https:\/\/comaps\.at\//)
})
it('FE-PLANNER-COMAPS-003: a nameless place still gets its pin', () => {
expect(getCoMapsUrlForPlace(place({ name: '' })))
.toBe('https://comaps.at/map?v=1&ll=48.2038,16.3616')
})
it('FE-PLANNER-COMAPS-004: without coordinates there is nothing to pin', () => {
expect(getCoMapsUrlForPlace(place({ lat: null, lng: null }))).toBeNull()
expect(getCoMapsUrlForPlace(null)).toBeNull()
})
})