diff --git a/test/e2e/constants/images_paths.py b/test/e2e/constants/images_paths.py index 47f62f3d20..03fa22f9b1 100644 --- a/test/e2e/constants/images_paths.py +++ b/test/e2e/constants/images_paths.py @@ -10,3 +10,4 @@ CHOOSE_KEYCARD_PIN_IMAGE_PATH = '/imports/assets/png/keycard/enter-pin-0.png' KEYCARD_SUCCESS_IMAGE_PATH = '/imports/assets/png/keycard/strong_success/img-20.png' KEYCARD_RECOGNIZED_IMAGE_PATH = '/imports/assets/png/keycard/success/img-13.png' KEYCARD_ERROR_IMAGE_PATH = '/imports/assets/png/keycard/plain-error.png' +HEART_EMOJI_PATH = '/imports/assets/icons/emojiReactions/heart.svg' diff --git a/test/e2e/gui/components/messaging/message_context_menu_popup.py b/test/e2e/gui/components/messaging/message_context_menu_popup.py new file mode 100644 index 0000000000..7afd23bb02 --- /dev/null +++ b/test/e2e/gui/components/messaging/message_context_menu_popup.py @@ -0,0 +1,24 @@ +import allure + +import configs +from gui.components.base_popup import BasePopup +from gui.elements.object import QObject +from gui.objects_map import messaging_names + + +class MessageContextMenuPopup(BasePopup): + + def __init__(self): + super().__init__() + self._emoji_reaction = QObject(messaging_names.o_EmojiReaction) + + @allure.step('Wait until appears {0}') + def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + self._emoji_reaction.wait_until_appears(timeout_msec) + return self + + @allure.step('Add reaction to message') + def add_reaction_to_message(self, occurrence: int): + if occurrence > 1: + self._emoji_reaction.real_name['occurrence'] = occurrence + self._emoji_reaction.click() diff --git a/test/e2e/gui/objects_map/messaging_names.py b/test/e2e/gui/objects_map/messaging_names.py index d5080e27ea..9ef40bcbf9 100644 --- a/test/e2e/gui/objects_map/messaging_names.py +++ b/test/e2e/gui/objects_map/messaging_names.py @@ -53,9 +53,13 @@ add_remove_from_group_StatusMenuItem = {"checkable": False, "container": mainWin mainWindow_inputScrollView_StatusScrollView = {"container": statusDesktop_mainWindow, "id": "inputScrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True} inputScrollView_messageInputField_TextArea = {"container": mainWindow_inputScrollView_StatusScrollView, "objectName": "messageInputField", "type": "TextArea", "visible": True} mainWindow_statusChatInputEmojiButton_StatusFlatRoundButton = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputEmojiButton", "type": "StatusFlatRoundButton", "visible": True} +mainWindow_imageBtn_StatusFlatRoundButton = {"container": statusDesktop_mainWindow, "id": "imageBtn", "type": "StatusFlatRoundButton", "unnamed": 1, "visible": True} +mainWindow_statusChatInput_StatusChatInput = {"container": statusDesktop_mainWindow, "objectName": "statusChatInput", "type": "Rectangle", "visible": True} mark_as_Read_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItem", "visible": True} clear_History_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "clearHistoryMenuItem", "type": "StatusMenuItem", "visible": True} close_Chat_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItem", "visible": True} +o_EmojiReaction = {"container": mainWindow_Overlay, "type": "EmojiReaction", "unnamed": 1, "visible": True} +chatMessageViewDelegate_StatusEmoji = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "emojiReaction", "type": "StatusEmoji", "unnamed": 1, "visible": True} # User List Panel mainWindow_UserListPanel = {"container": mainWindow_chatView_ChatView, "type": "UserListPanel", "unnamed": 1, "visible": True} diff --git a/test/e2e/gui/screens/messages.py b/test/e2e/gui/screens/messages.py index 742268372c..f520652ddb 100644 --- a/test/e2e/gui/screens/messages.py +++ b/test/e2e/gui/screens/messages.py @@ -7,7 +7,6 @@ import allure import configs import driver from driver.objects_access import walk_children -from driver.toplevel_window import set_focus from gui.components.activity_center import ActivityCenter from gui.components.context_menu import ContextMenu from gui.components.delete_popup import DeleteMessagePopup @@ -17,6 +16,7 @@ from gui.components.messaging.close_chat_popup import CloseChatPopup from gui.components.messaging.edit_group_name_and_image_popup import EditGroupNameAndImagePopup 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.elements.button import Button from gui.elements.list import List from gui.elements.object import QObject @@ -130,6 +130,7 @@ class Message: self.link_preview: typing.Optional[QObject] = None self.link_preview_title_object: typing.Optional[QObject] = None self.link_preview_emoji_hash: typing.Optional[str] = None + self.image_message: typing.Optional[QObject] = None self.community_invitation: dict = {} self.init_ui() @@ -161,6 +162,8 @@ class Message: self.delegate_button = Button(real_name=driver.objectMap.realName(child)) case 'linksMessageView': self.link_preview = QObject(real_name=driver.objectMap.realName(child)) + case 'imageMessage': + self.image_message = child @allure.step('Open community invitation') def open_community_invitation(self): @@ -198,6 +201,21 @@ class Message: if getattr(child, 'objectName', '') == 'linkPreviewTitle': return str(child.text) + @allure.step('Open context menu for message') + def open_context_menu_for_message(self): + QObject(real_name=driver.objectMap.realName(self.object)).right_click() + return MessageContextMenuPopup().wait_until_appears() + + @allure.step('Get emoji reactions pathes') + def get_emoji_reactions_pathes(self): + reactions_pathes = [] + for child in walk_children(self.object): + if getattr(child, 'id', '') == 'reactionDelegate': + for item in walk_children(child): + if getattr(item, 'objectName', '') == 'emojiReaction': + reactions_pathes.append(item.source.path) + return reactions_pathes + class ChatView(QObject): @@ -288,9 +306,11 @@ class ChatMessagesView(QObject): self._add_remove_item = QObject(messaging_names.add_remove_from_group_StatusMenuItem) self._clear_history_item = QObject(messaging_names.clear_History_StatusMenuItem) self._close_chat_item = QObject(messaging_names.close_Chat_StatusMenuItem) + self._chat_input = QObject(messaging_names.mainWindow_statusChatInput_StatusChatInput) self._message_input_area = QObject(messaging_names.inputScrollView_messageInputField_TextArea) self._message_field = TextEdit(messaging_names.inputScrollView_Message_PlaceholderText) self._emoji_button = Button(messaging_names.mainWindow_statusChatInputEmojiButton_StatusFlatRoundButton) + self._image_button = Button(messaging_names.mainWindow_imageBtn_StatusFlatRoundButton) self._link_preview_title = QObject(messaging_names.mainWindow_linkPreviewTitleText_StatusBaseText) self._link_preview_preview_subtitle = QObject(messaging_names.mainWindow_linkPreviewSubtitleText_StatusBaseText) self._link_preview_show_preview = QObject(messaging_names.mainWindow_titleText_StatusBaseText) @@ -398,6 +418,12 @@ class ChatMessagesView(QObject): for i in range(2): driver.nativeType('') + @allure.step('Send image to chat') + def send_image_to_chat(self, path): + self._chat_input.object.selectImageString('file://' + str(path)) + for i in range(2): + driver.nativeType('') + @allure.step('Remove member from chat') def remove_member_from_chat(self, member): time.sleep(2) diff --git a/test/e2e/tests/messages/test_messaging_1x1_chat.py b/test/e2e/tests/messages/test_messaging_1x1_chat.py index 91ff3f8ccc..ca41a10134 100644 --- a/test/e2e/tests/messages/test_messaging_1x1_chat.py +++ b/test/e2e/tests/messages/test_messaging_1x1_chat.py @@ -7,6 +7,7 @@ import pytest from allure_commons._allure import step import driver +from constants.images_paths import HEART_EMOJI_PATH from gui.screens.messages import MessagesScreen, ToolBar, ChatMessagesView from tests.settings.settings_messaging import marks @@ -26,6 +27,7 @@ def test_1x1_chat(multiple_instances): main_window = MainWindow() messages_screen = MessagesScreen() emoji = 'sunglasses' + timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC with multiple_instances(user_data=None) as aut_one, multiple_instances(user_data=None) as aut_two: with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'): @@ -56,7 +58,7 @@ def test_1x1_chat(multiple_instances): aut_two.attach() main_window.prepare() activity_center = ToolBar().open_activity_center() - request = activity_center.find_contact_request_in_list(user_one.name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + request = activity_center.find_contact_request_in_list(user_one.name, timeout) activity_center.click_activity_center_button( 'Contact requests').accept_contact_request(request) main_window.hide() @@ -103,22 +105,32 @@ def test_1x1_chat(multiple_instances): message_items = [message.text for message in message_objects] for message_item in message_items: assert '😎' in message_item + + with step(f'User {user_two.name} send image to {user_one.name} and verify it was sent'): + path = configs.testpath.TEST_IMAGES / 'comm_logo.jpeg' + messages_screen.group_chat.send_image_to_chat(str(path)) + message_object = messages_screen.chat.messages(0)[0] + assert message_object.image_message.visible main_window.hide() with step(f'User {user_one.name}, received reply from {user_two.name}'): aut_one.attach() main_window.prepare() + time.sleep(4) + message_objects = messages_screen.chat.messages(2) + message_items = [message.text for message in message_objects] + for message_item in message_items: + assert driver.waitFor(lambda: chat_message2 in message_item, timeout) + + with step(f'User {user_one.name}, received emoji from {user_two.name}'): message_objects = messages_screen.chat.messages(1) message_items = [message.text for message in message_objects] for message_item in message_items: - assert driver.waitFor(lambda: chat_message2 in message_item, configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + assert driver.waitFor(lambda: '😎' in message_item, timeout) - with step(f'User {user_one.name}, received emoji from {user_two.name}'): - time.sleep(2) - message_objects = messages_screen.chat.messages(0) - message_items = [message.text for message in message_objects] - for message_item in message_items: - assert driver.waitFor(lambda: '😎' in message_item, configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + with step(f'User {user_one.name}, received image from {user_two.name}'): + message_object = messages_screen.chat.messages(0)[0] + assert message_object.image_message.visible with step(f'User {user_one.name}, reply to own message and verify that message displayed as a reply'): chat_message_reply = \ @@ -128,6 +140,10 @@ def test_1x1_chat(multiple_instances): message = chat.find_message_by_text(chat_message_reply, 0) assert message.reply_corner.exists + with step(f'User {user_one.name}, add reaction to the last message and verify it was added'): + message.open_context_menu_for_message().add_reaction_to_message(1) + assert driver.waitFor(lambda: HEART_EMOJI_PATH == message.get_emoji_reactions_pathes()[0], timeout) + with step(f'User {user_one.name}, delete own message and verify it was deleted'): message = messages_screen.left_panel.click_chat_by_name(user_two.name).find_message_by_text( chat_message_reply, 0) @@ -135,7 +151,7 @@ def test_1x1_chat(multiple_instances): with step(f'User {user_one.name}, cannot delete {user_two.name} message'): message = messages_screen.left_panel.click_chat_by_name(user_two.name).find_message_by_text(chat_message2, - 2) + 3) assert not message.hover_message().is_delete_button_visible() with step(f'User {user_one.name}, clears chat history'): @@ -163,5 +179,5 @@ def test_1x1_chat(multiple_instances): aut_one.attach() main_window.prepare() assert driver.waitFor(lambda: user_two.name in messages_screen.left_panel.get_chats_names, - configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'{chat} is present in chats list' + timeout), f'{chat} is present in chats list' main_window.hide()