This commit is contained in:
Your Name
2026-08-22 08:51:35 +08:00
parent 6c444a4a04
commit c06d293424
69 changed files with 11431 additions and 1601 deletions
+60 -17
View File
@@ -109,8 +109,9 @@ def test_appointments_navigation_is_named_reception_and_always_first() -> None:
demo_mode=False,
)
# 挂号与诊单是两条队列,侧边栏此前两项同名。现在与服务端菜单的“挂号列表”一致。
assert [(item.key, title) for item, title in resolved] == [
("appointments", "问诊列表"),
("appointments", "挂号列表"),
("patients", "我的患者"),
]
@@ -123,7 +124,7 @@ def shell_window(
navigation = [
NavigationItem(key, title, glyph, _ShellPageDouble, (permission,))
for key, title, glyph, permission in (
("appointments", "问诊列表", "", "doctor.appointment/lists"),
("appointments", "挂号列表", "", "doctor.appointment/lists"),
("reception", "接诊台", "", "doctor.appointment/lists"),
(
"prescription_library",
@@ -262,52 +263,93 @@ def test_reference_shell_has_integrated_search_ai_card_and_window_controls(
assert "在线" in shell_window.assistant_status.text()
def test_shell_ai_entry_opens_the_current_selected_diagnosis(
def test_shell_ai_entry_always_opens_patient_picker_even_with_current_selection(
application: QApplication,
shell_window: ShellWindow,
monkeypatch: pytest.MonkeyPatch,
) -> None:
current = shell_window.pages["appointments"]
assert isinstance(current, _ShellPageDouble)
current.ai_context_available = True
opened: list[tuple[tuple[Any, ...], dict[str, Any]]] = []
monkeypatch.setattr(
shell_module,
"select_and_present_ai_consult",
lambda *args, **kwargs: opened.append((args, kwargs)) or False,
)
shell_window.assistant_button.click()
application.processEvents()
assert current.ai_open_count == 1
assert current.ai_open_count == 0
assert len(opened) == 1
assert opened[0][0][0] is shell_window.repository
assert opened[0][0][2] is shell_window
assert shell_window.stack.currentWidget() is current
def test_shell_ai_entry_falls_back_to_reception_and_opens_its_selection(
def test_shell_ai_entry_without_selection_opens_patient_diagnosis_picker(
application: QApplication,
shell_window: ShellWindow,
monkeypatch: pytest.MonkeyPatch,
) -> None:
appointments = shell_window.pages["appointments"]
reception = shell_window.pages["reception"]
assert isinstance(appointments, _ShellPageDouble)
assert isinstance(reception, _ShellPageDouble)
reception.ai_context_available = True
opened: list[dict[str, Any]] = []
def open_picker(repository: Any, permissions: Any, parent: Any, **kwargs: Any) -> bool:
opened.append(
{
"repository": repository,
"permissions": permissions,
"parent": parent,
**kwargs,
}
)
return False
monkeypatch.setattr(shell_module, "select_and_present_ai_consult", open_picker)
shell_window.global_search.setText("张医生")
shell_window.ai_top_button.click()
application.processEvents()
assert appointments.ai_open_count == 1
assert reception.ai_open_count == 1
assert shell_window.stack.currentWidget() is reception
assert appointments.ai_open_count == 0
assert reception.ai_open_count == 0
assert shell_window.stack.currentWidget() is appointments
assert opened == [
{
"repository": shell_window.repository,
"permissions": shell_window.permissions,
"parent": shell_window,
"initial_query": "张医生",
}
]
def test_shell_ai_entry_on_reception_opens_chat_instead_of_noop(
def test_shell_ai_entry_on_reception_still_opens_global_patient_picker(
application: QApplication,
shell_window: ShellWindow,
monkeypatch: pytest.MonkeyPatch,
) -> None:
reception = shell_window.pages["reception"]
assert isinstance(reception, _ShellPageDouble)
assert shell_window.navigate("reception")
reception.ai_context_available = True
opened: list[tuple[tuple[Any, ...], dict[str, Any]]] = []
monkeypatch.setattr(
shell_module,
"select_and_present_ai_consult",
lambda *args, **kwargs: opened.append((args, kwargs)) or False,
)
shell_window.ai_top_button.click()
application.processEvents()
assert reception.ai_open_count == 1
assert reception.ai_open_count == 0
assert len(opened) == 1
assert shell_window.stack.currentWidget() is reception
@@ -346,7 +388,7 @@ def test_shell_hides_global_ai_entries_without_ai_permission(
application.processEvents()
def test_shell_ai_entry_reports_when_reception_is_not_available(
def test_shell_ai_entry_does_not_require_reception_page(
application: QApplication,
monkeypatch: pytest.MonkeyPatch,
) -> None:
@@ -366,11 +408,11 @@ def test_shell_ai_entry_reports_when_reception_is_not_available(
(item, item.title) for item in navigation
],
)
messages: list[str] = []
opened: list[Any] = []
monkeypatch.setattr(
shell_module,
"show_toast",
lambda _parent, message, *_args, **_kwargs: messages.append(message),
"select_and_present_ai_consult",
lambda *args, **kwargs: opened.append((args, kwargs)) or False,
)
window = ShellWindow(
object(),
@@ -386,8 +428,9 @@ def test_shell_ai_entry_reports_when_reception_is_not_available(
window.assistant_button.click()
application.processEvents()
assert any("没有可用的接诊台" in message for message in messages)
assert all("已进入接诊台" not in message for message in messages)
assert len(opened) == 1
assert opened[0][0][0] is window.repository
assert opened[0][0][2] is window
assert window.stack.currentWidget() is window.pages["appointments"]
window.close()