from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def test_detection_operator_profiles_define_explicit_yolo_candidates_and_promoted_profile() -> None: profiles = ROOT / "frontend" / "src" / "components" / "detection" / "detectionProfiles.ts" source = profiles.read_text(encoding="utf-8") assert "DETECTION_OPERATOR_PROFILES" in source assert "geointel-building-yolov8s-smallbld-minpx3-img640-ft30-pt" in source assert "geointel-building-yolov8s-aoi1024expandedminpx4vis035e50-pt" in source assert "geointel-building-yolov8s-aoi1024bg512r3e50-pt" in source assert "small-building-balanced-review" in source assert "expanded-balanced-review" in source assert "conservative-review" in source assert "confidenceThreshold: 0.15" in source assert "confidenceThreshold: 0.35" in source assert "defaultApproved: true" in source assert "promotionRecommendation: 'promote_candidate'" in source assert "positiveSampleCount: 7" in source assert "f1: 0.5824578631584316" in source assert "f1: 0.5432865390636915" in source assert "maxBackgroundDetections: 0" in source assert "pure-empty gate passed" in source assert "1,571 fewer false negatives" in source assert "higher false-positive review load" in source def test_detection_lab_surfaces_profiles_as_deliberate_operator_actions() -> None: lab = (ROOT / "frontend" / "src" / "components" / "detection" / "DetectionLab.tsx").read_text( encoding="utf-8" ) assert "DETECTION_OPERATOR_PROFILES" in lab assert "Gevalideerde profielen" in lab assert "profile.displayName" in lab assert "profile.confidenceThreshold" in lab assert "kandidaat ยท extra controle vereist" in lab assert "standaardprofiel" in lab assert "Profiel gebruiken" in lab assert "onApplyOperatorProfile(profile)" in lab assert "Recommended starting threshold: 0.25" not in lab def test_detection_workflow_applies_profiles_without_selecting_the_first_arbitrary_asset() -> None: hook = (ROOT / "frontend" / "src" / "hooks" / "useDetectionWorkflow.ts").read_text(encoding="utf-8") app = (ROOT / "frontend" / "src" / "App.tsx").read_text(encoding="utf-8") assert "applyDetectionOperatorProfile" in hook assert "setSelectedDetectionModelId('yolo-configured')" in hook assert "setSelectedModelAssetId(profile.modelAssetId)" in hook assert "setDetectionConfidenceThreshold(profile.confidenceThreshold)" in hook assert "setSelectedModelAssetId(assetResponse.items[0]" not in hook assert "onApplyOperatorProfile={applyDetectionOperatorProfile}" in app