Files
geointel/backend/tests/test_sprint192_regional_map_state.py
T
Codex 7997a7220a
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s
fix: clear stale regional map results
2026-07-14 20:50:45 +02:00

37 lines
1.5 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def read(path: str) -> str:
return (ROOT / path).read_text(encoding="utf-8")
def test_work_area_change_clears_stale_spatial_results_before_switching_area() -> None:
workspace = read("frontend/src/components/map/MapWorkspace.tsx")
assert "const handleSelectMapArea = (areaId: string) => {" in workspace
assert "clearAreaSelection()\n onSelectMapArea(areaId)" in workspace
assert workspace.count("handleSelectMapArea(event.target.value)") == 2
def test_cancelled_selection_requests_cannot_restore_stale_results() -> None:
selection_hook = read("frontend/src/hooks/useMapSelectionExtract.ts")
themes_hook = read("frontend/src/hooks/useMapThemeSelectionInsights.ts")
assert "const requestSequence = useRef(0)" in selection_hook
assert "requestSequence.current += 1\n setMapSelectionBbox(null)" in selection_hook
assert "if (requestSequence.current !== sequence)" in selection_hook
assert "const requestSequence = useRef(0)" in themes_hook
assert "requestSequence.current += 1\n setThemeInsights([])" in themes_hook
assert "if (requestSequence.current !== sequence)" in themes_hook
def test_viewport_status_names_the_active_reference_layer() -> None:
hook = read("frontend/src/hooks/useViewportVectorLayer.ts")
assert "load buildings from PostGIS" not in hook
assert "selectedDataset?.reference_layer_name?.trim() || 'features'" in hook
assert "to load ${layerLabel} from PostGIS" in hook