From 7282ba04bc3b0f213877f36d35abc459f9733c5d Mon Sep 17 00:00:00 2001 From: Tetiana Churikova Date: Wed, 12 Jul 2023 11:21:39 +0200 Subject: [PATCH] e2e: fixes shell nav (#16545) --- .../critical/chats/test_1_1_public_chats.py | 7 +++--- .../tests/critical/chats/test_group_chat.py | 8 ++++++- .../critical/test_public_chat_browsing.py | 23 ++++++++++++++----- .../tests/medium/test_activity_center.py | 19 ++++----------- test/appium/views/base_view.py | 9 ++++++-- test/appium/views/chat_view.py | 12 ++++++---- test/appium/views/sign_in_view.py | 2 +- 7 files changed, 49 insertions(+), 31 deletions(-) diff --git a/test/appium/tests/critical/chats/test_1_1_public_chats.py b/test/appium/tests/critical/chats/test_1_1_public_chats.py index c1c2045ee2..e8ddca4aaa 100644 --- a/test/appium/tests/critical/chats/test_1_1_public_chats.py +++ b/test/appium/tests/critical/chats/test_1_1_public_chats.py @@ -979,8 +979,9 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): url_message = 'http://status.im' self.chat_1.send_message(url_message) try: - self.chat_2.element_starts_with_text(url_message, 'button').wait_for_visibility_of_element(120) - self.chat_2.element_starts_with_text(url_message, 'button').click_inside_element_by_coordinate(0.2, 0.5) + element = self.chat_2.chat_view_element_starts_with_text(url_message) + element.wait_for_visibility_of_element(120) + element.click_inside_element_by_coordinate(0.2, 0.5) web_view = self.chat_2.open_in_status_button.click() if not web_view.element_by_text('Private, Secure Communication').is_element_displayed(60): self.errors.append('URL was not opened from 1-1 chat') @@ -1082,7 +1083,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): @marks.testrail_id(702745) def test_1_1_chat_non_latin_messages_stack_update_profile_photo(self): - self.home_1.click_system_back_button_until_element_is_shown() + self.home_1.jump_to_messages_home() self.home_1.profile_button.click() self.profile_1.edit_profile_picture('sauce_logo.png') self.profile_1.click_system_back_button_until_element_is_shown() diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index 1650ef42e1..d6bf256f0d 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -343,8 +343,10 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.testrail_id(702808) def test_group_chat_offline_pn(self): - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + self.homes[0].click_system_back_button_until_element_is_shown() + [self.homes[i].jump_to_messages_home() for i in range(3)] for i in range(1, 3): + self.homes[i].groups_tab.click() self.homes[i].get_chat(self.chat_name).click() message_1, message_2 = 'message from old member', 'message from new member' @@ -364,6 +366,10 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): else: self.errors.append('Messages PN was not fetched from offline') self.homes[0].click_system_back_button() + # workaround for app closed after opening notifications + if not self.homes[0].chats_tab.is_element_displayed(): + self.drivers[0].launch_app() + SignInView(self.drivers[0]).sign_in() self.homes[0].chats_tab.click() self.homes[0].get_chat(self.chat_name).click() diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 550546fd9d..49db4b5cba 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -350,7 +350,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(703133) def test_restore_multiaccount_with_waku_backup_remove_switch(self): - self.home.click_system_back_button_until_element_is_shown() + self.home.jump_to_communities_home() profile = self.home.profile_button.click() profile.logout() self.sign_in.recover_access(passphrase=waku_user.seed, second_user=True) @@ -453,12 +453,13 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.home_2.handle_contact_request(self.username_1) self.text_message = 'hello' - self.home_2.just_fyi("Send message to contact (need for blocking contact) test") + # self.home_2.just_fyi("Send message to contact (need for blocking contact) test") self.chat_1 = self.home_1.get_chat(self.username_2).click() self.chat_1.send_message('hey') self.chat_2 = self.home_2.get_chat(self.username_1).click() - self.chat_2.send_message(self.text_message) - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + # self.chat_2.send_message(self.text_message) + # [home.click_system_back_button_until_element_is_shown() for home in self.homes] + self.home_1.click_system_back_button_until_element_is_shown() self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() @@ -472,7 +473,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.community_1.send_invite_to_community(self.community_name, self.username_2) self.home_1.get_to_community_channel_from_home(self.community_name) - self.chat_2 = self.home_2.get_chat(self.username_1).click() + # self.chat_2 = self.home_2.get_chat(self.username_1).click() + self.home_2.just_fyi("Send message to contact (need for blocking contact) test") + self.chat_2.send_message(self.text_message) self.chat_2.element_by_text_part('View').click() self.community_2.join_community() self.channel_2 = self.community_2.get_channel(self.channel_name).click() @@ -487,6 +490,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.errors.append("Timestamp is not shown, expected: '%s', in fact: '%s'" % (", ".join(sent_time_variants), timestamp)) self.channel_1.verify_message_is_under_today_text(message, self.errors) + self.channel_2.send_message("one more message") new_message = "new message" self.channel_1.send_message(new_message) self.channel_2.verify_message_is_under_today_text(new_message, self.errors, 60) @@ -773,13 +777,19 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.channel_1.block_contact() self.chat_1.just_fyi('Check that messages from blocked user are hidden in public chat and close app') - if self.chat_1.chat_element_by_text(message_to_disappear).is_element_displayed(): + if not self.chat_1.chat_element_by_text(message_to_disappear).is_element_disappeared(30): self.errors.append("Messages from blocked user is not cleared in public chat ") self.chat_1.jump_to_messages_home() if self.home_1.element_by_text(self.username_2).is_element_displayed(): self.errors.append("1-1 chat from blocked user is not removed!") self.chat_1.toggle_airplane_mode() + # workaround for app closed after airplane mode + if not self.home_1.chats_tab.is_element_displayed() and \ + not self.chat_1.chat_floating_screen.is_element_displayed(): + self.device_1.driver.launch_app() + self.device_1.sign_in() + self.home_2.just_fyi('Send message to public chat while device 1 is offline') message_blocked, message_unblocked = "Message from blocked user", "Hurray! unblocked" self.channel_2.send_message(message_blocked) @@ -950,6 +960,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702845) def test_community_leave(self): + self.home_2.click_system_back_button_until_element_is_shown() self.home_2.jump_to_communities_home() community = self.home_2.get_chat(self.community_name, community=True) community_to_leave = CommunityView(self.drivers[1]) diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index f286261734..c02cc91e17 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -68,14 +68,9 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC 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) - 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"): + if not self.home_2.element_by_text_part(self.home_2.get_translation_by_key("add-me-to-your-contacts")).is_element_displayed(30): self.errors.append( - "Pending contact request is not shown on unread notification element on Activity center!," - " actual is '%s'" % message_text) + "Pending contact request is not shown on unread notification element on Activity center!") self.home_2.close_activity_centre.click() self.errors.verify_no_errors() @@ -83,7 +78,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.jump_to_messages_home() 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') @@ -261,10 +256,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): @marks.testrail_id(702957) def test_activity_center_mentions(self): if not self.channel_2.chat_message_input.is_element_displayed(): - self.home_2.click_system_back_button_until_element_is_shown() - self.home_2.communities_tab.click() - self.home_2.get_chat(self.community_name, community=True).click() - self.community_2.get_channel(self.channel_name).click() + self.channel_2.jump_to_card_by_text('# %s' % self.channel_name) self.home_1.jump_to_communities_home() self.device_2.just_fyi("Invited member sends a message with a mention") @@ -300,8 +292,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): @marks.testrail_id(702958) def test_activity_center_admin_notification_accept_swipe(self): self.home_2.just_fyi("Clearing history") - self.home_2.click_system_back_button_until_element_is_shown() - self.home_2.chats_tab.click() + self.home_2.jump_to_messages_home() self.home_2.clear_chat_long_press(self.username_1) [home.jump_to_communities_home() for home in (self.home_1, self.home_2)] diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index a712dca55d..e6420e6350 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -253,6 +253,10 @@ class BaseView(object): self.browser_tab = BrowserTab(self.driver) self.wallet_tab = WalletTab(self.driver) + # Floating screens (introduced by https://github.com/status-im/status-mobile/pull/16438) + self.chat_floating_screen = BaseElement(self.driver, accessibility_id=":chat-floating-screen") + self.community_floating_screen = BaseElement(self.driver, accessibility_id=":community-overview-floating-screen") + self.jump_to_button = Button(self.driver, accessibility_id="jump-to") self.yes_button = Button(self.driver, xpath="//*[@text='YES' or @text='GOT IT']") @@ -299,6 +303,7 @@ class BaseView(object): self.airplane_mode_button = AirplaneModeButton(self.driver) self.enter_qr_edit_box = EnterQRcodeEditBox(self.driver) + self.element_types = { 'base': BaseElement, 'button': Button, @@ -378,13 +383,13 @@ class BaseView(object): def click_system_back_button_until_element_is_shown(self, attempts=3, element='home'): counter = 0 + if self.chat_floating_screen.is_element_displayed(2) or self.community_floating_screen.is_element_displayed(2): + self.driver.press_keycode(4) if element == 'home': element = self.chats_tab elif element == 'chat': chat = self.get_chat_view() element = chat.chat_message_input - # Old UI - # element = self.home_button while not element.is_element_displayed(1) and counter <= attempts: self.driver.press_keycode(4) try: diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index d04e1739d9..d68236e3c5 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -980,7 +980,7 @@ class ChatView(BaseView): def edit_message_in_chat(self, message_to_edit, message_to_update): self.driver.info("Looking for message '%s' to edit it" % message_to_edit) element = self.element_by_translation_id("edit-message") - self.element_by_text_part(message_to_edit).long_press_until_element_is_shown(element) + self.chat_view_element_starts_with_text(message_to_edit).long_press_until_element_is_shown(element) element.click() self.chat_message_input.clear() self.chat_message_input.send_keys(message_to_update) @@ -988,7 +988,7 @@ class ChatView(BaseView): def delete_message_in_chat(self, message, everyone=True): self.driver.info("Looking for message '%s' to delete it" % message) - self.element_by_text_part(message).long_press_element() + self.chat_view_element_starts_with_text(message).long_press_element() for_everyone, for_me = self.element_by_translation_id("delete-for-everyone"), self.element_by_translation_id( "delete-for-me") for_everyone.click() if everyone else for_me.click() @@ -998,9 +998,9 @@ class ChatView(BaseView): self.element_by_text_part(message_text).long_press_element() self.element_by_translation_id("copy-text").click() - def quote_message(self, message=str): + def quote_message(self, message: str): self.driver.info("Quoting '%s' message" % message) - self.element_by_text_part(message).long_press_until_element_is_shown(self.reply_message_button) + self.chat_view_element_starts_with_text(message).long_press_until_element_is_shown(self.reply_message_button) self.reply_message_button.click() def set_reaction(self, message: str, emoji: str = 'thumbs-up', emoji_message=False): @@ -1225,3 +1225,7 @@ class ChatView(BaseView): def authors_for_reaction(self, emoji: str): return Button(self.driver, accessibility_id='authors-for-reaction-%s' % emojis[emoji]) + + def chat_view_element_starts_with_text(self, text: str): + return BaseElement(self.driver, + xpath="//*[@content-desc=':chat-floating-screen']//*[starts-with(@text,'%s')]" % text) diff --git a/test/appium/views/sign_in_view.py b/test/appium/views/sign_in_view.py index 58bd77f5f1..507a4e7aaa 100644 --- a/test/appium/views/sign_in_view.py +++ b/test/appium/views/sign_in_view.py @@ -253,7 +253,7 @@ class SignInView(BaseView): if not second_user: self.i_m_new_in_status_button.click_until_presence_of_element(self.generate_keys_button) else: - self.show_profiles_button.click() + self.show_profiles_button.wait_and_click(20) self.plus_profiles_button.click() self.create_new_profile_button.click() self.use_recovery_phrase_button.click()