更新
This commit is contained in:
@@ -7,10 +7,12 @@ from typing import Any
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import pytest
|
||||
from PySide6.QtCore import QSettings
|
||||
from PySide6.QtCore import QEvent, QObject, QSettings
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from doctor_workstation.services import DemoDoctorRepository
|
||||
from doctor_workstation.ui.login import LoginWindow
|
||||
from doctor_workstation.ui.shell import ShellWindow
|
||||
from doctor_workstation.ui.widgets import BusyOverlay
|
||||
|
||||
|
||||
@@ -87,3 +89,41 @@ def test_login_loading_does_not_spawn_extra_windows(
|
||||
|
||||
window.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_shell_construction_never_shows_orphan_business_controls(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
shown: list[tuple[str, str]] = []
|
||||
|
||||
class OrphanShowRecorder(QObject):
|
||||
def eventFilter(self, watched: QObject, event: QEvent) -> bool: # noqa: N802
|
||||
if (
|
||||
event.type() == QEvent.Type.Show
|
||||
and isinstance(watched, QWidget)
|
||||
and watched.parentWidget() is None
|
||||
):
|
||||
text = getattr(watched, "text", lambda: "")()
|
||||
shown.append((type(watched).__name__, str(text)))
|
||||
return False
|
||||
|
||||
repository = DemoDoctorRepository()
|
||||
session = repository.login(repository.DEMO_ACCOUNT, repository.DEMO_PASSWORD)
|
||||
recorder = OrphanShowRecorder(application)
|
||||
application.installEventFilter(recorder)
|
||||
try:
|
||||
shell = ShellWindow(
|
||||
repository,
|
||||
{
|
||||
"session": session,
|
||||
"user": session.user,
|
||||
"demo_mode": True,
|
||||
},
|
||||
permissions=session.permissions,
|
||||
)
|
||||
finally:
|
||||
application.removeEventFilter(recorder)
|
||||
|
||||
assert shown == []
|
||||
shell.close()
|
||||
application.processEvents()
|
||||
|
||||
Reference in New Issue
Block a user