diff --git a/src/status_im/ui/screens/advanced_settings/views.cljs b/src/status_im/ui/screens/advanced_settings/views.cljs index 3fabe55cfb..a114d063e8 100644 --- a/src/status_im/ui/screens/advanced_settings/views.cljs +++ b/src/status_im/ui/screens/advanced_settings/views.cljs @@ -111,7 +111,7 @@ :active waku-bloom-filter-mode} {:size :small :title (i18n/label :t/mutual-contact-requests) - :accessibility-label :wallet-connect-settings-switch + :accessibility-label :mutual-contact-requests-switch :container-margin-bottom 8 :on-press #(re-frame/dispatch diff --git a/test/appium/support/testrail_report.py b/test/appium/support/testrail_report.py index 1a04a3b7db..43d8263cdf 100644 --- a/test/appium/support/testrail_report.py +++ b/test/appium/support/testrail_report.py @@ -135,6 +135,7 @@ class TestrailReport(BaseTestReport): test_cases['nightly']['permissions'] = 50843 test_cases['nightly']['scan qr'] = 50844 test_cases['nightly']['mentions'] = 50845 + test_cases['nightly']['mutual_contact_requests'] = 50857 test_cases['nightly']['keycard'] = 50850 test_cases['nightly']['wallet'] = 50851 ## Upgrade e2e diff --git a/test/appium/tests/medium/test_chats_m.py b/test/appium/tests/medium/test_chats_m.py index caf694fb0a..21515b48bc 100644 --- a/test/appium/tests/medium/test_chats_m.py +++ b/test/appium/tests/medium/test_chats_m.py @@ -996,3 +996,104 @@ class TestChatKeycardMentionsMediumMultipleDevice(MultipleSharedDeviceTestCase): self.errors.append("Background notification service is not started after relogin") self.errors.verify_no_errors() + + +@pytest.mark.xdist_group(name="four_2") +@marks.medium +class TestMutualContactRequests(MultipleSharedDeviceTestCase): + + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = self.device_1.create_user(enable_notifications=True), self.device_2.create_user() + self.public_key_1, self.default_username_1 = self.home_1.get_public_key_and_username(return_username=True) + self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True) + [home.tap_mutual_cr_switcher() for home in (self.home_1, self.home_2)] + [home.home_button.click() for home in (self.home_1, self.home_2)] + + @marks.testrail_id(702375) + def test_mutual_cr_unable_send_messages_if_users_not_contacts(self): + self.home_1.just_fyi("Creating 1-1 chats") + self.chat_1 = self.home_1.add_contact(self.public_key_2, add_in_contacts=False) + if self.chat_1.chat_message_input.is_element_displayed(): + self.errors.append('Input field is displayed in chat with not a contact') + if not self.chat_1.contact_request_button.is_element_displayed(): + self.errors.append('Send contact request button is not displayed in chat with not a contact') + self.errors.verify_no_errors() + + @marks.testrail_id(702376) + def test_mutual_cr_send_and_accept_cr(self): + self.home_1.home_button.click() + + self.home_1.just_fyi('Entering 1-1 chat and sending contact request') + self.chat_1 = self.home_1.add_contact(self.public_key_2, add_in_contacts=False) + self.chat_1.send_contact_request("Hi, please add me to contacts") + + self.home_1.just_fyi('Check pending request is displayed, input field still disabled') + if not self.chat_1.element_by_translation_id('contact-request-pending').is_element_displayed(): + self.errors.append('Pending request is not displayed after request was sent') + if self.chat_1.chat_message_input.is_element_displayed(): + self.errors.append('Input field is displayed despite request has not been accepted yet') + + self.home_2.just_fyi('Accepting of a new contact request') + self.home_2.handle_contact_request(self.default_username_1) + chat_2 = self.home_2.get_chat_view() + + self.home_2.just_fyi('Verify request acceptor can send messages to request sender after acceptance of cr') + message_from_receiver = 'Message from user who has accepted contact request' + chat_2.send_message(message_from_receiver) + if not self.chat_1.chat_element_by_text(message_from_receiver).is_element_displayed(): + self.errors.append('Message from accepted user has not been received') + + self.home_1.just_fyi('Verify chat input field has appeared after contact request has been accepted') + if not self.chat_1.chat_message_input.is_element_displayed(): + self.drivers[0].fail('Chat input field has not appeared after contact request has been accepted') + + self.home_1.just_fyi('Verify request sender can send messages to request acceptor after acceptance of cr') + + #TODO: Clicking send button to clear input field from remained request message. Should be removed after fix of #13610 + self.chat_1.send_message_button.click() + + message_from_sender = 'Message sent after my contact request has been accepted' + self.chat_1.send_message(message_from_sender) + if not chat_2.chat_element_by_text(message_from_sender).is_element_displayed(): + self.errors.append('Message from request sender has not been received after acceptance of his request') + + self.home_2.just_fyi('Verify contacts are mutually removed for users with enabled contact request') + chat_2.chat_options.click() + chat_2.view_profile_button.click() + chat_2.remove_from_contacts.click_until_absense_of_element(chat_2.remove_from_contacts) + chat_2.back_button.click() + + chat_2.just_fyi('Verify cannot send messages to user who was removed from contacts') + if not chat_2.contact_request_button.is_element_displayed(): + self.errors.append('Send contact request button is not displayed after removing user from contacts') + if chat_2.chat_message_input.is_element_displayed(): + self.errors.append('Chat input field is displayed after removing user from contacts') + + self.chat_1.just_fyi('Verify users are mutually removed from contacts') + if not self.chat_1.element_by_text('Not a contact').is_element_displayed(): + self.errors.append('User has not been mutually removed from contacts of removed contact') + if not self.chat_1.contact_request_button.is_element_displayed(): + self.errors.append('Send contact request button is not displayed after user has been removed from contacts') + if self.chat_1.chat_message_input.is_element_displayed(): + self.errors.append('Chat input field is displayed after user has been removed from contacts') + + self.errors.verify_no_errors() + + @marks.testrail_id(702377) + def test_mutual_cr_decline_contact_request(self): + [home.home_button.double_click() for home in (self.home_1, self.home_2)] + self.chat_1 = self.home_1.add_contact(self.public_key_2, add_in_contacts=False) + self.chat_1.send_contact_request('Contact request to decline') + self.home_2.handle_contact_request(self.default_username_1, accept=False) + self.home_2.home_button.click() + chat_2 = self.home_2.add_contact(self.public_key_1, add_in_contacts=False) + + self.chat_1.just_fyi('Verify cannot send messages to user who declined contact request') + if self.chat_1.chat_message_input.is_element_displayed(): + self.drivers[0].fail('Chat input field is displayed despite contact request has been declined') + + chat_2.just_fyi('Verify cannot send messages to user whos request has been declined') + if chat_2.chat_message_input.is_element_displayed(): + self.drivers[1].fail('Chat input field is displayed in 1-1 chat with user whos cr was declined') diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index f48517d0c7..ee8e00de70 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -223,6 +223,7 @@ class BaseView(object): def __init__(self, driver): self.driver = driver self.send_message_button = SendMessageButton(self.driver) + self.send_contact_request_button = Button(self.driver, translation_id="send-request") # Tabs self.home_button = HomeButton(self.driver) @@ -584,6 +585,12 @@ class BaseView(object): user_data = (public_key, default_username) if return_username else public_key return user_data + def tap_mutual_cr_switcher(self): + profile_view = self.profile_button.click() + profile_view.advanced_button.scroll_and_click() + profile_view.mutual_contact_request_switcher.scroll_and_click() + profile_view.click_system_back_button() + def share_via_messenger(self): self.driver.info("Sharing via messenger", device=False) self.element_by_text('Messages').wait_for_visibility_of_element(40) diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 1e45bf11c5..91cb7880c5 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -601,6 +601,7 @@ class ChatView(BaseView): # General chat view self.history_start_icon = Button(self.driver, accessibility_id="history-chat") self.unpin_message_popup = UnpinMessagePopUp(self.driver) + self.contact_request_button = Button(self.driver, accessibility_id="contact-request--button") # Stickers self.show_stickers_button = Button(self.driver, accessibility_id="show-stickers-icon") @@ -810,6 +811,13 @@ class ChatView(BaseView): self.chat_message_input.send_keys(message) self.send_message_button.click() + def send_contact_request(self, message:str = 'Contact request message', wait_chat_input_sec=5): + self.driver.info("Sending contact request message '%s'" % BaseElement(self.driver).exclude_emoji(message)) + self.contact_request_button.wait_and_click() + self.chat_message_input.wait_for_element(wait_chat_input_sec) + self.chat_message_input.send_keys(message) + self.send_contact_request_button.click() + def pin_message(self, message, action="pin"): self.driver.info("Looking for message '%s' pin" % message) self.element_by_text_part(message).long_press_element() diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index 06ccc0c4fd..c103e39c9c 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -291,6 +291,7 @@ class ProfileView(BaseView): # Advanced self.advanced_button = AdvancedButton(self.driver) + self.mutual_contact_request_switcher = Button(self.driver, accessibility_id="mutual-contact-requests-switch") ## Network self.network_settings_button = Button(self.driver, accessibility_id="network-button") self.active_network_name = Text(self.driver,