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:
@@ -1,4 +1,5 @@
|
||||
from pathlib import Path
|
||||
from tests.frontend_contract import read_feature
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
@@ -24,7 +25,7 @@ def test_national_workspace_is_automatic_and_map_has_one_scope_selector() -> Non
|
||||
|
||||
|
||||
def test_primary_navigation_uses_end_user_language_and_keeps_management_secondary() -> None:
|
||||
app = read("frontend/src/App.tsx")
|
||||
app = read_feature("shell")
|
||||
|
||||
for label in ("Kaart", "Bronnen", "Kwaliteit", "Beeldanalyse", "Downloads"):
|
||||
assert f"label: '{label}'" in app
|
||||
@@ -35,7 +36,7 @@ def test_primary_navigation_uses_end_user_language_and_keeps_management_secondar
|
||||
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("frontend/src/components/datasets/DatasetPanel.tsx")
|
||||
datasets = read_feature("datasets")
|
||||
dataset_names = read("frontend/src/lib/datasetDisplay.ts")
|
||||
|
||||
assert "TECHNICAL_PROJECT_PATTERN" in projects
|
||||
@@ -50,8 +51,8 @@ def test_technical_projects_and_metadata_are_progressively_disclosed() -> None:
|
||||
|
||||
|
||||
def test_configured_yolo_and_active_asset_are_selected_without_hiding_limitations() -> None:
|
||||
hook = read("frontend/src/hooks/useDetectionWorkflow.ts")
|
||||
lab = read("frontend/src/components/detection/DetectionLab.tsx")
|
||||
hook = read_feature("detection")
|
||||
lab = read_feature("detection")
|
||||
|
||||
assert "useState('yolo-configured')" in hook
|
||||
assert "useState(0.15)" in hook
|
||||
@@ -66,8 +67,8 @@ def test_configured_yolo_and_active_asset_are_selected_without_hiding_limitation
|
||||
|
||||
|
||||
def test_visible_ai_and_quality_labels_are_end_user_facing() -> None:
|
||||
profiles = read("frontend/src/components/detection/detectionProfiles.ts")
|
||||
quality = read("frontend/src/components/quality/QualityResultsPanel.tsx")
|
||||
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user