mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
fix(planner): scheme-check the booking URL, and stop the serial routing calls
A booking's url is rendered as a plain href to every other member of the trip and nothing ever checked its scheme, so a collaborator could store javascript: there. The place website next to it has been going through safeHttpUrl for exactly this reason, with a comment saying stored values predate the server check - this is the surface that was left. Both ends now: safeHttpUrl at the render site, and the scheme in the shared contract so nothing new gets stored, additively so existing rows still load. The per-leg routing rewrite turned one multi-waypoint request per run into one serial request per leg. A twelve-stop day is eleven round trips to a public OSRM in sequence before a single connector appears, and toggling km/mi does it all again. Group consecutive legs that resolve to the same mode into one request and fire the groups concurrently, keeping leg order on the join. Transport reordering wrote to the store and persisted with a bare catch, so a failed PUT left the sidebar showing an order the server never got; it reconciles now. Plus the smaller ones: the OSM menu_url rendered unchecked, expand/collapse-all persisting to a different storage than the day list reads, the debounced address search with no ordering guard, the accommodation save chain with no error path, and window.__trek_map holding a destroyed map.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-PLANNER-ADDRIN-001 to FE-PLANNER-ADDRIN-014
|
||||
// FE-PLANNER-ADDRIN-001 to FE-PLANNER-ADDRIN-015
|
||||
import { useState } from 'react';
|
||||
import { delay, http, HttpResponse } from 'msw';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
@@ -206,6 +206,28 @@ describe('AddressInput', () => {
|
||||
expect(input).toHaveValue('Sacher');
|
||||
});
|
||||
|
||||
it('FE-PLANNER-ADDRIN-015: a slow earlier search cannot overwrite the newer results', async () => {
|
||||
// The debounce only cancels the timer; a request already on its way keeps
|
||||
// going, and this one answers last.
|
||||
server.use(http.post('/api/maps/search', async ({ request }) => {
|
||||
const { query } = await request.json() as { query: string };
|
||||
if (query === 'Sacher') { await delay(600); return HttpResponse.json({ places: [HOTEL] }); }
|
||||
return HttpResponse.json({ places: [CAFE] });
|
||||
}));
|
||||
|
||||
render(<Host />);
|
||||
const input = screen.getByPlaceholderText('Street and number');
|
||||
fireEvent.change(input, { target: { value: 'Sacher' } });
|
||||
await settle(350);
|
||||
fireEvent.change(input, { target: { value: 'Cafe Central' } });
|
||||
|
||||
expect(await screen.findByText('Cafe Central')).toBeInTheDocument();
|
||||
// Now let the first request land.
|
||||
await settle(500);
|
||||
expect(screen.getByText('Cafe Central')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Hotel Sacher')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-ADDRIN-014: a mousedown outside closes the list and a failing search empties it', async () => {
|
||||
const user = userEvent.setup();
|
||||
server.use(searchRoute([HOTEL]));
|
||||
|
||||
Reference in New Issue
Block a user