Files
geointel/backend/tests/test_sprint53_selection_ergonomics.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

71 lines
2.8 KiB
Python

from pathlib import Path
from tests.frontend_contract import read_feature
ROOT = Path(__file__).resolve().parents[2]
def test_dataset_panel_exposes_map_and_export_quick_actions() -> None:
panel = read_feature("datasets")
assert "selectedDatasetId" in panel
assert "dataset-card-active" in panel
assert "onOpenDatasetInMap" in panel
assert "onOpenDatasetExport" in panel
assert "Open op kaart" in panel
assert "Downloaden" in panel
assert "disabled={!(dataset.dataset_type === 'vector' || dataset.dataset_type === 'geojson')}" in panel
def test_data_workspace_keeps_catalog_wide_enough_for_populated_state() -> None:
css = (ROOT / "frontend" / "src" / "styles" / "app.css").read_text(encoding="utf-8")
assert ".workspace-grid-data {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}" in css
assert ".workspace-grid-data > section:nth-child(3)" in css
assert "grid-column: 1 / -1" in css
assert ".dataset-card .button-row" in css
def test_shell_preserves_workspace_width_on_standard_desktop_viewports() -> None:
css = (ROOT / "frontend" / "src" / "styles" / "app.css").read_text(encoding="utf-8")
app = read_feature("shell")
assert "grid-template-columns: 12.5rem minmax(0, 1fr) 21rem" in css
assert "@media (max-width: 1360px)" in css
assert ".workbench-inspector {\n grid-column: 1 / -1;" in css
assert "height: auto;" in css
assert "workbenchMainRef.current?.scrollTo({ top: 0, left: 0 })" in app
assert "}, [activeWorkspace])" in app
def test_app_wires_dataset_quick_actions_to_existing_workspaces() -> None:
app = read_feature("shell")
assert "const openDatasetInMap = (dataset: DatasetCreateResponse) => {" in app
assert "loadDatasetDetails(selectedProjectId, dataset)" in app
assert "setMapLayerVisible(true)" in app
assert "setActiveWorkspace('map')" in app
assert "const openDatasetExport = (dataset: DatasetCreateResponse) => {" in app
assert "setActiveWorkspace('exports')" in app
assert "selectedDatasetId={selectedDatasetId}" in app
assert "onOpenDatasetInMap={openDatasetInMap}" in app
assert "onOpenDatasetExport={openDatasetExport}" in app
def test_inspector_exposes_navigation_actions_without_api_calls() -> None:
inspector = (
ROOT / "frontend" / "src" / "components" / "inspector" / "WorkbenchInspector.tsx"
).read_text(encoding="utf-8")
assert "onOpenDataWorkspace" in inspector
assert "onOpenMapWorkspace" in inspector
assert "onOpenQualityWorkspace" in inspector
assert "onOpenExportsWorkspace" in inspector
assert "onOpenAiWorkspace" in inspector
assert "Gegevenscatalogus" in inspector
assert "Kaartlaag" in inspector
assert "Kwaliteit openen" in inspector
assert "Downloads openen" in inspector
assert "Beeldanalyse openen" in inspector
assert "fetch(" not in inspector