This commit is contained in:
Your Name
2026-08-31 15:17:34 +08:00
parent ed48f8be31
commit 456dd667df
439 changed files with 5720 additions and 422 deletions
+96
View File
@@ -1436,6 +1436,102 @@ def test_im_consult_is_visible_immediately_after_history(
application.processEvents()
@pytest.mark.parametrize("width", [1280, 1494])
@pytest.mark.parametrize("permissions", [[], ["*"]])
def test_notify_assistant_is_a_visible_header_action_not_a_more_menu_item(
application: QApplication,
queued_async: list[dict[str, Any]],
width: int,
permissions: list[str],
) -> None:
page = ReceptionPage(DemoDoctorRepository(), PermissionSet(permissions))
page.resize(width, 760)
page.show()
try:
application.processEvents()
# The first show initiates a queue reload and clears the selection.
# Present a synthetic selected patient after that initial reset.
page.patient_name_label.setText("测试患者")
page.patient_meta_label.setText("女 · 42岁 · 138****8000 | 就诊号:31")
page.detail_stack.setCurrentIndex(1)
for _ in range(4):
application.processEvents()
hero = page.notify_button.parentWidget()
assert hero.objectName() == "ReceptionHero"
assert page.notify_button.isVisibleTo(page)
assert page.notify_button.text() == "通知医助"
assert page.notify_button.width() >= page.notify_button.sizeHint().width()
assert page.notify_button.height() > 0
assert "通知医助" not in [action.text() for action in page.more_button.menu().actions()]
buttons = [
button
for button in (
page.complete_button,
page.notify_button,
page.history_button,
page.video_button,
page.more_button,
)
if button.isVisibleTo(page)
]
for button in buttons:
assert hero.rect().contains(button.geometry())
assert button.width() >= button.sizeHint().width()
right = button.mapTo(page.detail_scroll.viewport(), QPoint(button.width(), 0)).x()
assert right <= page.detail_scroll.viewport().width()
for previous, following in zip(buttons, buttons[1:], strict=False):
assert previous.geometry().right() < following.geometry().left()
finally:
page.close()
application.processEvents()
def test_notify_header_button_keeps_appointment_context_and_pending_state(
application: QApplication,
queued_async: list[dict[str, Any]],
) -> None:
sent: list[int] = []
class Repository:
def notify_assistant(self, appointment_id: int) -> dict[str, bool]:
sent.append(appointment_id)
return {"success": True}
page = ReceptionPage(Repository(), PermissionSet([]))
try:
page._update_action_state({}, {})
assert not page.notify_button.isEnabled()
page._selected_appointment_id = 31
page._selected_record = {"id": 31, "status": 1}
page._update_action_state(page._selected_record, {})
assert page.notify_button.isEnabled()
queued_async.clear()
page.notify_button.click()
assert not page.notify_button.isEnabled()
page.notify_button.click()
assert len(queued_async) == 1
notification = queued_async.pop()
notification["function"]()
assert sent == [31]
notification["on_finished"]()
assert page.notify_button.isEnabled()
page.notify_button.click()
notification = queued_async.pop()
page._selected_appointment_id = 32
page._selected_record = {"id": 32, "status": 1}
page._detail_generation += 1
# An old request still targets its original appointment and cannot
# re-enable a pending notification for a newly selected patient.
notification["function"]()
notification["on_finished"]()
assert sent == [31, 31]
assert not page.notify_button.isEnabled()
finally:
page.close()
application.processEvents()
def test_reception_ai_report_button_follows_permission(
application: QApplication,
immediate_async: None,