From cbb65719544f938f017974f9c96db4a06c3263af Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Mon, 19 Dec 2022 04:02:57 +0200 Subject: [PATCH] e2e: Updated tests 702807 and 702808 --- .../tests/critical/chats/test_group_chat.py | 199 ++++++++++++------ test/appium/views/home_view.py | 8 +- 2 files changed, 143 insertions(+), 64 deletions(-) diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index 2d01f191a4..09515b99c5 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -77,32 +77,6 @@ class TestGroupChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.errors.verify_no_errors() - @marks.testrail_id(700731) - @marks.xfail(reason="test may fail as sometimes message 'Hey admin' is not delivered; needs investigation") - def test_group_chat_join_send_text_messages_push(self): - message_to_admin = self.message_to_admin - [self.homes[i].home_button.double_click() for i in range(3)] - self.homes[1].get_chat(self.chat_name).click() - - self.chats[1].send_message(message_to_admin) - - self.chats[0].just_fyi('check that PN is received and after tap you are redirected to group chat') - self.chats[0].open_notification_bar() - pn = self.homes[0].get_pn(message_to_admin) - if pn: - pn.click() - else: - self.homes[0].click_system_back_button() - self.homes[0].get_chat(self.chat_name).click() - - self.chats[1].just_fyi('Check message status and message delivery') - message_status = self.chats[1].chat_element_by_text(message_to_admin).status - if message_status != 'delivered': - self.errors.append('Message status is not delivered, it is %s!' % message_status) - if not self.chats[0].chat_element_by_text(message_to_admin).is_element_displayed(30): - self.drivers[0].fail('Message %s was not received by admin' % message_to_admin) - self.errors.verify_no_errors() - @marks.testrail_id(700732) def test_group_chat_add_new_member(self): [self.homes[i].home_button.double_click() for i in range(3)] @@ -129,40 +103,6 @@ class TestGroupChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.errors.append('%s is shown for new user' % message) self.errors.verify_no_errors() - @marks.testrail_id(3998) - @marks.xfail(reason="mysterious issue when PNs are not fetched from offline, can not reproduce on real devices; needs investigation") - def test_group_chat_offline_pn(self): - [self.homes[i].home_button.double_click() for i in range(3)] - chat_name = 'for_offline_pn' - self.homes[0].create_group_chat([self.usernames[1], self.usernames[2]], chat_name) - self.homes[0].home_button.double_click() - for i in range(1, 3): - self.homes[i].get_chat(chat_name).click() - - message_1, message_2 = 'message from old member', 'message from new member' - - self.homes[0].just_fyi("Put admin device to offline and send messages from members") - self.homes[0].toggle_airplane_mode() - self.chats[1].send_message(message_1) - self.chats[2].send_message(message_2) - - self.homes[0].just_fyi("Put admin device to online and check that messages and PNs will be fetched") - self.homes[0].toggle_airplane_mode() - self.homes[0].connection_offline_icon.wait_for_invisibility_of_element(60) - self.homes[0].open_notification_bar() - for message in (message_1, message_2): - if not self.homes[0].element_by_text(message).is_element_displayed(30): - self.errors.append('%s PN was not fetched from offline' % message) - self.homes[0].click_system_back_button() - self.homes[0].get_chat(chat_name).click() - - self.homes[0].just_fyi("check that messages are shown for every member") - for i in range(3): - for message in (message_1, message_2): - if not self.chats[i].chat_element_by_text(message).is_element_displayed(): - self.errors.append('%s if not shown for device %s' % (message, str(i))) - self.errors.verify_no_errors() - @marks.testrail_id(5756) def test_group_chat_highligted(self): chat_name = 'for_invited' @@ -200,6 +140,145 @@ class TestGroupChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.drivers[0].fail('Deleted %s is present after relaunch app' % self.chat_name) +@pytest.mark.xdist_group(name="one_3") +@marks.new_ui_critical +class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): + + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(3) + self.message_before_adding = 'message before adding new user' + self.message_to_admin = 'Hey, admin!' + self.public_keys, self.usernames, self.chats = {}, {}, {} + sign_in_views = [SignInView(self.drivers[key]) for key in self.drivers] + self.loop.run_until_complete( + run_in_parallel( + ( + (sign_in_views[0].create_user,), + (sign_in_views[1].create_user,), + (sign_in_views[2].create_user,) + ) + ) + ) + self.homes = [sign_in.get_home_view() for sign_in in sign_in_views] + users = self.loop.run_until_complete( + run_in_parallel( + ( + (self.homes[0].get_public_key_and_username, True), + (self.homes[1].get_public_key_and_username, True), + (self.homes[2].get_public_key_and_username, True) + ) + ) + ) + self.profiles = [home.get_profile_view() for home in self.homes] + self.loop.run_until_complete( + run_in_parallel( + ( + (self.profiles[0].switch_push_notifications,), + (self.profiles[1].switch_push_notifications,), + (self.profiles[2].switch_push_notifications,) + ) + ) + ) + self.homes[0].just_fyi('Admin adds future members to contacts') + + for i in range(3): + self.public_keys[i], self.usernames[i] = users[i] + + for i in range(1, 3): + self.homes[0].browser_tab.click() + self.profiles[0].add_contact_via_contacts_list(self.public_keys[i]) + + for i in range(3): + self.homes[i].chats_tab.click() + + self.homes[0].just_fyi('Members add admin to contacts to see PNs and put app in background') + self.loop.run_until_complete( + run_in_parallel( + ( + (self.homes[1].handle_contact_request, self.usernames[0]), + (self.homes[2].handle_contact_request, self.usernames[0]) + ) + ) + ) + for i in range(1, 3): + self.homes[i].click_system_back_button_until_element_is_shown() + + self.homes[0].just_fyi('Admin creates group chat') + self.chat_name = self.homes[0].get_random_chat_name() + self.chats[0] = self.homes[0].create_group_chat(user_names_to_add=[self.usernames[1]], + group_chat_name=self.chat_name, + new_ui=True) + for i in range(1, 3): + self.chats[i] = ChatView(self.drivers[i]) + + self.chats[0].send_message(self.message_before_adding) + + @marks.testrail_id(702807) + # @marks.xfail(reason="test may fail as sometimes message 'Hey admin' is not delivered; needs investigation") + def test_group_chat_join_send_text_messages_push(self): + message_to_admin = self.message_to_admin + [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + self.homes[1].get_chat(self.chat_name).click() + + self.chats[1].send_message(message_to_admin) + + self.chats[0].just_fyi('Check that PN is received and after tap you are redirected to group chat') + self.chats[0].open_notification_bar() + pn = self.homes[0].get_pn(message_to_admin) + if pn: + pn.click() + else: + self.homes[0].click_system_back_button() + self.homes[0].get_chat(self.chat_name).click() + + self.chats[1].just_fyi('Check message status and message delivery') + # Not available yet + # message_status = self.chats[1].chat_element_by_text(message_to_admin).status + # if message_status != 'delivered': + # self.errors.append('Message status is not delivered, it is %s!' % message_status) + if not self.chats[0].chat_element_by_text(message_to_admin).is_element_displayed(30): + self.errors.append('Message %s was not received by admin' % message_to_admin) + self.errors.verify_no_errors() + + @marks.testrail_id(702808) + # @marks.xfail( + # reason="mysterious issue when PNs are not fetched from offline, + # can not reproduce on real devices; needs investigation") + def test_group_chat_offline_pn(self): + [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + chat_name = 'for_offline_pn' + self.homes[0].create_group_chat(user_names_to_add=[self.usernames[1], self.usernames[2]], + group_chat_name=chat_name, + new_ui=True) + self.homes[0].click_system_back_button_until_element_is_shown() + for i in range(1, 3): + self.homes[i].get_chat(chat_name).click() + + message_1, message_2 = 'message from old member', 'message from new member' + + self.homes[0].just_fyi("Put admin device to offline and send messages from members") + self.homes[0].toggle_airplane_mode() + self.chats[1].send_message(message_1) + self.chats[2].send_message(message_2) + + self.homes[0].just_fyi("Put admin device to online and check that messages and PNs will be fetched") + self.homes[0].toggle_airplane_mode() + self.homes[0].connection_offline_icon.wait_for_invisibility_of_element(60) + self.homes[0].open_notification_bar() + for message in (message_1, message_2): + if not self.homes[0].element_by_text(message).is_element_displayed(30): + self.errors.append('%s PN was not fetched from offline' % message) + self.homes[0].click_system_back_button() + self.homes[0].get_chat(chat_name).click() + + self.homes[0].just_fyi("check that messages are shown for every member") + for i in range(3): + for message in (message_1, message_2): + if not self.chats[i].chat_element_by_text(message).is_element_displayed(): + self.errors.append('%s if not shown for device %s' % (message, str(i))) + self.errors.verify_no_errors() + + @pytest.mark.xdist_group(name="three_2") @marks.new_ui_critical class TestGroupChatMediumMultipleDeviceNewUI(MultipleSharedDeviceTestCase): diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 576a24243d..d19741026d 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -326,10 +326,10 @@ class HomeView(BaseView): chat_element = ChatElement(self.driver, username[:25], community=community) if not chat_element.is_element_displayed(10): if self.notifications_unread_badge.is_element_displayed(30): - self.open_activity_center_button.click() - chat_in_ac = ActivityCenterElement(self.driver, username[:25]) - chat_in_ac.wait_for_element(20) - chat_in_ac.click() + chat_in_ac = ActivityCenterElement(self.driver, username[:25]) + self.open_activity_center_button.click_until_presence_of_element(chat_in_ac) + chat_in_ac.wait_for_element(20) + chat_in_ac.click() return chat_element def get_chat_from_home_view(self, username):