from pathlib import Path from tests.frontend_contract import read_feature ROOT = Path(__file__).resolve().parents[2] def test_detection_lab_has_guided_threshold_calibration_runner() -> None: hook = ROOT / "frontend" / "src" / "hooks" / "useDetectionWorkflow.ts" lab = ROOT / "frontend" / "src" / "components" / "detection" / "DetectionLab.tsx" todo = ROOT / "docs" / "TODO.md" hook_source = hook.read_text(encoding="utf-8") lab_source = lab.read_text(encoding="utf-8") app_source = read_feature("shell") todo_source = todo.read_text(encoding="utf-8") assert "interface DetectionCalibrationRunRow" in hook_source assert "parseCalibrationThresholds" in hook_source assert "calibrationThresholdText" in hook_source assert "runningDetectionCalibration" in hook_source assert "detectionCalibrationRows" in hook_source assert "detectionCalibrationError" in hook_source assert "runDetectionCalibration" in hook_source assert "executeDetection(" in hook_source # Every requested threshold is reported, but from one inference pass at the # lowest cut: detections above a higher cut are a subset of it, and # suppression walks candidates in descending confidence, so the kept set # above a cut does not depend on the threshold the run used. Asserting the # old per-threshold loop pinned N GPU passes that produced identical numbers. assert "lowestThreshold," in hook_source assert "calibration_thresholds: thresholds" in hook_source assert "calibration_sweep" in hook_source assert "{ calibration: true, calibration_thresholds: thresholds }," in hook_source assert "detectionApi.compareWithReference(result.analysis_run_id" in hook_source assert "reference_dataset_id: referenceDatasetId" in hook_source assert "Kies eerst een referentiebron om te kalibreren" in hook_source assert "Geef minstens één geldige drempel tussen 0 en 1 op" in hook_source assert "Kalibratie met YOLO vereist een beeldtegelmanifest" in hook_source assert "Kies eerst een lokaal modelbestand om te kalibreren" in hook_source assert "Modelkalibratie voor beheerders" in lab_source assert "Voert het lokale model en een kwaliteitscontrole uit" in lab_source assert "Zekerheidsdrempels" in lab_source assert "Drempels vergelijken" in lab_source assert "Voortgang modelkalibratie" in lab_source assert "detectionCalibrationRows.map" in lab_source assert "runningDetectionCalibration" in lab_source assert "detectionCalibrationError" in lab_source assert "onRunCalibration" in lab_source assert "onSetCalibrationThresholdText" in lab_source assert "calibrationThresholdText={calibrationThresholdText}" in app_source assert "runningDetectionCalibration={runningDetectionCalibration}" in app_source assert "detectionCalibrationRows={detectionCalibrationRows}" in app_source assert "onRunCalibration={runDetectionCalibration}" in app_source assert "[x] Add guided in-app detection calibration runner" in todo_source