from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def read_text(relative_path: str) -> str: return (ROOT / relative_path).read_text(encoding="utf-8") def test_map_qa_result_exposes_quality_check_evidence_contract(): types = read_text("frontend/src/types.ts") hook = read_text("frontend/src/hooks/useMapSelectionQa.ts") workspace = read_text("frontend/src/components/map/MapWorkspace.tsx") app = read_text("frontend/src/App.tsx") assert "quality_check_id?: string" in types assert "latestMapSelectionQualityCheckId" in hook assert "parsed.quality_check_id" in hook assert "setLatestMapSelectionQualityCheckId" in hook assert "onOpenMapSelectionQualityEvidence" in app assert "setActiveWorkspace('analysis')" in app assert "latestMapSelectionQualityCheckId={latestMapSelectionQualityCheckId}" in app assert "onOpenMapSelectionQualityEvidence={openMapSelectionQualityEvidence}" in app assert "QA evidence" in workspace assert "Quality check id" in workspace assert "Mean IoU" in workspace assert "False positives" in workspace assert "False negatives" in workspace assert "Map selection QA warnings" in workspace assert "Open QA/QC evidence" in workspace def test_map_qa_evidence_keeps_backend_contract_unchanged(): app = read_text("frontend/src/App.tsx") api_contracts = read_text("docs/API_CONTRACTS.md") assert "/api/v1/qa/detections-vs-reference" in api_contracts assert "qaApi.runQa" not in app