更新
This commit is contained in:
@@ -8,7 +8,7 @@ from typing import Any
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import pytest
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtCore import QPoint, Qt
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
@@ -125,6 +125,56 @@ def test_ai_consult_dialog_matches_workspace_chrome(
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_header_and_chat_filter_move_to_right_pane_and_filter_message_roles(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
dialog = AiConsultDialog(
|
||||
DemoDoctorRepository(), PermissionSet(["tcm.diagnosis/aiAssistant"])
|
||||
)
|
||||
patient = dialog._append_bubble("patient", "患者提问")
|
||||
doctor = dialog._append_bubble("doctor", "医生回复")
|
||||
ai = dialog._append_bubble("ai", "智能分析")
|
||||
system = dialog._append_event(title="视频开始")
|
||||
dialog.show()
|
||||
application.processEvents()
|
||||
|
||||
right_pane = dialog.findChild(QWidget, "AiConsultRightPane")
|
||||
chat_pane = dialog.findChild(QWidget, "AiConsultChatPane")
|
||||
assert right_pane is not None and chat_pane is not None
|
||||
assert right_pane.mapTo(dialog, QPoint(0, 0)).x() >= chat_pane.mapTo(
|
||||
dialog, QPoint(chat_pane.width(), 0)
|
||||
).x()
|
||||
assert dialog.tabs.parentWidget() is right_pane
|
||||
assert dialog.chat_filter_button.parentWidget() is right_pane
|
||||
assert right_pane.findChild(QWidget, "AiConsultHero") is not None
|
||||
assert all(item.isVisible() for item in (patient, doctor, ai, system))
|
||||
|
||||
actions = {action.data(): action for action in dialog.chat_filter_menu.actions()}
|
||||
actions["doctor"].trigger()
|
||||
application.processEvents()
|
||||
assert doctor.isVisible()
|
||||
assert not patient.isVisible()
|
||||
assert not ai.isVisible()
|
||||
assert not system.isVisible()
|
||||
|
||||
new_doctor = dialog._append_bubble("doctor", "新的医生回复")
|
||||
new_patient = dialog._append_bubble("patient", "新的患者提问")
|
||||
application.processEvents()
|
||||
assert new_doctor.isVisible()
|
||||
assert not new_patient.isVisible()
|
||||
|
||||
actions["all"].trigger()
|
||||
application.processEvents()
|
||||
assert all(item.isVisible() for item in (patient, doctor, ai, system, new_doctor, new_patient))
|
||||
dialog.tabs.setCurrentIndex(1)
|
||||
application.processEvents()
|
||||
assert not dialog.chat_filter_button.isVisible()
|
||||
dialog.tabs.setCurrentIndex(0)
|
||||
application.processEvents()
|
||||
assert dialog.chat_filter_button.isVisible()
|
||||
dialog.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", [Qt.Key.Key_Return, Qt.Key.Key_Enter])
|
||||
def test_input_enter_submits_once_without_closing_dialog(
|
||||
application: QApplication,
|
||||
@@ -663,6 +713,29 @@ def test_ai_consult_sidebar_loads_patient_facts_and_reports(
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_missing_server_analysis_is_not_presented_as_ai_diagnosis(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
dialog = AiConsultDialog(
|
||||
DemoDoctorRepository(), PermissionSet(["tcm.diagnosis/aiAssistant"])
|
||||
)
|
||||
dialog._seed = {
|
||||
"clinical_diagnosis": "糖尿病",
|
||||
"fasting_blood_sugar": 11.2,
|
||||
}
|
||||
dialog._render_analysis({})
|
||||
dialog.show()
|
||||
application.processEvents()
|
||||
|
||||
titles = [
|
||||
widget.text()
|
||||
for widget in dialog.findChildren(QLabel, "AiConsultRecordTitle")
|
||||
]
|
||||
assert titles == ["分析状态"]
|
||||
assert not dialog.findChildren(QTextBrowser, "AiConsultBubbleText")
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_ai_consult_sidebar_survives_chat_archive_errors(
|
||||
application: QApplication,
|
||||
immediate_async: None,
|
||||
|
||||
Reference in New Issue
Block a user