更新
This commit is contained in:
@@ -9,7 +9,7 @@ from typing import Any
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import pytest
|
||||
from PySide6.QtWidgets import QApplication, QDialog, QLabel
|
||||
from PySide6.QtWidgets import QApplication, QDialog, QDialogButtonBox, QLabel
|
||||
|
||||
from doctor_workstation.core.errors import ApiProtocolError
|
||||
from doctor_workstation.core.models import Appointment, PageResult
|
||||
@@ -348,14 +348,14 @@ def test_appointment_multiline_cells_receive_enough_row_height(
|
||||
False,
|
||||
)
|
||||
|
||||
patient_text = page.table.item(0, 1).text()
|
||||
appointment_text = page.table.item(0, 3).text()
|
||||
assert patient_text.count("\n") == 2
|
||||
assert appointment_text == "2026-08-11\n14:30"
|
||||
patient_text = page.table.item(0, 2).text()
|
||||
appointment_text = page.table.item(0, 4).text()
|
||||
assert patient_text == "张玉英"
|
||||
assert appointment_text.count("\n") == 2
|
||||
assert "2026-08-11 14:30" in appointment_text
|
||||
required = 3 * max(16, page.table.fontMetrics().lineSpacing()) + 10
|
||||
assert page.table.rowHeight(0) >= required
|
||||
assert page.table.item(0, 1).toolTip() == patient_text
|
||||
assert page.table.item(0, 3).toolTip() == appointment_text
|
||||
assert page.table.item(0, 4).toolTip() == appointment_text
|
||||
page.close()
|
||||
|
||||
|
||||
@@ -379,11 +379,68 @@ def test_video_qr_dialog_renders_downloaded_image_inside_app(
|
||||
assert image is not None
|
||||
assert image.pixmap() is not None and not image.pixmap().isNull()
|
||||
assert dialog.findChild(QLabel, "VideoQrImage").text() == ""
|
||||
assert dialog.objectName() == "VideoQrDialog"
|
||||
assert dialog.property("businessDialog") is True
|
||||
buttons = dialog.findChild(QDialogButtonBox)
|
||||
assert next(button for button in buttons.buttons() if button.text() == "浏览器打开").property(
|
||||
"variant"
|
||||
) == "primary"
|
||||
dialog.close()
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_page_owned_appointment_dialogs_have_stable_visual_contract(
|
||||
application: QApplication,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
page = AppointmentsPage(
|
||||
DemoDoctorRepository(),
|
||||
permissions=PermissionSet(
|
||||
["doctor.appointment/complete", "doctor.appointment/addDoctorNote"]
|
||||
),
|
||||
current_user={"id": 1001, "role_id": 1},
|
||||
)
|
||||
captured: list[QDialog] = []
|
||||
|
||||
def reject_dialog(dialog: QDialog) -> QDialog.DialogCode:
|
||||
captured.append(dialog)
|
||||
return QDialog.DialogCode.Rejected
|
||||
|
||||
monkeypatch.setattr(QDialog, "exec", reject_dialog)
|
||||
page._open_custom_date()
|
||||
page._show_detail({"id": 101, "patient_name": "鹿立核"}, page._action_generation)
|
||||
page.table.set_rows(
|
||||
[{"id": 101, "diagnosis_id": 501, "patient_id": 301, "status": 1}]
|
||||
)
|
||||
page.table.selectRow(0)
|
||||
page._complete_selected()
|
||||
|
||||
assert [dialog.objectName() for dialog in captured] == [
|
||||
"AppointmentCustomDateDialog",
|
||||
"AppointmentDetailDialog",
|
||||
"AppointmentCompleteDialog",
|
||||
]
|
||||
assert all(dialog.property("businessDialog") is True for dialog in captured)
|
||||
assert all(
|
||||
any(label.property("dialogRole") == "title" for label in dialog.findChildren(QLabel))
|
||||
for dialog in captured
|
||||
)
|
||||
custom_buttons = captured[0].findChild(QDialogButtonBox)
|
||||
complete_buttons = captured[2].findChild(QDialogButtonBox)
|
||||
assert custom_buttons.button(QDialogButtonBox.StandardButton.Ok).property(
|
||||
"variant"
|
||||
) == "primary"
|
||||
assert complete_buttons.button(QDialogButtonBox.StandardButton.Ok).property(
|
||||
"variant"
|
||||
) == "primary"
|
||||
|
||||
for dialog in captured:
|
||||
dialog.close()
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_prescription_case_snapshot_uses_keyword_diagnosis_id(
|
||||
application: QApplication,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
@@ -425,3 +482,64 @@ def test_prescription_case_snapshot_uses_keyword_diagnosis_id(
|
||||
assert opened and opened[0][1]["id"] == 501
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_appointment_ai_report_button_visible_with_reception_permission(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
hidden = AppointmentsPage(
|
||||
SimpleNamespace(),
|
||||
permissions=PermissionSet(["tcm.diagnosis/kaifang"]),
|
||||
)
|
||||
assert hidden.ai_button.isHidden()
|
||||
hidden.close()
|
||||
|
||||
page = AppointmentsPage(
|
||||
SimpleNamespace(),
|
||||
permissions=PermissionSet(["doctor.appointment/reception"]),
|
||||
)
|
||||
assert not page.ai_button.isHidden()
|
||||
assert not page.ai_button.isEnabled()
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_appointments_reference_split_layout_and_video_list(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
page = AppointmentsPage(
|
||||
DemoDoctorRepository(),
|
||||
permissions=PermissionSet(["doctor.appointment/lists"]),
|
||||
current_user={"id": 1001, "role_id": 1},
|
||||
)
|
||||
page.resize(1460, 820)
|
||||
page._loaded(
|
||||
{
|
||||
"lists": [
|
||||
{
|
||||
"id": 101,
|
||||
"diagnosis_id": 501,
|
||||
"patient_name": "赵俊霞",
|
||||
"gender": 0,
|
||||
"age": 53,
|
||||
"assistant_name": "自媒体4",
|
||||
"appointment_date": "2026-08-13",
|
||||
"appointment_time": "09:50",
|
||||
"status": 1,
|
||||
"status_desc": "已挂号",
|
||||
}
|
||||
],
|
||||
"count": 1,
|
||||
},
|
||||
page._generation,
|
||||
False,
|
||||
)
|
||||
application.processEvents()
|
||||
|
||||
assert page.video_list.count() == 1
|
||||
assert "赵俊霞" in page.video_list.item(0).text()
|
||||
assert page.video_list.parentWidget().width() == 420
|
||||
assert page.table.objectName() == "AppointmentTable"
|
||||
assert page.date_buttons["today"].isChecked()
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
Reference in New Issue
Block a user