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>
60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
from pathlib import Path
|
|
from tests.frontend_contract import read_feature
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def test_detection_lab_surfaces_yolo_runtime_preflight() -> None:
|
|
lab = "\n".join(
|
|
(
|
|
(ROOT / "frontend" / "src" / "components" / "detection" / "DetectionLab.tsx").read_text(encoding="utf-8"),
|
|
(ROOT / "frontend" / "src" / "components" / "detection" / "DetectionModelManagement.tsx").read_text(encoding="utf-8"),
|
|
)
|
|
)
|
|
hook = read_feature("detection")
|
|
api = (ROOT / "frontend" / "src" / "services" / "api" / "detection.ts").read_text(encoding="utf-8")
|
|
types = (ROOT / "frontend" / "src" / "types.ts").read_text(encoding="utf-8")
|
|
app = read_feature("shell")
|
|
|
|
assert "Technische YOLO-runtimecontrole" in lab
|
|
assert "torch_version" in lab
|
|
assert "ultralytics_version" in lab
|
|
assert "cuda_available" in lab
|
|
assert "onRefreshYoloPreflight" in lab
|
|
assert "loadYoloPreflight" in hook
|
|
assert "getYoloPreflight" in api
|
|
assert "/api/v1/detection/yolo/preflight" in api
|
|
assert "interface YoloPreflightResponse" in types
|
|
assert "yoloPreflight={yoloPreflight}" in app
|
|
|
|
|
|
def test_detection_lab_surfaces_local_model_asset_selection() -> None:
|
|
lab = "\n".join(
|
|
(
|
|
(ROOT / "frontend" / "src" / "components" / "detection" / "DetectionLab.tsx").read_text(encoding="utf-8"),
|
|
(ROOT / "frontend" / "src" / "components" / "detection" / "DetectionModelManagement.tsx").read_text(encoding="utf-8"),
|
|
)
|
|
)
|
|
hook = read_feature("detection")
|
|
api = (ROOT / "frontend" / "src" / "services" / "api" / "detection.ts").read_text(encoding="utf-8")
|
|
types = (ROOT / "frontend" / "src" / "types.ts").read_text(encoding="utf-8")
|
|
app = read_feature("shell")
|
|
provider_panel = (ROOT / "frontend" / "src" / "components" / "providers" / "ProviderPanel.tsx").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
|
|
assert "interface ModelAssetRead" in types
|
|
assert "model_asset_id?: string | null" in types
|
|
assert "listModelAssets" in api
|
|
assert "/api/v1/detection/model-assets" in api
|
|
assert "modelAssets" in hook
|
|
assert "selectedModelAssetId" in hook
|
|
assert "model_asset_id: selectedModelAssetId || null" in hook
|
|
assert "Lokaal modelbestand" in lab
|
|
assert "onSelectModelAsset" in lab
|
|
assert "modelAssets={modelAssets}" in app
|
|
assert "Officiële referentiebronnen" in provider_panel
|
|
assert "GRB is beschikbaar voor expliciet begrensde kaartselecties" in provider_panel
|
|
assert "OSM blijft uitgeschakeld" in provider_panel
|