feat(map): chokepoint preset buttons on the Leaflet toolbar

Fetch GET /api/map/chokepoints once. Desktop buttons / phone <select>
fly to Hormuz, Bab el-Mandeb, Suez, Malacca, Taiwan. Turns Vessels on,
uses ?src=vesselapi on Hormuz, enables Sentinel-1 there, and never
POSTs /api/vessels/subscribe outside CONUS.
This commit is contained in:
Sirius DevOps 2026-08-29 14:12:02 -04:00
commit ac03442998
2 changed files with 141 additions and 3 deletions

View file

@ -47,3 +47,32 @@ def test_ws_reconnect_uses_backoff():
def test_check_health_treats_degraded_status():
fn = HTML.split("async function checkHealth")[1].split("/* ═══════════════ NAV")[0]
assert "degraded" in fn.lower() or "d.status" in fn
def test_chokepoint_presets_in_toolbar():
assert 'id="chokepoint-btns"' in HTML
assert 'id="chokepoint-select"' in HTML
assert "loadChokepoints()" in HTML
assert "/api/map/chokepoints" in HTML
assert "function applyChokepoint" in HTML
for name in ("Hormuz", "Bab el-Mandeb", "Suez", "Malacca", "Taiwan"):
assert name in HTML
def test_chokepoint_skips_aisstream_subscribe_outside_conus():
load = HTML.split("async function loadVessels")[1].split("async function toggleStorms")[0]
assert "intersectsConus()" in load
assert "api/vessels/subscribe" in load
assert "src=${encodeURIComponent(vesselSrcPref)}" in load or "&src=" in load
apply = HTML.split("function applyChokepoint")[1].split("function currentBBox")[0]
assert "vesselapi" in apply
assert "lp-vessels-on" in apply
assert "lp-sentinel-on" in apply
assert "map.setView" in apply
assert "minlat,minlon,maxlat,maxlon" in HTML.split("function chokepointLeafletBounds")[1][:400]
def test_phone_chokepoints_use_select_not_buttons():
mobile = HTML.split("@media (max-width: 820px)")[1].split("@media (prefers-reduced-motion")[0]
assert "#chokepoint-select { display: block; }" in mobile
assert ".chokepoint-btns { display: none; }" in mobile or "#chokepoint-label, .chokepoint-btns { display: none; }" in mobile