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 ec2a4f7124..5bda5372ac 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 @@ -1238,11 +1238,20 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.public_key_2, self.default_username_2 = users[1] self.profile_1.switch_push_notifications() - self.profile_1.chats_tab.click() - self.chat_1 = self.home_1.add_contact(self.public_key_2) + + self.profile_1.just_fyi("Sending contact request via Profile > Contacts") + self.profile_1.click_system_back_button_until_element_is_shown(self.profile_1.contacts_button) + self.profile_1.add_contact_via_contacts_list(self.public_key_2) + self.chat_1 = self.profile_1.open_contact_from_profile(self.default_username_2) + + self.home_2.just_fyi("Accepting contact request from activity centre") + self.home_2.chats_tab.click() + self.home_2.handle_contact_request(self.default_username_1) + + self.profile_1.just_fyi("Sending message to contact via Profile > Contacts > Send message") + self.chat_1.profile_send_message.click() self.chat_1.send_message('hey') self.home_2.click_system_back_button_until_element_is_shown() - self.home_2.chats_tab.click() self.chat_2 = self.home_2.get_chat(self.default_username_1).click() self.message_1, self.message_2, self.message_3, self.message_4 = \ "Message 1", "Message 2", "Message 3", "Message 4" @@ -1383,9 +1392,10 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): message = 'profile_photo' self.chat_1.send_message(message) self.chat_2.chat_element_by_text(message).wait_for_visibility_of_element(30) - if not self.chat_2.chat_element_by_text(message).member_photo.is_element_differs_from_template("member2.png", - diff=5): - self.errors.append("Image of user in 1-1 chat is updated even when user is not added to contacts!") + # Should be checked in CR flow, as for now no way to start chat with user until he is added to contacts + # if not self.chat_2.chat_element_by_text(message).member_photo.is_element_differs_from_template("member2.png", + # diff=5): + # self.errors.append("Image of user in 1-1 chat is updated even when user is not added to contacts!") self.chat_1.just_fyi("Users add to contacts each other") [home.click_system_back_button_until_element_is_shown() for home in (self.home_1, self.home_2)] diff --git a/test/appium/tests/critical/test_pairing_devices_sync.py b/test/appium/tests/critical/test_pairing_devices_sync.py index b0bed58e41..5912043cb1 100644 --- a/test/appium/tests/critical/test_pairing_devices_sync.py +++ b/test/appium/tests/critical/test_pairing_devices_sync.py @@ -58,14 +58,16 @@ class TestPairingMultipleDevicesMerged(MultipleSharedDeviceTestCase): if self.home_2.notifications_unread_badge.is_element_displayed(): self.home_2.notifications_unread_badge.click() for chat in activity_centre.keys(): - from views.home_view import ActivityCenterChatElement - chat_in_ac = ActivityCenterChatElement(self.driver, chat_name=chat) + from views.home_view import ActivityCenterElement + chat_in_ac = ActivityCenterElement(self.driver, username=chat) if not chat_in_ac.is_element_displayed(): self.errors.append('No chat "%s" in activity centre' % chat) else: - if not chat_in_ac.chat_message_preview != activity_centre[chat]: - self.errors.append('No chat preview for "%s" in activity centre, "%s" instead' % - chat, chat_in_ac.chat_message_preview) + pass + # Old UI + # if not chat_in_ac.chat_message_preview != activity_centre[chat]: + # self.errors.append('No chat preview for "%s" in activity centre, "%s" instead' % + # chat, chat_in_ac.chat_message_preview) else: self.home_2.driver.fail("No unread messages in Activity centre!") self.errors.verify_no_errors() diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index eead34cb75..6cf54b41fc 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -93,54 +93,15 @@ class ChatElement(SilentButton): return ChatImage(self.driver) -class ActivityCenterChatElement(SilentButton): - def __init__(self, driver, chat_name): - self.chat_name = chat_name +class ActivityCenterElement(SilentButton): + def __init__(self, driver, username): + self.chat_name = username super().__init__(driver, - xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/../.." % chat_name) - - def navigate(self): - from views.chat_view import ChatView - return ChatView(self.driver) - - def click(self): - from views.chat_view import ChatView - desired_element = ChatView(self.driver).chat_message_input - self.click_until_presence_of_element(desired_element=desired_element) - - return self.navigate() - - @property - def chat_image(self): - class ChatImage(BaseElement): - def __init__(self, driver, parent_locator: str): - super().__init__(driver, xpath="%s//*[@content-desc='current-account-photo']" % parent_locator) - - return ChatImage(self.driver, self.locator) - - @property - def chat_message_preview(self): - class ChatMessagePreview(BaseElement): - def __init__(self, driver, parent_locator: str): - super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator) - - return ChatMessagePreview(self.driver, self.locator).text - - @property - def chat_name_indicator_text(self): - class ChatNameIndicatorText(BaseElement): - def __init__(self, driver, parent_locator: str): - super().__init__(driver, - xpath="(%s//*[@content-desc='chat-name-container']//android.widget.TextView)[last()]" % parent_locator) - - try: - return ChatNameIndicatorText(self.driver, self.locator).text - except NoSuchElementException: - return '' + xpath="//*[contains(@text, '%s')]/ancestor::*[@content-desc='activity']" % username) def accept_contact_request(self): try: - accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-cr"]').find_element() + accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-contact-request"]').find_element() except NoSuchElementException: return '' if accept_element: @@ -148,13 +109,109 @@ class ActivityCenterChatElement(SilentButton): def decline_contact_request(self): try: - decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-cr"]').find_element() + decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-contact-request"]').find_element() except NoSuchElementException: return '' if decline_element: decline_element.click() +# Old UI +# def __init__(self, driver, chat_name): +# self.chat_name = chat_name +# super().__init__(driver, +# xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/../.." % chat_name) + +# def navigate(self): +# from views.chat_view import ChatView +# return ChatView(self.driver) +# +# def click(self): +# from views.chat_view import ChatView +# desired_element = ChatView(self.driver).chat_message_input +# self.click_until_presence_of_element(desired_element=desired_element) +# +# return self.navigate() +# +# @property +# def chat_image(self): +# class ChatImage(BaseElement): +# def __init__(self, driver, parent_locator: str): +# super().__init__(driver, xpath="%s//*[@content-desc='current-account-photo']" % parent_locator) +# +# return ChatImage(self.driver, self.locator) +# +# @property +# def chat_message_preview(self): +# class ChatMessagePreview(BaseElement): +# def __init__(self, driver, parent_locator: str): +# super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator) +# +# return ChatMessagePreview(self.driver, self.locator).text +# +# @property +# def chat_name_indicator_text(self): +# class ChatNameIndicatorText(BaseElement): +# def __init__(self, driver, parent_locator: str): +# super().__init__(driver, +# xpath="(%s//*[@content-desc='chat-name-container']//android.widget.TextView)[last()]" % parent_locator) +# +# try: +# return ChatNameIndicatorText(self.driver, self.locator).text +# except NoSuchElementException: +# return '' +# +# def accept_contact_request(self): +# try: +# accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-cr"]').find_element() +# except NoSuchElementException: +# return '' +# if accept_element: +# accept_element.click() +# +# def decline_contact_request(self): +# try: +# decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-cr"]').find_element() +# except NoSuchElementException: +# return '' +# if decline_element: +# decline_element.click() +# +# +# class PushNotificationElement(SilentButton): +# def __init__(self, driver, pn_text): +# self.pn_text = pn_text +# super().__init__(driver, xpath="//*[@text='%s']" % pn_text) +# +# @property +# def icon(self): +# class PnIconElement(BaseElement): +# def __init__(self, driver, parent_locator): +# super().__init__(driver, +# xpath="%s/../../../../*/*[@resource-id='android:id/message_icon']" % parent_locator) +# +# return PnIconElement(self.driver, self.locator) +# +# @property +# def username(self): +# class PnUsername(BaseElement): +# def __init__(self, driver, parent_locator): +# super().__init__(driver, +# xpath="%s/../../*[@resource-id='android:id/message_name']" % parent_locator) +# +# return PnUsername(self.driver, self.locator).text +# +# @property +# def group_chat_icon(self): +# class GroupChatIconElement(BaseElement): +# def __init__(self, driver, parent_locator): +# super().__init__(driver, +# xpath="%s/../../../../*[@resource-id='android:id/right_icon_container']" % parent_locator) +# +# return GroupChatIconElement(self.driver, self.locator) + + + class PushNotificationElement(SilentButton): def __init__(self, driver, pn_text): self.pn_text = pn_text @@ -209,6 +266,7 @@ class HomeView(BaseView): self.notifications_button = Button(self.driver, accessibility_id="notifications-button") self.notifications_unread_badge = BaseElement(self.driver, accessibility_id="notifications-unread-badge") self.open_activity_center_button = Button(self.driver, accessibility_id="open-activity-center-button") + self.close_activity_centre = Button(self.driver, accessibility_id="close-activity-center") self.notifications_select_button = Button(self.driver, translation_id="select") self.notifications_reject_and_delete_button = Button(self.driver, accessibility_id="reject-and-delete" @@ -261,7 +319,7 @@ class HomeView(BaseView): 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 = ActivityCenterChatElement(self.driver, username[:25]) + chat_in_ac = ActivityCenterElement(self.driver, username[:25]) chat_in_ac.wait_for_element(20) chat_in_ac.click() return chat_element @@ -273,20 +331,21 @@ class HomeView(BaseView): def get_chat_from_activity_center_view(self, chat_name): self.driver.info("Looking for chat: '%s'" % chat_name) - chat_element = ActivityCenterChatElement(self.driver, chat_name[:25]) + chat_element = ActivityCenterElement(self.driver, chat_name[:25]) return chat_element def handle_contact_request(self, username: str, accept=True): if self.notifications_unread_badge.is_element_displayed(30): self.open_activity_center_button.click() - chat_element = ActivityCenterChatElement(self.driver, username[:25]) + chat_element = ActivityCenterElement(self.driver, username[:25]) if accept: self.driver.info("Accepting contact request for %s" % username) chat_element.accept_contact_request() - chat_element.click() else: self.driver.info("Rejecting contact request for %s" % username) chat_element.decline_contact_request() + self.close_activity_centre.click() + self.chats_tab.wait_for_visibility_of_element() def get_username_below_start_new_chat_button(self, username_part): return Text(self.driver,