更新
This commit is contained in:
@@ -10,13 +10,20 @@ os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtWidgets import QApplication, QPushButton
|
||||
|
||||
from doctor_workstation.core import PermissionSet
|
||||
from doctor_workstation.services.api_client import ApiClient
|
||||
from doctor_workstation.services.mock_repository import DemoDoctorRepository
|
||||
from doctor_workstation.services.repository import RemoteDoctorRepository
|
||||
from doctor_workstation.ui.pages import reception as reception_module
|
||||
from doctor_workstation.ui.pages.reception import NOTE_LIMIT, ReceptionPage
|
||||
from doctor_workstation.ui.pages.reception import (
|
||||
NOTE_LIMIT,
|
||||
QueueRow,
|
||||
ReceptionPage,
|
||||
_is_image_attachment,
|
||||
)
|
||||
from doctor_workstation.ui.widgets import StatusBadge
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@@ -50,6 +57,71 @@ def immediate_async(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(reception_module, "run_async", run_immediately)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("path", "expected"),
|
||||
[
|
||||
("https://cdn.test/tongue.JPG?token=1", True),
|
||||
("https://cdn.test/report.webp", True),
|
||||
("https://cdn.test/report.pdf", False),
|
||||
],
|
||||
)
|
||||
def test_note_attachment_preview_type_is_extension_aware(path: str, expected: bool) -> None:
|
||||
assert _is_image_attachment(path) is expected
|
||||
|
||||
|
||||
def test_note_attachments_offer_image_preview_and_file_open(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
page = ReceptionPage(DemoDoctorRepository(), PermissionSet([]))
|
||||
page._render_notes(
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"note_date": "2026-08-12",
|
||||
"tongue_images": ["https://cdn.test/tongue.jpg"],
|
||||
"report_files": [
|
||||
"https://cdn.test/check.png",
|
||||
"https://cdn.test/check.pdf",
|
||||
],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
labels = [button.text() for button in page.notes_container.findChildren(QPushButton)]
|
||||
assert labels.count("预览") == 2
|
||||
assert labels.count("打开") == 1
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_queue_status_badge_is_not_clipped_in_narrow_panel(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
row = QueueRow(
|
||||
{
|
||||
"patient_name": "张蒙",
|
||||
"status": 1,
|
||||
"status_desc": "待接诊",
|
||||
"appointment_time": "12:45:00",
|
||||
"gender": 1,
|
||||
"age": 36,
|
||||
"assistant_name": "苏亚梅",
|
||||
}
|
||||
)
|
||||
row.setFixedWidth(280)
|
||||
row.show()
|
||||
application.processEvents()
|
||||
|
||||
badge = row.findChild(StatusBadge)
|
||||
assert badge is not None
|
||||
assert badge.height() >= 24
|
||||
assert badge.width() >= 54
|
||||
assert badge.geometry().right() < row.width()
|
||||
|
||||
row.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def _detail(
|
||||
appointment_id: int,
|
||||
*,
|
||||
@@ -361,6 +433,7 @@ def test_video_payload_keeps_three_identifiers_distinct(
|
||||
"patient_id": 141,
|
||||
"diagnosis_id": 241,
|
||||
"patient_name": "视频患者",
|
||||
"mode": "im",
|
||||
"record": detail["appointment"],
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user