mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
1bc82f97fd
Paddle tours are planned on the water by TREK's own router: a water network per paddle region, built from the same Geofabrik extract as the obstacles and searched in a worker thread of the server (no sidecar). Rivers, canals and lakes (direct or along the shore), portages round weirs, locks by policy, whitewater by boat, gaps marked. Found portages and locks become points of their own; an unplannable leg says why and offers a way out. - Shaping points: a click on the line sets a point that steers the route without being a stop (hikes and paddle tours); recompute a single leg. - Lake style direct/shore, suggested from the wind forecast. - Regions load by themselves where a paddler plans (admin setting: automatic, on request, off; size cap and a daily count), with requests for the admins, a notification, and the load followed on the leg. - Portage from the last point, portages follow footways via the walking router (or stay straight), "put in here" on slipways and put-ins. - MCP plan_paddle_route with the REST route's rules.
54 lines
2.5 KiB
TypeScript
54 lines
2.5 KiB
TypeScript
// FE-PADDLE-WAYPOINT-PARTS-001 to 004: the pending portage at the last point and a portage's way on land (PAD-03).
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { fireEvent, render, screen } from '../../../../tests/helpers/render';
|
|
import { PendingPortageRow, PortageLegRow, type PortageWay } from './PaddleWaypointParts';
|
|
|
|
const way = (extra: Partial<PortageWay> = {}): PortageWay => ({
|
|
routed: false,
|
|
noWay: false,
|
|
searching: false,
|
|
onFollow: vi.fn(),
|
|
onStraighten: vi.fn(),
|
|
...extra,
|
|
});
|
|
|
|
function openPortage(props: Partial<Parameters<typeof PortageLegRow>[0]> = {}) {
|
|
render(<PortageLegRow lengthM={320} extraMinutes={null} disabled={false} onExtraChange={vi.fn()} {...props} />);
|
|
fireEvent.click(screen.getByRole('button', { expanded: false }));
|
|
}
|
|
|
|
describe('PendingPortageRow', () => {
|
|
it('FE-PADDLE-WAYPOINT-PARTS-001: says to set the point where the boat goes in again, and takes the ask back', () => {
|
|
const onRemove = vi.fn();
|
|
render(<PendingPortageRow disabled={false} onRemove={onRemove} />);
|
|
expect(screen.getByTestId('tour-planner-portage-pending')).toHaveTextContent('Portage from here');
|
|
fireEvent.click(screen.getByRole('button', { name: 'Do not carry after all' }));
|
|
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('FE-PADDLE-WAYPOINT-PARTS-002: offers no way back on a tour that cannot be edited', () => {
|
|
render(<PendingPortageRow disabled onRemove={vi.fn()} />);
|
|
expect(screen.queryByRole('button', { name: 'Do not carry after all' })).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('PortageLegRow way', () => {
|
|
it('FE-PADDLE-WAYPOINT-PARTS-003: switches between following the path and a straight line', () => {
|
|
const straight = way();
|
|
openPortage({ way: straight });
|
|
fireEvent.click(screen.getByRole('button', { name: 'Follow the path' }));
|
|
expect(straight.onFollow).toHaveBeenCalledTimes(1);
|
|
const routed = way({ routed: true });
|
|
openPortage({ way: routed });
|
|
fireEvent.click(screen.getAllByRole('button', { name: 'Straight line' })[1]);
|
|
expect(routed.onStraighten).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('FE-PADDLE-WAYPOINT-PARTS-004: says why a carry stayed straight, and that the router is asked', () => {
|
|
openPortage({ way: way({ noWay: true }) });
|
|
expect(screen.getByTestId('tour-planner-portage-way')).toHaveTextContent('No path without a long detour');
|
|
openPortage({ way: way({ searching: true }) });
|
|
expect(screen.getAllByTestId('tour-planner-portage-way')[1]).toHaveTextContent('Looking for a path');
|
|
});
|
|
});
|