mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
fix(tours): explain and offer to re-ask hike ways that could not be asked
A way OpenStreetMap could not be asked about this time now carries a tooltip saying so, and the unknown list offers to ask again whenever such a row is there, not only when nothing at all was answered.
This commit is contained in:
@@ -12,7 +12,7 @@ vi.mock('./useHikeWays', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// FE-HIKE-WAYSCARD-001 to FE-HIKE-WAYSCARD-011
|
||||
// FE-HIKE-WAYSCARD-001 to FE-HIKE-WAYSCARD-012
|
||||
|
||||
const LINE: [number, number][] = [
|
||||
[47.0, 11.0],
|
||||
@@ -153,8 +153,8 @@ describe('HikeWaysCard (MAP-03, MAP-04)', () => {
|
||||
await tooltipOf('sac-row-unclear', /T3, hiking;mountain_hiking/);
|
||||
await tooltipOf('sac-row-untagged', /Unknown does not mean easy/);
|
||||
await tooltipOf('sac-row-unmatched', /no way lies clearly under the line/i);
|
||||
// A way that could not be asked about says so in its row; there is nothing more to name.
|
||||
expect(screen.getByTestId('sac-row-unasked')).toHaveTextContent('Could not be asked this time');
|
||||
await tooltipOf('sac-row-unasked', /could not be asked about these ways this time/);
|
||||
});
|
||||
|
||||
it('FE-HIKE-WAYSCARD-009: the surfaces list their groups, the most common one, and no grade or routing limit', () => {
|
||||
@@ -190,4 +190,16 @@ describe('HikeWaysCard (MAP-03, MAP-04)', () => {
|
||||
fireEvent.click(screen.getByTestId('way-row-track'));
|
||||
expect(state.focusOn).toHaveBeenCalledWith('track');
|
||||
});
|
||||
|
||||
it('FE-HIKE-WAYSCARD-012: ways that could not be asked this time may be asked again from the list, and only then', () => {
|
||||
const state = ways();
|
||||
const partial = show(state);
|
||||
const unknown = screen.getByText('Unknown').parentElement as HTMLElement;
|
||||
fireEvent.click(within(unknown).getByRole('button', { name: /try again/i }));
|
||||
expect(state.retry).toHaveBeenCalledTimes(1);
|
||||
partial.unmount();
|
||||
show(ways({ rows: SAC_ROWS.filter((row) => row.key !== 'unasked') }));
|
||||
expect(screen.getByTestId('sac-row-unmatched')).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: /try again/i })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Info, SlidersHorizontal } from 'lucide-react';
|
||||
import { Info, RefreshCw, SlidersHorizontal } from 'lucide-react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { useSettingsStore } from '../../../store/settingsStore';
|
||||
import { formatDistance } from '../../../utils/units';
|
||||
@@ -7,6 +7,7 @@ import { fs } from '../../shared/DialogShell';
|
||||
import { Tooltip } from '../../shared/Tooltip';
|
||||
import { bikePaintCss } from '../bike/bikePaint';
|
||||
import { FigureBadge } from '../paddle/FigureBadge';
|
||||
import { CardAction } from '../tourParts';
|
||||
import { HIKE_FACETS, type HikeFacet } from './hikeFacetSpecs';
|
||||
import { facetPaint, isUnknownClass, type FacetRow } from './hikeFacets';
|
||||
import { hikePaintCss } from './hikePaint';
|
||||
@@ -74,7 +75,7 @@ function useRowSource(facet: HikeFacet, row: FacetRow): string {
|
||||
if (step !== null) return t('tours.hike.sac.stepTip', { step: stepName(step), tag: row.tags[0] ?? '' });
|
||||
if (row.key === 'untagged') return t(FACET_KEY[facet]('untaggedTip'));
|
||||
if (row.key === 'unmatched') return t('tours.hike.ways.unmatchedTip');
|
||||
if (row.key === 'unasked') return '';
|
||||
if (row.key === 'unasked') return t('tours.hike.ways.unaskedTip');
|
||||
if (row.key === 'unclear' && facet === 'sac') return t('tours.hike.sac.unclearTip', { tags: row.tags.join(', ') });
|
||||
if (row.key === 'unclear') return t('tours.hike.ways.unclearTip', { tags: writtenTags(facet, row) });
|
||||
return t('tours.hike.ways.recordedTip', { tags: writtenTags(facet, row) });
|
||||
@@ -211,6 +212,14 @@ export function HikeWaysList({ ways, limit }: { ways: HikeWays; limit: number |
|
||||
<ClassRow key={row.key} row={row} ways={ways} limit={limit} />
|
||||
))}
|
||||
</ul>
|
||||
{/* Some ways could not be asked this time: they may be asked again without leaving the card. */}
|
||||
{unknown.some((row) => row.key === 'unasked') && (
|
||||
<span className="flex">
|
||||
<CardAction icon={<RefreshCw size={12} strokeWidth={2} />} onClick={ways.retry}>
|
||||
{t('common.errorRetry')}
|
||||
</CardAction>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<span className="inline-flex gap-1.5 text-content-faint" style={fs(11, 'body')}>
|
||||
|
||||
Reference in New Issue
Block a user