This commit is contained in:
Your Name
2026-08-20 17:56:08 +08:00
parent 5794f60c5d
commit cc6173e5b0
393 changed files with 1320 additions and 1041 deletions
+30
View File
@@ -710,6 +710,36 @@ def test_ownerless_notes_prescriptions_and_tracking_rows_fail_closed_as_warning(
dialog.close()
def test_ownerless_im_messages_fail_closed_before_chat_rendering(
application: QApplication,
immediate_async: None,
) -> None:
class OwnerlessMessageRepository(WorkspaceRepository):
def list_im_chat_messages(
self,
diagnosis_id: int,
*,
only_archived: bool = True,
) -> list[dict[str, Any]]:
del diagnosis_id, only_archived
return [
{
"msg_id": "ownerless-message",
"msg_type": "text",
"text": "不应展示的无归属会话",
"is_from_doctor": False,
}
]
dialog = _open_dialog(application, OwnerlessMessageRepository())
chat_text = "\n".join(
label.text() for label in dialog.chat_host.findChildren(QLabel)
)
assert "不应展示的无归属会话" not in chat_text
dialog.close()
def test_tracking_response_without_diagnosis_owner_is_filtered_without_retry(
application: QApplication,
immediate_async: None,
+92 -1
View File
@@ -33,10 +33,16 @@ class _ShellPageDouble(QWidget):
self.current_user = current_user
self.refresh_count = 0
self.show_count = 0
self.ai_context_available = False
self.ai_open_count = 0
def refresh(self) -> None:
self.refresh_count += 1
def open_selected_ai_consult(self) -> bool:
self.ai_open_count += 1
return self.ai_context_available
def showEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
super().showEvent(event)
self.show_count += 1
@@ -143,7 +149,8 @@ def shell_window(
"user": {"name": "陈医生", "department_name": "中医门诊", "role_ids": [1]},
"demo_mode": True,
},
permissions={item.permissions[0] for item in navigation},
permissions={item.permissions[0] for item in navigation}
| {"tcm.diagnosis/aiAssistant"},
)
window.show()
application.processEvents()
@@ -255,6 +262,90 @@ 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(
application: QApplication,
shell_window: ShellWindow,
) -> None:
current = shell_window.pages["appointments"]
assert isinstance(current, _ShellPageDouble)
current.ai_context_available = True
shell_window.assistant_button.click()
application.processEvents()
assert current.ai_open_count == 1
assert shell_window.stack.currentWidget() is current
def test_shell_ai_entry_falls_back_to_reception_and_opens_its_selection(
application: QApplication,
shell_window: ShellWindow,
) -> None:
appointments = shell_window.pages["appointments"]
reception = shell_window.pages["reception"]
assert isinstance(appointments, _ShellPageDouble)
assert isinstance(reception, _ShellPageDouble)
reception.ai_context_available = True
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
def test_shell_ai_entry_on_reception_opens_chat_instead_of_noop(
application: QApplication,
shell_window: ShellWindow,
) -> None:
reception = shell_window.pages["reception"]
assert isinstance(reception, _ShellPageDouble)
assert shell_window.navigate("reception")
reception.ai_context_available = True
shell_window.ai_top_button.click()
application.processEvents()
assert reception.ai_open_count == 1
assert shell_window.stack.currentWidget() is reception
def test_shell_hides_global_ai_entries_without_ai_permission(
application: QApplication,
monkeypatch: pytest.MonkeyPatch,
) -> None:
navigation = [
NavigationItem(
"appointments",
"问诊列表",
"",
_ShellPageDouble,
("doctor.appointment/lists",),
)
]
monkeypatch.setattr(
shell_module,
"_resolve_navigation",
lambda _menu, _permissions, *, demo_mode: [
(item, item.title) for item in navigation
],
)
window = ShellWindow(
object(),
{"user": {"name": "无 AI 权限医生"}, "demo_mode": True},
permissions={"doctor.appointment/lists"},
)
window.show()
application.processEvents()
assert window.assistant_card.isHidden()
assert window.ai_top_button.isHidden()
window.close()
application.processEvents()
def test_shell_settings_opens_global_local_audio_upload_manager(
application: QApplication,
shell_window: ShellWindow,