From 5b5a29a2e1850a965d7d1121b69981ed55ffa050 Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Mon, 19 Jun 2023 14:13:23 +0300 Subject: [PATCH] e2e: tests fixes --- .../critical/test_public_chat_browsing.py | 39 ++++++++++++------- .../tests/medium/test_activity_center.py | 28 ++++++++----- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 8cccb186b4..d1ff3b5867 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -486,10 +486,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.home_2.just_fyi( 'Deleting message for me. Checking that message is deleted only for the author of the message') self.channel_2.send_message(message_to_delete_for_me) + self.channel_1.chat_element_by_text(message_to_delete_for_me).wait_for_element(120) self.channel_2.delete_message_in_chat(message_to_delete_for_me, everyone=False) if not self.channel_2.chat_element_by_text(message_to_delete_for_me).is_element_disappeared(30): self.errors.append("Deleted for me message is shown in channel for the author of message") - if not channel.element_by_translation_id('message-deleted-for-you').is_element_displayed(30): + if not self.channel_2.element_by_translation_id('message-deleted-for-you').is_element_displayed(30): self.errors.append("System message about deletion for you is not displayed") if not self.channel_1.chat_element_by_text(message_to_delete_for_me).is_element_displayed(30): self.errors.append("Deleted for me message is deleted all channel members") @@ -556,18 +557,26 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.channel_2.just_fyi("Check gallery on second device") self.channel_2.jump_to_communities_home() self.home_2.get_to_community_channel_from_home(self.community_name) - if self.channel_2.chat_element_by_text( - image_description).image_container_in_message.is_element_differs_from_template(file_name, 5): - self.errors.append("Gallery message do not match the template!") + chat_element = self.channel_2.chat_element_by_text(image_description) + try: + chat_element.wait_for_visibility_of_element(120) + received = True + if chat_element.image_container_in_message.is_element_differs_from_template(file_name, 5): + self.errors.append("Gallery message do not match the template!") + except TimeoutException: + self.errors.append("Gallery message was not received") + received = False - self.channel_2.just_fyi("Can reply to gallery") - self.channel_2.quote_message(image_description) - message_text = 'reply to gallery' - self.channel_2.chat_message_input.send_keys(message_text) - self.channel_2.send_message_button.click() - chat_element_1 = self.channel_1.chat_element_by_text(message_text) - if not chat_element_1.is_element_displayed(sec=60) or chat_element_1.replied_message_text != image_description: - self.errors.append('Reply message was not received by the sender') + if received: + self.channel_2.just_fyi("Can reply to gallery") + self.channel_2.quote_message(image_description) + message_text = 'reply to gallery' + self.channel_2.chat_message_input.send_keys(message_text) + self.channel_2.send_message_button.click() + chat_element_1 = self.channel_1.chat_element_by_text(message_text) + if not chat_element_1.is_element_displayed( + sec=60) or chat_element_1.replied_message_text != image_description: + self.errors.append('Reply message was not received by the sender') self.errors.verify_no_errors() @marks.testrail_id(702840) @@ -645,8 +654,8 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): if shown_title != data['title']: self.errors.append("Preview text is not expected, it is '%s'" % shown_title) self.channel_2.send_message_button.click() - self.channel_1.get_preview_message_by_text(url).wait_for_element(60) message = self.channel_1.get_preview_message_by_text(url) + message.wait_for_element(60) # if not message.preview_image: # self.errors.append("No preview is shown for %s" % link_data['url']) shown_title = message.preview_title.text @@ -669,7 +678,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.channel_2.send_message(message) self.home_1.just_fyi('Check new messages badge is shown for community') community_element_1 = self.home_1.get_chat(self.community_name, community=True) - if not community_element_1.new_messages_community.is_element_displayed(): + if not community_element_1.new_messages_community.is_element_displayed(sec=30): self.errors.append('New message community badge is not shown') community_1 = community_element_1.click() @@ -732,7 +741,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.chat_1.click_system_back_button_until_element_is_shown() self.home_2.just_fyi("Check that can send message in community after unblock") - [home.jump_to_card_by_text('# %s' % self.channel_name) for home in [self.home_1, self.home_2]] + self.home_1.jump_to_card_by_text('# %s' % self.channel_name) self.chat_2.send_message(message_unblocked) if not self.chat_1.chat_element_by_text(message_unblocked).is_element_displayed(120): self.errors.append("Message was not received in public chat after user unblock!") diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index 84e5670f30..4a2dd09b8b 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -50,24 +50,31 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.home_1.contacts_tab.click() for indicator in (self.home_1.notifications_unread_badge, self.home_1.contact_new_badge): if not indicator.is_element_displayed(): - self.errors.append("Unread indicator on contacts tab or on activity center is not shown for incoming CR!") + self.errors.append( + "Unread indicator on contacts tab or on activity center is not shown for incoming CR!") if self.home_1.pending_contact_request_text.text != '1': self.errors.append("The amount of contact requests is not shown for incoming CR!") self.device_1.just_fyi('Device1 declines pending contact request') self.home_1.handle_contact_request(username=self.username_2, action='decline') - for indicator in (self.home_1.notifications_unread_badge, self.home_1.contact_new_badge, self.home_1.pending_contact_request_text): + for indicator in (self.home_1.notifications_unread_badge, self.home_1.contact_new_badge, + self.home_1.pending_contact_request_text): if indicator.is_element_displayed(): - self.errors.append("Unread indicator on contacts tab or on activity center is shown after declining contact request!") + self.errors.append( + "Unread indicator on contacts tab or on activity center is shown after declining contact request!") self.device_1.just_fyi("Check that it is still pending contact after declining on sender device") self.home_2.jump_to_messages_home() self.home_2.open_activity_center_button.click() self.home_2.activity_unread_filter_button.click() activity_center_element = self.home_2.get_element_from_activity_center_view(self.username_1) - if activity_center_element.message_body.text != self.home_2.get_translation_by_key("add-me-to-your-contacts"): - self.errors.append("Pending contact request is not shown on unread notification element on Activity center!," - " actual is '%s'" % activity_center_element.message_body.text) + message_element = activity_center_element.message_body + message_element.wait_for_element(30) + message_text = message_element.text + if message_text != self.home_2.get_translation_by_key("add-me-to-your-contacts"): + self.errors.append( + "Pending contact request is not shown on unread notification element on Activity center!," + " actual is '%s'" % message_text) self.home_2.close_activity_centre.click() self.errors.verify_no_errors() @@ -75,6 +82,7 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC @marks.testrail_id(702851) def test_activity_center_contact_request_accept_swipe_mark_all_as_read(self): self.device_2.just_fyi('Device2 re-sends a contact request to Device1') + self.home_2.click_system_back_button_until_element_is_shown() self.home_2.add_contact(self.public_key_1, remove_from_contacts=True) self.device_1.just_fyi('Device1 accepts pending contact request by swiping') @@ -180,7 +188,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): self.channel_1.send_message(message_to_reply) self.home_1.jump_to_communities_home() - self.channel_2.chat_element_by_text(message_to_reply).wait_for_visibility_of_element(60) + self.channel_2.chat_element_by_text(message_to_reply).wait_for_visibility_of_element(120) self.channel_2.quote_message(message_to_reply) self.channel_2.send_message(reply_to_message_from_sender) @@ -279,7 +287,8 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): if not mention_element.unread_indicator.is_element_displayed(): self.errors.append("No unread dot is shown on activity center element (mention)!") if mention_element.message_body.text != '@%s' % self.username_1: - self.errors.append("Mention body in activity center does not match expected, it is %s!" % mention_element.message_body.text) + self.errors.append( + "Mention body in activity center does not match expected, it is %s!" % mention_element.message_body.text) self.home_1.just_fyi("Tap on it and check redirect to channel") mention_element.click() @@ -325,5 +334,6 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): self.home_2.just_fyi("Checking that community appeared on thr list") if not self.home_2.element_by_text_part(community_name).is_element_displayed(30): - self.errors.append("Community is not appeared in the list after accepting admin request from activity centre") + self.errors.append( + "Community is not appeared in the list after accepting admin request from activity centre") self.errors.verify_no_errors()