diff --git a/tests/unit/gui/test_main_window.py b/tests/unit/gui/test_main_window.py index c1cd7040..45f6c84e 100644 --- a/tests/unit/gui/test_main_window.py +++ b/tests/unit/gui/test_main_window.py @@ -14,7 +14,7 @@ def mock_ui_state(): yield mock -def test_main_window_init(qtbot, mock_ui_state): +def test_main_window_init(qtbot, mock_ui_state, daq_status_factory): with ( patch("requests.get") as mock_get, patch("aare.gui.main_window.DAQWorker"), @@ -71,6 +71,25 @@ def test_main_window_init(qtbot, mock_ui_state): win.data_collection._emit_change_energy() assert sent and abs(sent[0] - 12400.0) < 1e-6 + # Motion watch: robot motion switches to the combined beamline view; + # alignment beginning switches straight back to the sample camera even + # while the busy flag is still set — busy moves during Sample + # alignment ARE the alignment, so it never re-triggers the switch. + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.RobotSampleExchange, busy=True) + ) + assert win._watching_motion + assert win.video_tab.currentWidget() is win.beamline_combined_panel + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.SampleAlignment, busy=True) + ) + assert not win._watching_motion + assert win.video_tab.currentWidget() is win.sample_camera + win.update_daq_status( + daq_status_factory(state=BeamlineStateEnum.SampleAlignment, busy=True) + ) + assert not win._watching_motion + def test_main_window_mount_view(qtbot, mock_ui_state): with (