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>
52 lines
2.0 KiB
Python
52 lines
2.0 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_theme_overview_names_the_metric_instead_of_showing_a_bare_value() -> None:
|
|
workspace = read_feature("map_workspace")
|
|
styles = read("frontend/src/styles/app.css")
|
|
|
|
assert 'className="geo-theme-result-value"' in workspace
|
|
assert "item.result.summary.metric_label" in workspace
|
|
assert ".geo-theme-result-value" in styles
|
|
|
|
|
|
def test_current_and_historical_results_are_downloadable() -> None:
|
|
workspace = read_feature("map_workspace")
|
|
|
|
assert "activeTheme.id}-analysis.json" in workspace
|
|
assert "activeTheme.id}-selection.geojson" in workspace
|
|
assert "application/geo+json" in workspace
|
|
assert "downloadTemporalComparison" in workspace
|
|
assert "Download vergelijking" in workspace
|
|
assert "Kopieer vergelijking" in workspace
|
|
|
|
|
|
def test_completed_analysis_hands_off_to_ai_and_downloads_responsively() -> None:
|
|
app = read("frontend/src/App.tsx")
|
|
workspace = read_feature("map_workspace")
|
|
styles = read("frontend/src/styles/app.css")
|
|
|
|
assert "onOpenAssistant: () => void" in workspace
|
|
assert "onOpenExports: () => void" in workspace
|
|
assert "Stel AI-vraag" in workspace
|
|
assert "Bewaar in downloads" in workspace
|
|
assert "persistActiveResultAndOpenDownloads" in workspace
|
|
assert "onPersistMapResult(payload)" in workspace
|
|
assert "onOpenAssistant={() => setActiveWorkspace('assistant')}" in app
|
|
assert "onOpenExports={() => setActiveWorkspace('exports')}" in app
|
|
assert "onPersistMapResult={persistMapResult}" in app
|
|
assert 'className="workspace-persistent-map"' in app
|
|
assert "hidden={activeWorkspace !== 'map'}" in app
|
|
assert "{activeWorkspace === 'map' ? (" not in app
|
|
assert ".geo-result-next-actions" in styles
|
|
assert ".geo-results-panel > .geo-result-next-actions" in styles
|
|
assert ".workspace-persistent-map[hidden]" in styles
|