From b55caf28e41a5d4b10224e9d24dfd87aa9b32b62 Mon Sep 17 00:00:00 2001 From: Simon Brunning Date: Fri, 12 Jul 2024 14:52:04 +0100 Subject: [PATCH] Add chat renaming to journey test. --- django_app/frontend/src/js/chats/streaming.js | 2 +- tests/pages.py | 15 +++++++++++++++ tests/test_journey.py | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/django_app/frontend/src/js/chats/streaming.js b/django_app/frontend/src/js/chats/streaming.js index 2ed727543..872c01a69 100644 --- a/django_app/frontend/src/js/chats/streaming.js +++ b/django_app/frontend/src/js/chats/streaming.js @@ -319,7 +319,7 @@ class ChatTitle extends HTMLElement { switchToEdit = () => { this.innerHTML = `
- +
`; this.escaped = false; diff --git a/tests/pages.py b/tests/pages.py index 7726d211c..28f4bc4b4 100644 --- a/tests/pages.py +++ b/tests/pages.py @@ -356,6 +356,17 @@ def feedback_chips(self, chips: Collection[str]): feedback_chips = property(fset=feedback_chips) + @property + def chat_title(self) -> str: + return self.page.locator(".chat_title__container").inner_text() + + @chat_title.setter + def chat_title(self, title: str): + self.page.locator(".chat_title__container").click() + input_ = self.page.get_by_label("Chat Title") + input_.fill(title) + input_.press("Enter") + def start_new_chat(self) -> "ChatsPage": self.page.get_by_role("button", name="New chat").click() return ChatsPage(self.page) @@ -393,6 +404,10 @@ def get_all_messages_once_streaming_has_completed( def wait_for_latest_message(self, role="Redbox") -> ChatMessage: return [m for m in self.get_all_messages_once_streaming_has_completed() if m.role == role][-1] + def navigate_to_titled_chat(self, title: str) -> "ChatsPage": + self.page.get_by_role("link", name=title).click() + return self + class CitationsPage(SignedInBasePage): def check_a11y(self): diff --git a/tests/test_journey.py b/tests/test_journey.py index 5b0e994d6..b9241e6ab 100644 --- a/tests/test_journey.py +++ b/tests/test_journey.py @@ -92,6 +92,7 @@ def test_user_journey(page: Page, email_address: str): assert files_to_select.pop() in latest_chat_response.sources # Use specific routes + chats_page = chats_page.start_new_chat() for route, select_file in [ ("search", False), ("search", True), @@ -101,7 +102,6 @@ def test_user_journey(page: Page, email_address: str): ("summarise", False), ("info", False), ]: - chats_page = chats_page.start_new_chat() question = f"@{route} What do I need to install?" logger.info("Asking %r", question) chats_page.write_message = question @@ -113,6 +113,13 @@ def test_user_journey(page: Page, email_address: str): latest_chat_response = chats_page.wait_for_latest_message() assert latest_chat_response.text assert latest_chat_response.route.startswith(route) + + # Navigate to old chat & rename + chats_page = chats_page.navigate_to_titled_chat("What architecture is in use?") + chats_page.chat_title = "About tech stuff." + chats_page = chats_page.start_new_chat() + chats_page = chats_page.navigate_to_titled_chat("About tech stuff.") + # Delete a file documents_page = chats_page.navigate_to_documents() pre_delete_doc_count = documents_page.document_count()