2026-09-08 02:12:15 -04:00
|
|
|
"""Smoke test for the MainWindow.
|
|
|
|
|
|
|
|
|
|
Marked as ``gui`` so it can be deselected on environments without a display.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
pytest.importorskip("PySide6")
|
|
|
|
|
pytest.importorskip("pyvistaqt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.gui
|
|
|
|
|
def test_main_window_opens(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
|
|
|
from otko.views.main_window import MainWindow
|
|
|
|
|
|
|
|
|
|
window = MainWindow()
|
|
|
|
|
qtbot.addWidget(window)
|
|
|
|
|
window.show()
|
|
|
|
|
assert window.isVisible()
|
|
|
|
|
assert window.windowTitle() == "OTKO"
|
2026-09-16 12:03:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.gui
|
|
|
|
|
def test_close_dirty_hidden_window_does_not_block(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
|
|
|
"""Closing a dirty but hidden window must not raise a modal prompt.
|
|
|
|
|
|
|
|
|
|
Qt closes hidden widgets during teardown (as ``pytest-qt`` does); a
|
|
|
|
|
modal "unsaved changes" dialog there would block forever with no user
|
|
|
|
|
to answer it. The prompt is therefore gated on visibility.
|
|
|
|
|
"""
|
|
|
|
|
from otko.views.main_window import MainWindow
|
|
|
|
|
|
|
|
|
|
window = MainWindow()
|
|
|
|
|
qtbot.addWidget(window)
|
|
|
|
|
window._vm.new_project()
|
|
|
|
|
window._vm.mark_dirty()
|
|
|
|
|
assert not window.isVisible()
|
|
|
|
|
assert window.close() is True
|
|
|
|
|
assert window._vm.is_dirty # unchanged: the prompt was skipped
|