|
11 | 11 | def page(qapp): |
12 | 12 | """UpdatePage instance with all heavy UI deps mocked.""" |
13 | 13 | patches = [ |
14 | | - patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.LoadingOverlayWidget"), |
15 | | - patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BlocksCustomButton"), |
| 14 | + patch( |
| 15 | + "BlocksScreen.lib.panels.widgets.MainWindow.updatePage.LoadingOverlayWidget" |
| 16 | + ), |
| 17 | + patch( |
| 18 | + "BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BlocksCustomButton" |
| 19 | + ), |
16 | 20 | patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.IconButton"), |
17 | 21 | ] |
18 | 22 | for p in patches: |
@@ -307,12 +311,22 @@ def test_false_does_not_emit_call_load_panel_when_no_overlay(self, page, qtbot): |
307 | 311 | with qtbot.assertNotEmitted(page.call_load_panel, wait=200): |
308 | 312 | page.handle_busy_changed(False) |
309 | 313 |
|
310 | | - def test_false_emits_call_load_panel_when_overlay_shown(self, page, qtbot): |
| 314 | + def test_false_holds_overlay_until_status_ready(self, page, qtbot): |
311 | 315 | page.show_loading = MagicMock() |
312 | 316 | page._overlay_shown = True |
313 | | - with qtbot.waitSignal(page.call_load_panel, timeout=200) as blocker: |
| 317 | + with qtbot.assertNotEmitted(page.call_load_panel, wait=200): |
314 | 318 | page.handle_busy_changed(False) |
315 | | - assert blocker.args == [False, "",False] |
| 319 | + assert page._overlay_shown is True |
| 320 | + with qtbot.waitSignal(page.call_load_panel, timeout=200) as blocker: |
| 321 | + page.handle_status_ready(_make_payload()) |
| 322 | + assert blocker.args == [False, "", False] |
| 323 | + assert page._overlay_shown is False |
| 324 | + |
| 325 | + def test_stale_overlay_fallback_dismisses(self, page, qtbot): |
| 326 | + page._overlay_shown = True |
| 327 | + page._busy = False |
| 328 | + with qtbot.waitSignal(page.call_load_panel, timeout=200): |
| 329 | + page._dismiss_stale_overlay() |
316 | 330 | assert page._overlay_shown is False |
317 | 331 |
|
318 | 332 | def test_true_starts_elapsed_timer(self, page): |
@@ -413,13 +427,13 @@ class TestHandleStepComplete: |
413 | 427 | def test_emits_call_load_panel_with_step_message(self, page, qtbot): |
414 | 428 | with qtbot.waitSignal(page.call_load_panel, timeout=200) as blocker: |
415 | 429 | page.handle_step_complete("klipper", 1, 4) |
416 | | - assert blocker.args == [True, "klipper: fetching",False] |
| 430 | + assert blocker.args == [True, "klipper: fetching", False] |
417 | 431 | page._progress_label.setText.assert_called_with("Step 1/4") |
418 | 432 |
|
419 | 433 | def test_unknown_steps_falls_back_to_working(self, page, qtbot): |
420 | 434 | with qtbot.waitSignal(page.call_load_panel, timeout=200) as blocker: |
421 | 435 | page.handle_step_complete("moonraker", 99, 4) |
422 | | - assert blocker.args == [True, "moonraker: working",False] |
| 436 | + assert blocker.args == [True, "moonraker: working", False] |
423 | 437 | page._progress_label.setText.assert_called_with("Step 99/4") |
424 | 438 |
|
425 | 439 |
|
@@ -498,7 +512,9 @@ def test_bad_payload_keeps_statuses_and_toasts(self, page): |
498 | 512 |
|
499 | 513 | class TestConfirmPopupCleanup: |
500 | 514 | def test_second_confirm_deletes_previous_popup(self, page): |
501 | | - with patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BasePopup") as popup_cls: |
| 515 | + with patch( |
| 516 | + "BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BasePopup" |
| 517 | + ) as popup_cls: |
502 | 518 | first = MagicMock() |
503 | 519 | second = MagicMock() |
504 | 520 | popup_cls.side_effect = [first, second] |
|
0 commit comments