fix(ui): join cleanup completion with explicit force confirmation
Core regression / Python core and release configuration (push) Successful in 42s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 35s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 42s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 35s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
086e0ebb61
commit
189ddc238b
3 files changed
+69
-16
No files matched your search
@@ -1,24 +1,61 @@
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from PySide6.QtCore import QTimer
|
||||
from threading import Event
|
||||
|
||||
import pytest
|
||||
|
||||
from test_ui_remediation import window
|
||||
|
||||
|
||||
def test_confirmed_force_runs_after_cleanup_worker_finishes(window, qtbot, monkeypatch):
|
||||
@pytest.mark.parametrize('finish_order', ['normal', 'after_confirmation', 'during_confirmation'])
|
||||
@pytest.mark.parametrize('confirmed', [False, True])
|
||||
def test_confirmed_force_runs_after_cleanup_worker_finishes(window, qtbot, monkeypatch, finish_order, confirmed):
|
||||
qtbot.waitUntil(lambda: not window._workers and not window._resource_status.busy)
|
||||
pending = ({'state': 'blocked', 'kind': 'retained_worker', 'force_available': True},)
|
||||
monkeypatch.setattr(window.service, 'pending_batch_resources', lambda: pending)
|
||||
monkeypatch.setattr(window.service, 'cleanup_batch_resources', lambda: pending)
|
||||
from dx_productivity.trial_task_center.ui.workers import ServiceWorker
|
||||
release, prompted, event_turn = Event(), Event(), Event()
|
||||
original_run = ServiceWorker.run
|
||||
def gated_run(worker):
|
||||
if finish_order != 'normal' and worker.action is window.service.cleanup_batch_resources:
|
||||
try:
|
||||
worker.signals.succeeded.emit(worker.action())
|
||||
assert release.wait(5)
|
||||
finally:
|
||||
worker.signals.finished.emit()
|
||||
else:
|
||||
original_run(worker)
|
||||
monkeypatch.setattr(ServiceWorker, 'run', gated_run)
|
||||
calls = []
|
||||
def force(*, confirmed):
|
||||
calls.append(confirmed)
|
||||
return ()
|
||||
monkeypatch.setattr(window.service, 'force_pending_owned_resources', force)
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *_a, **_k: QMessageBox.StandardButton.Yes)
|
||||
def confirm(*_a, **_k):
|
||||
prompted.set()
|
||||
if finish_order == 'during_confirmation':
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
assert calls == []
|
||||
QTimer.singleShot(0, event_turn.set)
|
||||
return QMessageBox.StandardButton.Yes if confirmed else QMessageBox.StandardButton.No
|
||||
monkeypatch.setattr(QMessageBox, 'question', confirm)
|
||||
window._resource_status.records = pending
|
||||
window._resource_status.known = True
|
||||
window._update_gates()
|
||||
window.run_panel.cleanup_resources_button.click()
|
||||
qtbot.waitUntil(lambda: calls == [True] and not window._workers)
|
||||
try:
|
||||
window.run_panel.cleanup_resources_button.click()
|
||||
qtbot.waitUntil(lambda: prompted.is_set() and event_turn.is_set())
|
||||
if finish_order == 'after_confirmation':
|
||||
assert calls == []
|
||||
assert window._workers
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
assert calls == ([True] if confirmed else [])
|
||||
finally:
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
|
||||
|
||||
def test_lost_handles_show_restart_hint_without_unusable_force_prompt(window, qtbot, monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user