From 8d75c556b4fdd0272a06ea67620101bc89dd57aa Mon Sep 17 00:00:00 2001 From: gummiflip Date: Thu, 25 Jun 2026 10:55:30 +0200 Subject: [PATCH] test: add offscreen smoke for Settings, TTS and History window instantiation Extends test_smoke_launch.py with test_secondary_windows_instantiate, which boots a BlitztextApp offscreen and verifies that all three previously uncovered dialog/panel constructors (HistoryPanel, TtsWindow, SettingsDialog) produce live objects without errors. SettingsDialog is instantiated directly to avoid the exec() call in show_settings_dialog(); History and TTS use the same lazy-init path as production code. Completes the smoke coverage goal: MainWindow, Tray, Compose, Settings, TTS, and History are now all exercised under WHISPER_GUI_TESTS=1. --- tests/test_smoke_launch.py | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/test_smoke_launch.py b/tests/test_smoke_launch.py index 567114a..d3bcb21 100644 --- a/tests/test_smoke_launch.py +++ b/tests/test_smoke_launch.py @@ -88,6 +88,46 @@ def test_app_boots_idles_and_exits_clean(ui_language, tmp_path): set_language(DEFAULT_LANGUAGE) +@gui_only +def test_secondary_windows_instantiate(tmp_path): + """Settings-, TTS- und History-Fenster lassen sich offscreen instanziieren.""" + from PyQt6.QtWidgets import QApplication + + from app.blitztext_linux import BlitztextApp, SettingsDialog + from app.config import Config + + config = Config.load(tmp_path / "config.json") + + qapp = QApplication.instance() or QApplication([]) + app = None + try: + with patch("app.blitztext_linux.Config.load", return_value=config): + app = BlitztextApp(qapp) + app.stop_hotkey_worker() + qapp.processEvents() + + # History-Panel: lazy-init via show_history_panel(). + app.show_history_panel() + qapp.processEvents() + assert app._history_panel is not None + + # TTS-Fenster: lazy-init via show_tts_window(). + app.show_tts_window() + qapp.processEvents() + assert app._tts_window is not None + + # Settings-Dialog: direkt instanziieren, da show_settings_dialog() exec() aufruft. + dlg = SettingsDialog(config) + qapp.processEvents() + assert dlg is not None + dlg.close() + + finally: + if app is not None: + app.stop_hotkey_worker() + set_language(DEFAULT_LANGUAGE) + + @gui_only def test_compose_dialog_lifecycle(tmp_path): """Compose-Dialog öffnet sich, wird wiederverwendet und übersetzt sich neu."""