style(tours): format the touched planner and map files

This commit is contained in:
Maurice
2026-10-14 20:54:44 +02:00
parent 976a612351
commit e3f3b0458b
6 changed files with 37 additions and 14 deletions
+4 -4
View File
@@ -30,9 +30,9 @@ function setup() {
describe('isPlacementTap', () => {
it('FE-MAP-PRESS-001: a short press that barely moved places', () => {
expect(isPlacementTap({ travelPx: 0, durationMs: 80, pointers: 1 })).toBe(true);
expect(isPlacementTap({ travelPx: TAP_MAX_TRAVEL_PX - 0.5, durationMs: TAP_MAX_DURATION_MS - 1, pointers: 1 })).toBe(
true
);
expect(
isPlacementTap({ travelPx: TAP_MAX_TRAVEL_PX - 0.5, durationMs: TAP_MAX_DURATION_MS - 1, pointers: 1 })
).toBe(true);
});
it('FE-MAP-PRESS-002: 4 px of travel, 300 ms of hold or a second finger never place', () => {
@@ -41,7 +41,7 @@ describe('isPlacementTap', () => {
expect(isPlacementTap({ travelPx: 0, durationMs: 50, pointers: 2 })).toBe(false);
});
it('FE-MAP-PRESS-003: a click no press was seen for (keyboard, synthetic) is the map\'s own call', () => {
it("FE-MAP-PRESS-003: a click no press was seen for (keyboard, synthetic) is the map's own call", () => {
expect(isPlacementTap(null)).toBe(true);
});
});
@@ -47,8 +47,23 @@ export function SuggestionInputBox({
className={floating ? 'focus-within:ring-2 focus-within:ring-accent' : 'bg-surface-tertiary'}
style={
floating
? { ...FLOATING_GLASS, display: 'flex', alignItems: 'center', gap: 8, height: 42, padding: '0 8px 0 14px', borderRadius: 999 }
: { display: 'flex', alignItems: 'center', gap: 6, padding: '8px 10px', borderRadius: 10, border: '1px solid var(--border-primary)' }
? {
...FLOATING_GLASS,
display: 'flex',
alignItems: 'center',
gap: 8,
height: 42,
padding: '0 8px 0 14px',
borderRadius: 999,
}
: {
display: 'flex',
alignItems: 'center',
gap: 6,
padding: '8px 10px',
borderRadius: 10,
border: '1px solid var(--border-primary)',
}
}
>
{icon}
@@ -100,7 +115,14 @@ interface SuggestionListProps {
}
/** The floating list under the field. Rendered only while it is loading, has rows or a status; the caller checks `open`. */
export function SuggestionList({ loading, rowCount, status, listbox, floating = false, children }: SuggestionListProps) {
export function SuggestionList({
loading,
rowCount,
status,
listbox,
floating = false,
children,
}: SuggestionListProps) {
const { t } = useTranslation();
if (!loading && rowCount === 0 && !status) return null;
return (
@@ -35,7 +35,7 @@ describe('parseTourDuration', () => {
'rejects %j',
(text) => {
expect(parseTourDuration(text)).toBe('invalid');
},
}
);
it('reads back everything it formats', () => {
@@ -11,7 +11,8 @@ const CLOCK = /^(\d+):(\d{1,2})$/;
// Hours with a unit, then minutes with an optional unit, or minutes alone with a unit:
// "2 h 56", "2h56min", "1,5 h", "45 min". Each part is anchored on its unit, so the
// pattern cannot match one text two ways.
const WITH_UNITS = /^(?:(\d+(?:[.,]\d+)?) ?(?:h|hr|hrs|hours?|std|stunden?)\.?)? ?(?:(\d+) ?(?:m|min|mins|minutes?|minuten?)?\.?)?$/;
const WITH_UNITS =
/^(?:(\d+(?:[.,]\d+)?) ?(?:h|hr|hrs|hours?|std|stunden?)\.?)? ?(?:(\d+) ?(?:m|min|mins|minutes?|minuten?)?\.?)?$/;
/**
* Reads what somebody typed into a duration field as whole minutes.
@@ -40,12 +40,12 @@ export function useWaypointPlaceNames(waypoints: WaypointCoordinate[]): Record<s
setNames((current) =>
current[point.id]?.key === point.key && current[point.id]?.name === name
? current
: { ...current, [point.id]: { key: point.key, name } },
: { ...current, [point.id]: { key: point.key, name } }
);
},
() => {
// Offline or a failed lookup: the row keeps showing the coordinates.
},
}
);
}
}, SETTLE_MS);
+3 -3
View File
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { reverseGeocodeRepo } from './reverseGeocodeRepo';
import { isEffectivelyOffline } from '../sync/networkMode';
import { mapsApi } from '../api/client';
import { isEffectivelyOffline } from '../sync/networkMode';
import { reverseGeocodeRepo } from './reverseGeocodeRepo';
vi.mock('../sync/networkMode', () => ({ isEffectivelyOffline: vi.fn(() => false) }));
vi.mock('../api/client', () => ({ mapsApi: { reverse: vi.fn() } }));
@@ -55,7 +55,7 @@ describe('reverse geocoded place names', () => {
() =>
new Promise((resolve) => {
resolvers.push(resolve);
}),
})
);
const names = [1, 2, 3].map((n) => reverseGeocodeRepo.placeName(46 + n, 11, 'de'));
expect(mapsApi.reverse).toHaveBeenCalledTimes(2);