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>
This commit is contained in:
@@ -20,7 +20,7 @@ from app.services.storage_service import StorageService
|
||||
from app.services.source_registry_service import SourceRegistryService
|
||||
from app.services.temporal_analysis_service import TemporalAnalysisService
|
||||
from app.services.thematic_raster_analysis_service import ThematicRasterAnalysisService
|
||||
from tests.frontend_contract import assert_calls, assert_mentions, assert_wired, read_map_workspace
|
||||
from tests.frontend_contract import assert_calls, assert_mentions, assert_wired, read_map_workspace, read_feature
|
||||
|
||||
|
||||
class FakeSession:
|
||||
@@ -365,7 +365,7 @@ def test_map_result_export_endpoint_uses_canonical_envelope(monkeypatch) -> None
|
||||
def test_frontend_persists_map_result_before_opening_downloads() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
workspace = read_map_workspace()
|
||||
hook = (root / "frontend/src/hooks/useExportWorkflow.ts").read_text(encoding="utf-8")
|
||||
hook = read_feature("exports")
|
||||
api = (root / "frontend/src/services/api/exports.ts").read_text(encoding="utf-8")
|
||||
|
||||
assert "persistActiveResultAndOpenDownloads" in workspace
|
||||
@@ -409,7 +409,7 @@ def test_project_list_supports_exact_canonical_workspace_lookup(monkeypatch) ->
|
||||
|
||||
def test_frontend_fetches_canonical_workspace_outside_default_project_page() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
workflow = (root / "frontend/src/hooks/useProjectWorkspace.ts").read_text(encoding="utf-8")
|
||||
workflow = read_feature("shell")
|
||||
api = (root / "frontend/src/services/api/projects.ts").read_text(encoding="utf-8")
|
||||
|
||||
assert "projectsApi.list({ name: REGIONAL_WORKSPACE_PROJECT_NAME, limit: 1 })" in workflow
|
||||
@@ -419,7 +419,7 @@ def test_frontend_fetches_canonical_workspace_outside_default_project_page() ->
|
||||
|
||||
def test_theme_failures_name_the_source_and_reason() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
hook = (root / "frontend/src/hooks/useMapThemeSelectionInsights.ts").read_text(encoding="utf-8")
|
||||
hook = read_feature("map_workspace")
|
||||
|
||||
assert "queries[index]?.dataset?.name" in hook
|
||||
assert "queries[index]?.acquisition?.displayName" in hook
|
||||
@@ -429,7 +429,7 @@ def test_theme_failures_name_the_source_and_reason() -> None:
|
||||
|
||||
def test_workspace_navigation_resets_the_actual_scroll_container() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
app = (root / "frontend/src/App.tsx").read_text(encoding="utf-8")
|
||||
app = read_feature("shell")
|
||||
|
||||
assert "const workbenchMainRef = useRef<HTMLElement | null>(null)" in app
|
||||
assert "workbenchMainRef.current?.scrollTo({ top: 0, left: 0 })" in app
|
||||
@@ -439,8 +439,8 @@ def test_workspace_navigation_resets_the_actual_scroll_container() -> None:
|
||||
|
||||
def test_quality_scores_have_plain_language_interpretation() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
quality = (root / "frontend/src/components/quality/QualityResultsPanel.tsx").read_text(encoding="utf-8")
|
||||
detection = (root / "frontend/src/components/detection/DetectionLab.tsx").read_text(encoding="utf-8")
|
||||
quality = read_feature("quality")
|
||||
detection = read_feature("detection")
|
||||
|
||||
assert "Laatste score (0-1)" in quality
|
||||
assert "Bruikbaar na controle" in quality
|
||||
@@ -465,7 +465,7 @@ def test_map_and_detection_workspaces_avoid_page_length_driven_layouts() -> None
|
||||
|
||||
def test_detection_lab_only_receives_operational_imagery_rasters() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
app_source = (root / "frontend/src/App.tsx").read_text(encoding="utf-8")
|
||||
app_source = read_feature("shell")
|
||||
capability_source = (root / "frontend/src/lib/datasetCapabilities.ts").read_text(encoding="utf-8")
|
||||
|
||||
assert "department_omgeving_thematic_raster" in capability_source
|
||||
@@ -480,7 +480,7 @@ def test_detection_lab_only_receives_operational_imagery_rasters() -> None:
|
||||
|
||||
def test_download_workspace_surfaces_map_results_in_plain_dutch() -> None:
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
exports = (root / "frontend/src/components/exports/ExportCenter.tsx").read_text(encoding="utf-8")
|
||||
exports = read_feature("exports")
|
||||
|
||||
assert "Gebiedsanalyse (JSON)" in exports
|
||||
assert "Historische vergelijking (JSON)" in exports
|
||||
|
||||
Reference in New Issue
Block a user