mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
fix(maps): stretches beside the overpass probe wait for it, empty note only after a full search
This commit is contained in:
@@ -67,8 +67,9 @@ function WarningNotice({ text, search }: { text: string; search?: TourPoiSearch
|
||||
* What the search answered beyond its places: offline, failed, kinds that
|
||||
* could not be searched, partly searched, cut, or empty. That the answer is
|
||||
* out of date the search button says, as it is what to press then. Nothing
|
||||
* found is said only when every kind was searched, with the next wider
|
||||
* corridor one press away; a failure or a gap carries its own retry.
|
||||
* found is said only when every kind was searched along the whole line, with
|
||||
* the next wider corridor one press away; a failure or a gap carries its own
|
||||
* retry.
|
||||
*/
|
||||
export function SearchNotices({ search, unit }: { search: TourPoiSearch; unit: Unit }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -85,12 +86,14 @@ export function SearchNotices({ search, unit }: { search: TourPoiSearch; unit: U
|
||||
{ text: answer.truncated && t('tours.poi.truncated'), retry: false },
|
||||
].filter((note): note is { text: string; retry: boolean } => !!note.text);
|
||||
const wider = search.widerCorridorM;
|
||||
// A gap wants a retry, not a wider corridor, and changed choices were not searched yet.
|
||||
const empty = answer.pois.length === 0 && answer.unavailable.length === 0 && !answer.partial && !search.outdated;
|
||||
return (
|
||||
<>
|
||||
{notes.map((note) => (
|
||||
<WarningNotice key={note.text} text={note.text} search={note.retry ? search : undefined} />
|
||||
))}
|
||||
{answer.pois.length === 0 && answer.unavailable.length === 0 && (
|
||||
{empty && (
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1.5">
|
||||
<p className="m-0 text-content-muted" style={fs(12, 'body')}>
|
||||
{t('tours.poi.empty', { distance: formatDistance(km(search.corridorM), unit) })}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { usePoiInsertion, type PoiInsertionPlanner } from './usePoiInsertion';
|
||||
import { useTourPoiMarkers } from './useTourPoiMarkers';
|
||||
import { useTourPoiSearch } from './useTourPoiSearch';
|
||||
|
||||
// FE-TOUR-POI-001 to FE-TOUR-POI-026
|
||||
// FE-TOUR-POI-001 to FE-TOUR-POI-027
|
||||
|
||||
vi.mock('../planner/useWaypointPlaceNames', () => ({ useWaypointPlaceNames: () => ({}) }));
|
||||
|
||||
@@ -656,4 +656,15 @@ describe('a search that could not ask, and its retry (PLN-05)', () => {
|
||||
await waitFor(() => expect(screen.getByTestId('tour-poi-search')).toBeEnabled());
|
||||
expect(screen.queryByTestId('tour-poi-widen')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-TOUR-POI-027: an empty answer with stretches left out offers a retry, never nothing found or a wider corridor', async () => {
|
||||
search.mockResolvedValue({ ...ANSWER, pois: [], partial: true });
|
||||
render(<TourPoiSearchCard planner={searchPlanner()} />);
|
||||
fireEvent.click(screen.getByTestId('tour-poi-search'));
|
||||
|
||||
expect(await screen.findByText(/Some stretches could not be searched/)).toBeInTheDocument();
|
||||
expect(screen.getByTestId('tour-poi-retry')).toHaveTextContent('Try again');
|
||||
expect(screen.queryByText(/Nothing found/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('tour-poi-widen')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user