更新
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user