fix: comparison results never reached QML; restore click-box run selection

This commit is contained in:
jack
2026-07-06 13:12:58 -07:00
parent f604308466
commit 3b919f576f
3 changed files with 137 additions and 149 deletions
+36 -1
View File
@@ -64,7 +64,42 @@ def test_compare_files_integration(controller):
assert "series_a" in args
assert "series_b" in args
assert args["frame_offset"] == 0
def test_comparison_result_reaches_qml(qapp, controller):
"""The result dict must arrive in QML as a real JS object with fields.
Signal(object) delivers Python dicts to QML as an opaque empty wrapper;
the signal must be declared with a dict/QVariantMap signature.
"""
from PySide6.QtQml import QQmlApplicationEngine
engine = QQmlApplicationEngine()
engine.rootContext().setContextProperty("streamController", controller)
engine.loadData(b"""
import QtQuick
Item {
id: probe
property bool gotSuccess: false
property real gotDistance: -1
Connections {
target: streamController
function onComparisonResult(result) {
probe.gotSuccess = result.success === true
probe.gotDistance = result.distance !== undefined ? result.distance : -1
}
}
}
""")
assert engine.rootObjects(), "probe QML failed to load"
root = engine.rootObjects()[0]
csv_path = "tests/fixtures/sample_stream.csv"
controller.compareFiles(csv_path, csv_path)
qapp.processEvents()
assert root.property("gotSuccess") is True
assert root.property("gotDistance") >= 0
def test_recording_toggle(controller, tmp_path):
csv_path = str(tmp_path / "rec" / "live_test.csv")
controller.startRecording(csv_path, "SN123")