Files
geointel/backend/tests/test_sprint30_workbench_components.py
T
JensandClaude Opus 5 9c29577b82 collapse five duplicate overlay blocks into one tested builder
MapWorkspace held five near-identical useMemo blocks deciding which raster
image the map draws under the active theme — terrain, flood depth, thematic
raster, WALOUS land cover and bathymetry. Each filtered partitions by source
name, read bbox_epsg4326 and assembled the same overlay shape, so the parts
that genuinely differ per theme were buried in the repetition.

One builder makes the rule testable and leaves only the source, the label and
the opacity varying. A raster whose bounds are unusable is now skipped rather
than drawn from a partial bbox: an overlay in the wrong place is worse than no
overlay.

The legend asked "are these thematic or WALOUS overlays" by inspecting two of
the five lists. That is a property of the source, so it says so directly.

Two contract tests needed fixing rather than repointing. One asserted
`"api" not in source.lower()`, which the new hook name useMapImageOverlays
matches inside "useM-api-mageOverlays" — as would rapid, capital or therapy.
The contract is that this component talks to no API client, so it now says
that.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 18:56:21 +02:00

66 lines
2.6 KiB
Python

from __future__ import annotations
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def test_app_uses_quality_and_map_presentational_components() -> None:
app = (ROOT / "frontend" / "src" / "App.tsx").read_text(encoding="utf-8")
assert "from './components/quality/QualityResultsPanel'" in app
assert "from './components/map/MapWorkspace'" in app
assert "<QualityResultsPanel" in app
assert "<MapWorkspace" in app
assert "<h2>QA/QC Results</h2>" not in app
assert "<h2>Map workspace</h2>" not in app
assert "<GeoMap" not in app
def test_map_workspace_lives_in_task_based_workbench_shell() -> None:
app = (ROOT / "frontend" / "src" / "App.tsx").read_text(encoding="utf-8")
styles = (ROOT / "frontend" / "src" / "styles" / "app.css").read_text(encoding="utf-8")
assert "activeWorkspace === 'map'" in app
assert app.index("activeWorkspace === 'map'") < app.index("<MapWorkspace")
assert "'workbench-main workbench-main-map' : 'workbench-main'" in app
assert 'className="workbench-inspector"' in app
assert ".workbench-layout" in styles
assert ".workbench-sidebar" in styles
assert ".workbench-main" in styles
assert ".workbench-inspector" in styles
def test_quality_results_panel_owns_persisted_quality_check_markup() -> None:
quality_panel = (
ROOT / "frontend" / "src" / "components" / "quality" / "QualityResultsPanel.tsx"
).read_text(encoding="utf-8")
assert "QualityCheckRead" in quality_panel
assert "Kwaliteitsresultaten vernieuwen" in quality_panel
assert "Nog geen bewaarde kwaliteitsresultaten" in quality_panel
assert "check.metrics.map" in quality_panel
assert "fetch(" not in quality_panel
assert "api" not in quality_panel.lower()
def test_map_workspace_owns_map_controls_and_feature_inspector_markup() -> None:
map_workspace = (
ROOT / "frontend" / "src" / "components" / "map" / "MapWorkspace.tsx"
).read_text(encoding="utf-8")
assert "GeoMap" in map_workspace
assert "map-toolbar" in map_workspace
assert "Area" in map_workspace
assert "Werkgebied" in map_workspace
assert "Actieve kaartlaag" in map_workspace
assert "Objectinspectie" in map_workspace
assert "onFeatureSelect={onSelectMapFeature}" in map_workspace
assert "fetch(" not in map_workspace
# The component owns markup and interaction, never transport. A bare "api"
# substring also matches useMapImageOverlays, so name what is forbidden.
assert "services/api" not in map_workspace
assert not re.search(r"\w*[Aa]pi\.(get|post|put|delete)\(", map_workspace)