tests: update existing test to open send modal from chat message

This commit is contained in:
Anastasiya Semenkevich 2024-09-27 18:08:42 +03:00 committed by Anastasiya
parent 1cad66bb2c
commit 54afe78b94
3 changed files with 38 additions and 11 deletions

View File

@ -72,6 +72,8 @@ groupUserListPanel_StatusMemberListItem = {"container": mainWindow_userListPanel
# Message quick actions
mainWindow_chatLogView_StatusListView = {"container": statusDesktop_mainWindow, "objectName": "chatLogView", "type": "StatusListView", "visible": True}
chatLogView_chatMessageViewDelegate_MessageView = {"container": mainWindow_chatLogView_StatusListView, "objectName": "chatMessageViewDelegate", "type": "MessageView", "visible": True}
StatusTextMessage_chatTextMessage = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "StatusTextMessage_chatText", "type": "TextEdit", "visible": True}
chatMessageViewDelegate_deletedMessage_RowLayout = {"container": chatLogView_chatMessageViewDelegate_MessageView, "id": "deletedMessage", "type": "RowLayout", "unnamed": 1, "visible": True}
chatMessageViewDelegate_StatusMessageQuickActions = {"container": chatLogView_chatMessageViewDelegate_MessageView, "type": "StatusMessageQuickActions", "unnamed": 1, "visible": True}
chatMessageViewDelegate_pin_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "pin-icon", "type": "StatusIcon", "visible": True}

View File

@ -1,4 +1,5 @@
import pathlib
import re
import time
import typing
from typing import List
@ -18,6 +19,7 @@ from gui.components.messaging.edit_group_name_and_image_popup import EditGroupNa
from gui.components.messaging.leave_group_popup import LeaveGroupPopup
from gui.components.messaging.link_preview_options_popup import LinkPreviewOptionsPopup
from gui.components.messaging.message_context_menu_popup import MessageContextMenuPopup
from gui.components.wallet.send_popup import SendPopup
from gui.elements.button import Button
from gui.elements.list import List
from gui.elements.object import QObject
@ -27,6 +29,7 @@ from gui.elements.text_label import TextLabel
from gui.objects_map import messaging_names, communities_names
from gui.screens.community import CommunityScreen
from scripts.tools.image import Image
from scripts.utils.parsers import remove_tags
class LeftPanel(QObject):
@ -230,6 +233,7 @@ class ChatView(QObject):
def __init__(self):
super().__init__(messaging_names.mainWindow_ChatColumnView)
self._message_list_item = QObject(messaging_names.chatLogView_chatMessageViewDelegate_MessageView)
self._message_text_item = QObject(messaging_names.StatusTextMessage_chatTextMessage)
self._deleted_message = QObject(messaging_names.chatMessageViewDelegate_deletedMessage_RowLayout)
self._recent_messages_button = QObject(messaging_names.layout_recentMessagesButton_AnchorButton)
@ -243,10 +247,21 @@ class ChatView(QObject):
if self._recent_messages_button.is_visible:
self._recent_messages_button.click()
for item in driver.findAllObjects(self._message_list_item.real_name):
if getattr(item, 'isMessage', False):
if getattr(item, 'isMessage', True):
_messages.append(Message(item))
return _messages
def open_send_modal_from_link(self, text):
text_messages = driver.findAllObjects(self._message_text_item.real_name)
for item in text_messages:
if remove_tags(str(getattr(item, 'text', ''))) == text:
pattern = r'(//send-via-personal-chat//0x[a-fA-F0-9]{40})'
raw_link = str(getattr(item, 'text', ''))
match = re.search(pattern, raw_link)
link = match.group(1)
item.linkActivated(link)
return SendPopup().wait_until_appears()
@allure.step('Get deleted message state')
def get_deleted_message_state(self):
return self._deleted_message.exists
@ -256,7 +271,7 @@ class ChatView(QObject):
started_at = time.monotonic()
while message is None:
for _message in self.messages(index):
if message_text in _message.text:
if message_text in remove_tags(_message.text):
message = _message
break
if time.monotonic() - started_at > configs.timeouts.MESSAGING_TIMEOUT_SEC:
@ -294,7 +309,8 @@ class CreateChatView(QObject):
@allure.step('Select contact in the list')
def select_contact(self, contact: str):
assert driver.waitFor(lambda: contact in self.contact_names), f'Contact: {contact} was not found in {self.contact_names}'
assert driver.waitFor(
lambda: contact in self.contact_names), f'Contact: {contact} was not found in {self.contact_names}'
self._create_chat_contacts_list.select(contact, 'userName')
@allure.step('Create chat by adding contacts from contact list')

View File

@ -9,11 +9,13 @@ from allure_commons._allure import step
import driver
from constants.images_paths import HEART_EMOJI_PATH, ANGRY_EMOJI_PATH, THUMBSUP_EMOJI_PATH, THUMBSDOWN_EMOJI_PATH, \
LAUGHING_EMOJI_PATH, SAD_EMOJI_PATH
from constants.wallet import WalletAddress
from gui.screens.messages import MessagesScreen, ToolBar
import configs.testpath
from constants import RandomUser, UserAccount
from gui.main_window import MainWindow
from scripts.utils.parsers import remove_tags
from tests.messages import marks
@ -66,23 +68,30 @@ def test_1x1_chat(multiple_instances):
'Contact requests').accept_contact_request(request)
main_window.hide()
with step(f'User {user_one.name} send another message to {user_two.name}, edit it and verify it was changed'):
with step(f'User {user_one.name} send a message to {user_two.name}'):
aut_one.attach()
main_window.prepare()
left_panel_chat = main_window.left_panel.open_messages_screen().left_panel
assert driver.waitFor(lambda: user_two.name in left_panel_chat.get_chats_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
chat = left_panel_chat.click_chat_by_name(user_two.name)
chat_message1 = \
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
chat_message1 = WalletAddress.RECEIVER_ADDRESS.value
messages_screen.group_chat.send_message_to_group_chat(chat_message1)
message = chat.find_message_by_text(chat_message1, 0)
additional_text = '?'
additional_text = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
time.sleep(5)
with step(f'User {user_one.name}, click address / ens link in message and verify send modal appears'):
send_modal = chat.open_send_modal_from_link(chat_message1)
assert remove_tags(send_modal._ens_address_text_edit.text) == chat_message1
left_panel_chat.click()
with step(f'User {user_one.name}, edit message and verify it was changed'):
message_actions = message.hover_message()
message_actions.edit_message(additional_text)
message_object = messages_screen.chat.messages(0)[0]
assert chat_message1 + additional_text in message_object.text, \
assert chat_message1 + additional_text in str(message_object.object.unparsedText), \
f"Message text is not found in last message"
assert message_object.delegate_button.object.isEdited, \
f"Message status was not changed to edited"
@ -101,7 +110,7 @@ def test_1x1_chat(multiple_instances):
assert chat_message2 in message_object_0.text, \
f"Message text is not found in the last message"
message_object_1 = messages_screen.chat.messages(1)[0]
assert chat_message1 in message_object_1.text,\
assert chat_message1 in str(message_object_1.object.unparsedText),\
f"Message text is not found in the last message"
with step(f'User {user_two.name} send emoji to {user_one.name}'):
@ -121,12 +130,12 @@ def test_1x1_chat(multiple_instances):
main_window.prepare()
time.sleep(4)
message_object = messages_screen.chat.messages(2)[0]
assert driver.waitFor(lambda: chat_message2 in message_object.text),\
assert driver.waitFor(lambda: chat_message2 in str(message_object.object.unparsedText)),\
f"Message text is not found in the last message"
with step(f'User {user_one.name}, received emoji from {user_two.name}'):
message_object = messages_screen.chat.messages(1)[0]
assert driver.waitFor(lambda: '😎' in message_object.text, timeout),\
assert driver.waitFor(lambda: '😎' in str(message_object.object.unparsedText) , timeout),\
f"Message text is not found in the last message"
with step(f'User {user_one.name}, received image from {user_two.name}'):