def test_reading_history_does_not_block_current_task_confirmation(ui): window = ui.window ui.settle() confirmations = [] window._quick_run_confirmer = lambda *args: confirmations.append(args) or False original = window.history_panel._worker window.history_panel._worker = object() try: window._update_gates() assert window.run_panel.quick_run_button.isEnabled() window.run_panel.quick_run_button.click() assert confirmations == [('current', 1, 1)] assert not ui.calls finally: window.history_panel._worker = original window._update_gates() def test_owned_modal_can_be_handled_while_execution_worker_is_busy(ui, monkeypatch): window = ui.window ui.settle() worker = object() invoked = [] monkeypatch.setattr('dx_productivity.trial_task_center.ui.cad_dialog_operations.show_cad_dialogs', lambda current: invoked.append(current)) window.service._supervisor_dialog_state = {'supervision': {'blocked': True}} window._workers.add(worker) try: window._update_gates() button = window.run_panel.cleanup_resources_button assert not button.isHidden() and button.isEnabled() button.click() assert invoked == [window] finally: window._workers.discard(worker) window.service._supervisor_dialog_state = None window._update_gates() def test_retained_resource_force_requires_explicit_operator_choice(ui, qtbot, monkeypatch): from PySide6.QtWidgets import QMessageBox window = ui.window ui.settle() forced = [] monkeypatch.setattr(window.service, 'cleanup_batch_resources', lambda: ({'state': 'blocked'},)) monkeypatch.setattr(window.service, 'force_pending_owned_resources', lambda *, confirmed=False: forced.append(confirmed) or ()) def run_async(action, done, *_a, on_finished=None, **_k): done(action()) if on_finished is not None: on_finished() monkeypatch.setattr(window, '_run_async', run_async) monkeypatch.setattr(QMessageBox, 'question', lambda *_a, **_k: QMessageBox.StandardButton.No) window.run_panel.cleanup_resources_button.setEnabled(True) window._cleanup_batch_resources() assert forced == [] monkeypatch.setattr(QMessageBox, 'question', lambda *_a, **_k: QMessageBox.StandardButton.Yes) window.run_panel.cleanup_resources_button.setEnabled(True) window._cleanup_batch_resources() qtbot.waitUntil(lambda: forced == [True])