Skip to content

Commit

Permalink
Add chat renaming to journey test.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunns committed Jul 12, 2024
1 parent d15a4d5 commit b55caf2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django_app/frontend/src/js/chats/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class ChatTitle extends HTMLElement {

switchToEdit = () => {
this.innerHTML = `<div class="chat_title__container">
<label for="chat_title" class="govuk-visually-hidden">Title</label>
<label for="chat_title" class="govuk-visually-hidden">Chat Title</label>
<input type="text" class="chat_title__input" id="chat_title" maxlength=${this.dataset.titleLength} value="${this.dataset.title}"/>
</div>`;
this.escaped = false;
Expand Down
15 changes: 15 additions & 0 deletions tests/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 8 additions & 1 deletion tests/test_journey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit b55caf2

Please sign in to comment.