mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 06:56:35 +00:00
ed18c37903
Every file the release touches was read once more, and what survived an independent check against the code is fixed here, with a test for each. Data and credentials - A document sync connection edited to a new address no longer carries the stored token along: a blank form under another origin is refused, the same rule the probe route already had. Dawarich and AirTrail testConnection send the stored key only to the host it was stored for. - The key rotation script now covers document_connections.secrets and trip_document_links.webhook_secret, which it had skipped. - Turning a booked night into a pause in the road trip popup asks first and says that the booking and its expense go with it. Deleting a place says the same when a night is booked there, on the desktop and on the phone. - A moved version marker over unchanged bytes no longer replaces the TREK file and its attachments; a real revision carries the attachments over. Planner - A drop in the day plan names the row it lands ahead of in the full day, so a hidden hotel stop no longer shifts it one slot early; the store sorts before it splices. Via re-anchoring, the booked-night guard and the sidebar's day membership read the stored day, the index space the server uses. - A hotel stop placed mid-day re-pins the road trip vias of that day, and the booking session receives the new stop order too. The Public API and the iCal feed list a booked hotel once. A plugin can no longer write a stay against another trip's day. Road trip and map - The route overview paces its requests to the public routers and retries a rate limit, and it says which legs it could not route instead of quietly reporting a shorter trip. A click on a via handle no longer drops a second via; handles hide when zooming out. Read-only members cannot edit the driving limits. The phone shows a way back when no day is picked and prints the night drive departure in the chosen clock format. Integrations and search - Google transit keeps conventional trains when the train chip is on. TREK_PLACES_ENABLED=false stops the details and enrichment calls too, and accepts the whole boolean family. A caller-supplied description no longer lands in the instance-wide enrichment cache. Nominatim searches carry a timeout. An OSM place id is checked for shape before it reaches Overpass. - Dawarich puts a stay on the trip whose dates hold it, the Atlas hand-off knows what the Atlas already shows, and a host change with a new key clears the old instance's state. - Document sync: a webhook address pasted by hand works on the token alone, deleting a connection unregisters its subscriptions, Nextcloud under a sub-path connects, Synology answers a name collision before uploading and verifies a move into the bin, Paperless titles are capped at 128 characters, a DNS failure reads as unreachable rather than as a policy verdict, videos from the store are accepted like uploads, and remote_missing has a way out. Conflict buttons only for the owner, a refused choice is reported, a refused credential gets a Reconnect button, disconnecting asks first on the desktop as it does on the phone, and the folder picker no longer spins forever. Release - The server holds the release notice back from a bundle that cannot draw it, so the previous shell served from the service worker cache after an update no longer shows bare keys and no longer lets a click use the notice up. - Import into an existing list gets the same body limit as a new list. Chat images say when the limit is reached and the new controls are translated. The transit backend switch reports a failed save. The Helm chart carries the Amap credentials in its Secret; the shipped templates document the Places API and Amap variables and the Overpass default. The wiki follows.
126 lines
5.9 KiB
TypeScript
126 lines
5.9 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react'
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
import { TripRouteOverviewPill, TripRouteOverviewPanel } from './TripRouteOverview'
|
|
import type { TripRouteOverview } from './useTripRouteOverview'
|
|
|
|
const overview = (over: Partial<TripRouteOverview> = {}): TripRouteOverview => ({
|
|
days: [
|
|
{ dayId: 1, dayNumber: 1, date: '2025-06-01', title: null, color: { line: '#0a84ff', casing: '#0a5cc2' }, lines: [], segments: [], distance: 82000, duration: 3600, modes: ['driving'] },
|
|
{ dayId: 2, dayNumber: 2, date: '2025-06-02', title: 'Coast road', color: { line: '#ff9f0a', casing: '#c2740a' }, lines: [], segments: [], distance: 140500, duration: 7200, modes: ['driving', 'walking'] },
|
|
],
|
|
lines: [], lineColors: [], segments: [], focusPoints: [],
|
|
totalDistance: 222500, totalDuration: 10800, loading: false,
|
|
...over,
|
|
})
|
|
|
|
describe('TripRouteOverviewPill', () => {
|
|
it('FE-MAP-TROU-001: says which way it will take you, and reports its state', () => {
|
|
const onToggle = vi.fn()
|
|
const { rerender } = render(<TripRouteOverviewPill active={false} onToggle={onToggle} />)
|
|
|
|
const button = screen.getByTestId('trip-overview-pill')
|
|
expect(button).toHaveAttribute('aria-pressed', 'false')
|
|
expect(button).toHaveAttribute('aria-label', 'map.overview.show')
|
|
|
|
fireEvent.click(button)
|
|
expect(onToggle).toHaveBeenCalledTimes(1)
|
|
|
|
rerender(<TripRouteOverviewPill active onToggle={onToggle} />)
|
|
expect(screen.getByTestId('trip-overview-pill')).toHaveAttribute('aria-label', 'map.overview.hide')
|
|
})
|
|
})
|
|
|
|
describe('TripRouteOverviewPanel', () => {
|
|
it('FE-MAP-TROU-002: leads with the trip total in the reader\'s own unit', () => {
|
|
const { rerender } = render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)
|
|
expect(screen.getByText('222.5 km')).toBeInTheDocument()
|
|
|
|
rerender(<TripRouteOverviewPanel overview={overview()} unit="imperial" />)
|
|
expect(screen.getByText('138.3 mi')).toBeInTheDocument()
|
|
})
|
|
|
|
it('FE-MAP-TROU-003: names every day, its distance and how it is travelled', () => {
|
|
render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)
|
|
|
|
expect(screen.getByText('dayplan.dayN')).toBeInTheDocument()
|
|
// A day with a title is named by it rather than by its number.
|
|
expect(screen.getByText('Coast road')).toBeInTheDocument()
|
|
expect(screen.getByText('82 km')).toBeInTheDocument()
|
|
expect(screen.getByText('140.5 km')).toBeInTheDocument()
|
|
})
|
|
|
|
it('FE-MAP-TROU-004: marks the total as partial while legs are still coming in', () => {
|
|
const { container, rerender } = render(<TripRouteOverviewPanel overview={overview({ loading: true })} unit="metric" />)
|
|
expect(container.textContent).toContain('…')
|
|
|
|
rerender(<TripRouteOverviewPanel overview={overview()} unit="metric" />)
|
|
expect(container.textContent).not.toContain('…')
|
|
})
|
|
|
|
it('FE-MAP-TROU-005: a day row picks that day when the shell offers it', () => {
|
|
const onSelectDay = vi.fn()
|
|
render(<TripRouteOverviewPanel overview={overview()} unit="metric" selectedDayId={2} onSelectDay={onSelectDay} />)
|
|
|
|
fireEvent.click(screen.getByText('Coast road'))
|
|
expect(onSelectDay).toHaveBeenCalledWith(2)
|
|
})
|
|
|
|
it('FE-MAP-TROU-006: read-only shells get rows, not buttons', () => {
|
|
render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)
|
|
expect(screen.queryAllByRole('button')).toHaveLength(0)
|
|
})
|
|
|
|
it('FE-MAP-TROU-008: hugs its rows, and takes the cap the shell gives it', () => {
|
|
const { container, rerender } = render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)
|
|
const card = () => screen.getByTestId('trip-overview-panel')
|
|
|
|
expect(card().style.width).toBe('fit-content')
|
|
expect(card().style.maxWidth).toBe('320px')
|
|
|
|
// The phone shell asks for a narrower card so the map keeps the space.
|
|
rerender(<TripRouteOverviewPanel overview={overview()} unit="metric" maxWidth={240} />)
|
|
expect(card().style.maxWidth).toBe('240px')
|
|
expect(container).not.toBeEmptyDOMElement()
|
|
})
|
|
|
|
it('FE-MAP-TROU-007: draws nothing at all for a trip with no routed day', () => {
|
|
const { container } = render(<TripRouteOverviewPanel overview={overview({ days: [], totalDistance: 0 })} unit="metric" />)
|
|
expect(container).toBeEmptyDOMElement()
|
|
})
|
|
|
|
it('FE-MAP-TROU-009: says when legs could not be routed, and marks the day that is short', () => {
|
|
// A refused leg stays a straight line and adds nothing to the sum, so a total shown
|
|
// without a word about it reads as the whole trip when it is not.
|
|
const days = overview().days
|
|
const short = overview({
|
|
days: [{ ...days[0], unroutedLegs: 1 }, { ...days[1], unroutedLegs: 0 }],
|
|
unroutedLegs: 1,
|
|
})
|
|
render(<TripRouteOverviewPanel overview={short} unit="metric" />)
|
|
|
|
expect(screen.getByTestId('trip-overview-unrouted')).toHaveTextContent('map.overview.unrouted')
|
|
expect(screen.getAllByRole('img', { name: 'map.overview.dayUnrouted' })).toHaveLength(1)
|
|
})
|
|
|
|
it('FE-MAP-TROU-010: does not call a leg unrouted while the round is still running', () => {
|
|
// Every leg still waiting is unrouted too; the ellipsis already says the number grows.
|
|
const days = overview().days
|
|
const running = overview({
|
|
days: [{ ...days[0], unroutedLegs: 1 }, { ...days[1], unroutedLegs: 1 }],
|
|
unroutedLegs: 2,
|
|
loading: true,
|
|
})
|
|
render(<TripRouteOverviewPanel overview={running} unit="metric" />)
|
|
|
|
expect(screen.queryByTestId('trip-overview-unrouted')).toBeNull()
|
|
expect(screen.queryByRole('img', { name: 'map.overview.dayUnrouted' })).toBeNull()
|
|
})
|
|
|
|
it('FE-MAP-TROU-011: a fully routed trip carries no warning at all', () => {
|
|
render(<TripRouteOverviewPanel overview={overview({ unroutedLegs: 0 })} unit="metric" />)
|
|
|
|
expect(screen.queryByTestId('trip-overview-unrouted')).toBeNull()
|
|
expect(screen.queryByRole('img', { name: 'map.overview.dayUnrouted' })).toBeNull()
|
|
})
|
|
})
|