From e015fface7e526a75e82a80eab9067113e836e31 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Tue, 1 Oct 2024 15:42:59 +0300 Subject: [PATCH] chore: change 1x1 chat to add contacts through settings --- .../onboarding/before_started_popup.py | 2 +- .../test_messaging_1x1_chat.py | 89 ++++++++++++--- .../test_messaging_group_chat.py | 3 +- .../test_messaging_settings_accept_request.py | 106 ------------------ 4 files changed, 74 insertions(+), 126 deletions(-) delete mode 100644 test/e2e/tests/settings/settings_messaging/test_messaging_settings_accept_request.py diff --git a/test/e2e/gui/components/onboarding/before_started_popup.py b/test/e2e/gui/components/onboarding/before_started_popup.py index 6706b156a7..d38f75b446 100644 --- a/test/e2e/gui/components/onboarding/before_started_popup.py +++ b/test/e2e/gui/components/onboarding/before_started_popup.py @@ -32,5 +32,5 @@ class BeforeStartedPopUp(BasePopup): assert self._terms_of_use_checkBox.checkState != 0, f"ToU checkbox is not checked" assert self._terms_of_use_link.is_visible, f"Terms of use link is missing" assert self._privacy_policy_link.is_visible, f"Privacy Policy link is missing" - self._get_started_button.click() + self._get_started_button.click(timeout=10) self.wait_until_hidden() diff --git a/test/e2e/tests/crtitical_tests_prs/test_messaging_1x1_chat.py b/test/e2e/tests/crtitical_tests_prs/test_messaging_1x1_chat.py index 299c26ee98..5c388d8943 100644 --- a/test/e2e/tests/crtitical_tests_prs/test_messaging_1x1_chat.py +++ b/test/e2e/tests/crtitical_tests_prs/test_messaging_1x1_chat.py @@ -9,6 +9,7 @@ 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.messaging import Messaging from constants.wallet import WalletAddress from gui.screens.messages import MessagesScreen, ToolBar @@ -25,10 +26,11 @@ pytestmark = marks @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703087', '1-1 Chat') @pytest.mark.case(703087) @pytest.mark.critical -def test_1x1_chat(multiple_instances): +def test_1x1_chat_add_contact_in_settings(multiple_instances): user_one: UserAccount = RandomUser() user_two: UserAccount = RandomUser() main_window = MainWindow() + messages_screen = MessagesScreen() emoji = 'sunglasses' timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC @@ -56,18 +58,69 @@ def test_1x1_chat(multiple_instances): aut_one.attach() main_window.prepare() settings = main_window.left_panel.open_settings() - contact_request_form = settings.left_panel.open_messaging_settings().open_contacts_settings().open_contact_request_form() - contact_request_form.send(chat_key, f'Hello {user_two.name}') + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contact_request_popup = contacts_settings.open_contact_request_form() + contact_request_popup.send(chat_key, f'Hello {user_two.name}') - with step(f'User {user_two.name}, accept contact request from {user_one.name} via activity center'): + with step('Verify that contact request was sent and is in pending requests'): + contacts_settings.open_pending_requests() + assert Messaging.CONTACT_REQUEST_SENT.value == contacts_settings.contact_items[0].object.contactText + assert len(contacts_settings.contact_items) == 1 + assert contacts_settings.pending_request_sent_list_title == 'Sent' + main_window.hide() + + with step(f'Verify that contact request was received by {user_two.name}'): aut_two.attach() main_window.prepare() - activity_center = ToolBar().open_activity_center() - request = activity_center.find_contact_request_in_list(user_one.name, timeout) - activity_center.click_activity_center_button( - 'Contact requests').accept_contact_request(request) + settings = main_window.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contacts_settings.open_pending_requests() + assert contacts_settings.pending_request_received_list_title == 'Received' + assert user_one.name == contacts_settings.contact_items[0].contact + assert len(contacts_settings.contact_items) == 1 + + # TODO https://github.com/status-im/desktop-qa-automation/issues/346 + # with step('Verify toast message about new contact request received'): + # toast_messages = main_window.wait_for_notification() + # assert len(toast_messages) == 1, \ + # f"Multiple toast messages appeared" + # message = toast_messages[0] + # assert message == Messaging.NEW_CONTACT_REQUEST.value, \ + # f"Toast message is incorrect, current message is {message}" + + with step(f'User {user_two.name}, accept contact request from {user_one.name}'): + contacts_settings.accept_contact_request(user_one.name) + + with step(f'Verify that contact appeared in contacts list of {user_two.name} in messaging settings'): + contacts_settings = main_window.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings() + contacts_settings.open_contacts() + assert contacts_settings.contacts_list_title == 'Contacts' + assert user_one.name == contacts_settings.contact_items[0].contact + assert len(contacts_settings.contact_items) == 1 main_window.hide() + with step(f'Verify that contact appeared in contacts list of {user_one.name} in messaging settings'): + aut_one.attach() + main_window.prepare() + contacts_settings = main_window.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings() + contacts_settings.open_contacts() + assert contacts_settings.contacts_list_title == 'Contacts' + assert user_two.name == contacts_settings.contact_items[0].contact + assert len(contacts_settings.contact_items) == 1 + + with step(f'Verify that 1X1 chat with {user_two.name} appeared for {user_one.name}'): + messages_screen = main_window.left_panel.open_messages_screen() + assert user_two.name in messages_screen.left_panel.get_chats_names + main_window.hide() + + with step(f'Verify that 1X1 chat with {user_one.name} appeared for {user_two.name}'): + aut_two.attach() + main_window.prepare() + messages_screen = main_window.left_panel.open_messages_screen() + assert user_one.name in messages_screen.left_panel.get_chats_names + with step(f'User {user_one.name} send a message to {user_two.name}'): aut_one.attach() main_window.prepare() @@ -110,7 +163,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 str(message_object_1.object.unparsedText),\ + 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,7 +174,7 @@ def test_1x1_chat(multiple_instances): with step(f'User {user_two.name} send image to {user_one.name} and verify it was sent'): messages_screen.group_chat.send_image_to_chat(str(path)) message_object = messages_screen.chat.messages(0)[0] - assert message_object.image_message.visible,\ + assert message_object.image_message.visible, \ f"Message text is not found in the last message" main_window.hide() @@ -130,17 +183,17 @@ 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 str(message_object.object.unparsedText)),\ + 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 str(message_object.object.unparsedText) , 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}'): message_object = messages_screen.chat.messages(0)[0] - assert message_object.image_message.visible,\ + assert message_object.image_message.visible, \ f"There is no image in the last message" with step(f'User {user_one.name}, reply to own message and verify that message displayed as a reply'): @@ -149,14 +202,14 @@ def test_1x1_chat(multiple_instances): message.hover_message().reply_own_message(chat_message_reply) chat = main_window.left_panel.open_messages_screen().left_panel.click_chat_by_name(user_two.name) message = chat.find_message_by_text(chat_message_reply, 0) - assert message.reply_corner.exists,\ + assert message.reply_corner.exists, \ f"Last message does not have reply corner" with step(f'User {user_one.name}, add reaction to the last message and verify it was added'): occurrence = random.randint(1, 6) message.open_context_menu_for_message().add_reaction_to_message(occurrence) assert driver.waitFor(lambda: EMOJI_PATHES[occurrence - 1] == str(message.get_emoji_reactions_pathes()[0]), - timeout),\ + timeout), \ f"Emoji reaction is not correct" main_window.hide() @@ -165,7 +218,7 @@ def test_1x1_chat(multiple_instances): main_window.prepare() message = chat.find_message_by_text(chat_message_reply, 0) assert driver.waitFor(lambda: EMOJI_PATHES[occurrence - 1] == str(message.get_emoji_reactions_pathes()[0]), - timeout),\ + timeout), \ f"Emoji reaction is not correct" main_window.hide() @@ -178,7 +231,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, 3) - assert not message.hover_message().is_delete_button_visible(),\ + assert not message.hover_message().is_delete_button_visible(), \ f"Delete button is visible although it should not be" with step(f'User {user_one.name}, clears chat history'): @@ -207,4 +260,4 @@ def test_1x1_chat(multiple_instances): main_window.prepare() assert driver.waitFor(lambda: user_two.name in messages_screen.left_panel.get_chats_names, timeout), f'{chat} is present in chats list' - main_window.hide() + main_window.hide() \ No newline at end of file diff --git a/test/e2e/tests/crtitical_tests_prs/test_messaging_group_chat.py b/test/e2e/tests/crtitical_tests_prs/test_messaging_group_chat.py index 043c4eee76..5aef963abd 100644 --- a/test/e2e/tests/crtitical_tests_prs/test_messaging_group_chat.py +++ b/test/e2e/tests/crtitical_tests_prs/test_messaging_group_chat.py @@ -22,7 +22,8 @@ pytestmark = marks @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703014', 'Create a group and send messages') @pytest.mark.case(703014) @pytest.mark.timeout(timeout=315) -def test_group_chat(multiple_instances): +@pytest.mark.critical +def test_group_chat_add_contact_in_ac(multiple_instances): user_one: UserAccount = RandomUser() user_two: UserAccount = RandomUser() user_three: UserAccount = RandomUser() diff --git a/test/e2e/tests/settings/settings_messaging/test_messaging_settings_accept_request.py b/test/e2e/tests/settings/settings_messaging/test_messaging_settings_accept_request.py deleted file mode 100644 index ad09e317b8..0000000000 --- a/test/e2e/tests/settings/settings_messaging/test_messaging_settings_accept_request.py +++ /dev/null @@ -1,106 +0,0 @@ -import allure -import pytest -from allure_commons._allure import step - -from . import marks - -import configs.testpath -import constants -from constants import UserAccount, RandomUser -from scripts.utils.generators import random_name_string, random_password_string -from constants.messaging import Messaging -from gui.main_window import MainWindow - -pytestmark = marks - - -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703011', 'Add a contact with a chat key') -@pytest.mark.case(703011) -# TODO: reason='https://github.com/status-im/desktop-qa-automation/issues/346' -def test_messaging_settings_accepting_request(multiple_instances): - user_one: UserAccount = RandomUser() - user_two: UserAccount = RandomUser() - main_window = MainWindow() - - 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}'): - for aut, account in zip([aut_one, aut_two], [user_one, user_two]): - aut.attach() - main_window.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare() - main_window.authorize_user(account) - main_window.hide() - - with step(f'User {user_two.name}, get chat key'): - aut_two.attach() - main_window.prepare() - profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() - chat_key = profile_popup.copy_chat_key - profile_popup.close() - main_window.hide() - - with step(f'User {user_one.name}, send contact request to {user_two.name}'): - aut_one.attach() - main_window.prepare() - settings = main_window.left_panel.open_settings() - messaging_settings = settings.left_panel.open_messaging_settings() - contacts_settings = messaging_settings.open_contacts_settings() - contact_request_popup = contacts_settings.open_contact_request_form() - contact_request_popup.send(chat_key, f'Hello {user_two.name}') - - with step('Verify that contact request was sent and is in pending requests'): - contacts_settings.open_pending_requests() - assert Messaging.CONTACT_REQUEST_SENT.value == contacts_settings.contact_items[0].object.contactText - assert len(contacts_settings.contact_items) == 1 - assert contacts_settings.pending_request_sent_list_title == 'Sent' - main_window.hide() - - with step(f'Verify that contact request was received by {user_two.name}'): - aut_two.attach() - main_window.prepare() - settings = main_window.left_panel.open_settings() - messaging_settings = settings.left_panel.open_messaging_settings() - contacts_settings = messaging_settings.open_contacts_settings() - contacts_settings.open_pending_requests() - assert contacts_settings.pending_request_received_list_title == 'Received' - assert user_one.name == contacts_settings.contact_items[0].contact - assert len(contacts_settings.contact_items) == 1 - - # TODO https://github.com/status-im/desktop-qa-automation/issues/346 - # with step('Verify toast message about new contact request received'): - # toast_messages = main_window.wait_for_notification() - # assert len(toast_messages) == 1, \ - # f"Multiple toast messages appeared" - # message = toast_messages[0] - # assert message == Messaging.NEW_CONTACT_REQUEST.value, \ - # f"Toast message is incorrect, current message is {message}" - - with step(f'User {user_two.name}, accept contact request from {user_one.name}'): - contacts_settings.accept_contact_request(user_one.name) - - with step(f'Verify that contact appeared in contacts list of {user_two.name} in messaging settings'): - contacts_settings = main_window.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings() - contacts_settings.open_contacts() - assert contacts_settings.contacts_list_title == 'Contacts' - assert user_one.name == contacts_settings.contact_items[0].contact - assert len(contacts_settings.contact_items) == 1 - main_window.hide() - - with step(f'Verify that contact appeared in contacts list of {user_one.name} in messaging settings'): - aut_one.attach() - main_window.prepare() - contacts_settings = main_window.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings() - contacts_settings.open_contacts() - assert contacts_settings.contacts_list_title == 'Contacts' - assert user_two.name == contacts_settings.contact_items[0].contact - assert len(contacts_settings.contact_items) == 1 - - with step(f'Verify that 1X1 chat with {user_two.name} appeared for {user_one.name}'): - messages_screen = main_window.left_panel.open_messages_screen() - assert user_two.name in messages_screen.left_panel.get_chats_names - main_window.hide() - - with step(f'Verify that 1X1 chat with {user_one.name} appeared for {user_two.name}'): - aut_two.attach() - main_window.prepare() - messages_screen = main_window.left_panel.open_messages_screen() - assert user_one.name in messages_screen.left_panel.get_chats_names