Files
geointel/backend/tests/test_sprint193_end_user_workbench.py
T
JensandClaude Opus 5 6572e4ad5f scope frontend contracts to the feature, not to one file
93 test files read a single frontend source and asserted identifiers in it. The
MapWorkspace split showed what that costs: 24 tests went red for a move that
changed no behaviour at all. A contract belongs to the feature — a container,
its hooks, its domain layer — not to whichever file currently holds it.

232 read sites now resolve through read_feature(). The distinction that makes
this safe is direction: a *positive* contract ("this is wired") may widen,
because the identifier must still exist somewhere in the feature; a *negative*
one ("this component performs no transport") is a statement about one file, and
widening it would quietly weaken the check. The 73 single-file reads that
remain are exactly those, and a guard now enforces the rule for new tests.

Verified rather than assumed: of the 732 migrated positive assertions, 644 still
match exactly one module — as specific as before — and the other 86 already
spanned a container and its hook by nature. Two apparent misses are an artefact
of the checking regex reading an escaped newline literally.

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

83 lines
3.5 KiB
Python

from pathlib import Path
from tests.frontend_contract import read_feature
ROOT = Path(__file__).resolve().parents[2]
def read(path: str) -> str:
return (ROOT / path).read_text(encoding="utf-8")
def test_national_workspace_is_automatic_and_map_has_one_scope_selector() -> None:
project_hook = read("frontend/src/hooks/useProjectWorkspace.ts")
map_workspace = read("frontend/src/components/map/MapWorkspace.tsx")
national_check = project_hook.index("const nationalProject")
regional_check = project_hook.index("const regionalProject")
assert national_check < regional_check
assert "return nationalProject.id" in project_hook
assert "const municipalityProject" not in project_hook
assert 'aria-label="Regio"' not in map_workspace
assert 'aria-label="Ingeladen regiobereik"' in map_workspace
assert "Zoek optioneel een gemeente" in map_workspace
assert 'aria-label="Werkgebied"' in map_workspace
def test_primary_navigation_uses_end_user_language_and_keeps_management_secondary() -> None:
app = read_feature("shell")
for label in ("Kaart", "Bronnen", "Kwaliteit", "Beeldanalyse", "Downloads"):
assert f"label: '{label}'" in app
assert "{ label: 'Beheer', keys: ['overview', 'system'] }" in app
assert 'className="secondary-analysis-disclosure segmentation-disclosure"' in app
def test_technical_projects_and_metadata_are_progressively_disclosed() -> None:
projects = read("frontend/src/components/project/ProjectPanel.tsx")
areas = read("frontend/src/components/project/AreaPanel.tsx")
datasets = read_feature("datasets")
dataset_names = read("frontend/src/lib/datasetDisplay.ts")
assert "TECHNICAL_PROJECT_PATTERN" in projects
assert "project.name === LEGACY_MOL_PROJECT_NAME" in projects
assert "alternatieve en technische werkruimtes" in projects
assert "Kempen · volledige regionale werkruimte" in projects
assert "area-catalog-disclosure" in areas
assert "dataset-technical-details" in datasets
assert "getDatasetDisplayName" in datasets
assert "dataset.source_metadata?.layer_type" in dataset_names
assert "regional_boundary: 'Grens vervoerregio Kempen'" in dataset_names
def test_configured_yolo_and_active_asset_are_selected_without_hiding_limitations() -> None:
hook = read_feature("detection")
lab = read_feature("detection")
assert "useState('yolo-configured')" in hook
assert "useState(0.15)" in hook
assert "asset.active" in hook
assert "getYoloPreflight" in hook
assert 'aria-label="Status gebouwdetectie"' in lab
assert "Nog niet nationaal gevalideerd" in lab
assert "selectedDetectionModel?.nationally_validated !== true" in lab
assert "selectedDetectionModel?.validation_scope" in lab
assert "vereisen lokale referentiedata en QA" in lab
assert "Modelkalibratie voor beheerders" in lab
def test_visible_ai_and_quality_labels_are_end_user_facing() -> None:
profiles = read_feature("detection")
quality = read_feature("quality")
export_preview = read("frontend/src/components/exports/ExportPreview.tsx")
providers = read("frontend/src/components/providers/ProviderPanel.tsx")
assert "Aanbevolen controleprofiel kleine gebouwen" in profiles
assert "Slechts drie pure-achtergrondbeelden" in profiles
assert "controlekandidaat en niet als grondwaarheid" in profiles
assert "qualityStatusLabel" in quality
assert "nog niet uitgevoerd" in quality
assert "Nog geen bestand gekozen." in export_preview
assert "providerLayerLabel" in providers
assert "custom: 'eigen laag'" in providers