From d727338e9aef6eb6ddd9d9472ce1166677c62ec3 Mon Sep 17 00:00:00 2001 From: Serhy Date: Fri, 23 Jul 2021 11:02:42 +0300 Subject: [PATCH] PN and reactions for messages Signed-off-by: Serhy --- .../ui/screens/chat/message/message.cljs | 2 +- src/status_im/ui/screens/status/views.cljs | 2 +- .../tests/atomic/chats/test_one_to_one.py | 98 +++++++++++++++++++ test/appium/views/chat_view.py | 23 +++-- 4 files changed, 117 insertions(+), 8 deletions(-) diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index 944c30a2c1..6399f5eb2d 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -343,7 +343,7 @@ :on-long-press on-long-press :disabled in-popover?} [react/view {:style (style/image-message style-opts) - :accessibility-label :message-image} + :accessibility-label :image-message} [react/image {:style (dissoc style-opts :outgoing) :resize-mode :cover :source {:uri uri}} diff --git a/src/status_im/ui/screens/status/views.cljs b/src/status_im/ui/screens/status/views.cljs index ed856a5f35..cb0b03b2f4 100644 --- a/src/status_im/ui/screens/status/views.cljs +++ b/src/status_im/ui/screens/status/views.cljs @@ -48,7 +48,7 @@ :overflow :hidden :border-radius 16 :margin-top 8} - :accessibility-label :message-image} + :accessibility-label :image-message} [react/image {:style {:width (first @dimensions) :height image-max-dimension} :cache :force-cache diff --git a/test/appium/tests/atomic/chats/test_one_to_one.py b/test/appium/tests/atomic/chats/test_one_to_one.py index 7f76700d31..7990eab76e 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -666,6 +666,104 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): self.errors.append('New messages counter is shown on chat element for already seen message') self.errors.verify_no_errors() + @marks.testrail_id(6321) + @marks.medium + def test_push_notifications_reactions_for_messages_in_stickers_audio_image(self): + self.create_drivers(2) + device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + device_1_home, device_2_home = device_1.create_user(enable_notifications=True), device_2.create_user() + device_1_public_key, default_username_1 = device_1_home.get_public_key_and_username(return_username=True) + device_2_public_key, default_username_2 = device_2_home.get_public_key_and_username(return_username=True) + device_1_home.home_button.click() + profile_2 = device_2_home.get_profile_view() + profile_2.switch_network() + device_2_chat = device_2_home.add_contact(device_1_public_key) + + device_2_home.just_fyi('Install free sticker pack and use it in 1-1 chat') + device_2_chat.show_stickers_button.click() + device_2_chat.get_stickers.click() + device_2_chat.install_sticker_pack_by_name('Status Cat') + device_2_chat.back_button.click() + time.sleep(2) + device_2_chat.swipe_left() + device_1_chat = device_1_home.add_contact(device_2_public_key) + + # methods with steps to use later in loop + def navigate_to_start_state_of_both_devices(): + device_1_chat.put_app_to_background() + device_1.open_notification_bar() + device_2_chat.get_back_to_home_view(2) + device_2_home.get_chat_from_home_view(default_username_1).click() + + def device_2_sends_sticker(): + device_2_chat.just_fyi("Sending Sticker in chat") + device_2_chat.show_stickers_button.click() + device_2_chat.sticker_icon.click() + + def device_2_sends_image(): + device_2_chat.just_fyi("Sending Image in chat") + device_2_chat.show_images_button.click() + device_2_chat.allow_button.click() + device_2_chat.first_image_from_gallery.click() + device_2_chat.send_message_button.click() + + def device_2_sends_audio(): + device_2_chat.just_fyi("Sending Audio in chat") + device_2_chat.record_audio_message(message_length_in_seconds=3) + device_2_chat.send_message_button.click() + + sending_list = { + "sticker": device_2_sends_sticker, + "image": device_2_sends_image, + "audio": device_2_sends_audio, + } + + + for key, value in sending_list.items(): + navigate_to_start_state_of_both_devices() + sending_list[key]() + if not device_1.element_by_text_part(key.capitalize()).is_element_displayed(10): + self.errors.append("%s not appeared in Push Notification" % key.capitalize()) + device_1.click_system_back_button() + device_1.get_app_from_background() + else: + device_1.element_by_text_part(key.capitalize()).click() + message = device_2_chat.chat_element_by_text(key) + device_1_chat.set_reaction(key) + if message.emojis_below_message(own=False) != 1: + self.errors.append("Counter of reaction is not set on %s for message receiver!" % key) + device_1_chat.set_reaction(key) + if message.emojis_below_message(own=False) == 1: + self.errors.append("Counter of reaction is not re-set on %s for message receiver!" % key) + + device_2_chat.just_fyi("Sending Emoji/Tag/Links in chat") + ## TODO: add link and tag messages after #11168 is fixed + navigate_to_start_state_of_both_devices() + + emoji_name = random.choice(list(emoji.EMOJI_UNICODE)) + emoji_unicode = emoji.EMOJI_UNICODE[emoji_name] + + device_2_chat.just_fyi("Sending Emoji in chat") + device_2_chat.chat_message_input.send_keys(emoji.emojize(emoji_name)) + device_2_chat.send_message_button.click() + + if not device_1.element_by_text_part(emoji_unicode).is_element_displayed(10): + self.errors.append("Emoji not appeared in Push Notification") + device_1.click_system_back_button() + device_1.get_app_from_background() + else: + device_1.element_by_text_part(emoji_unicode).click() + + emoji_message = device_2_chat.chat_element_by_text(emoji_unicode) + device_1_chat.set_reaction(emoji_unicode, emoji_message=True) + if emoji_message.emojis_below_message(own=False) != 1: + self.errors.append("Counter of reaction is not set on Emoji for message receiver!") + device_1_chat.set_reaction(emoji_unicode, emoji_message=True) + if emoji_message.emojis_below_message(own=False) == 1: + self.errors.append("Counter of reaction is not re-set on Emoji for message receiver!") + + self.errors.verify_no_errors() + @marks.testrail_id(5425) @marks.medium # TODO: should be completed with quoting after fix 9480 diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 860c536fae..0faaae79ca 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -117,7 +117,10 @@ class ProfileBlockContactButton(Button): class ChatElementByText(Text): def __init__(self, driver, text): self.message_text = text - self.message_locator = "//*[starts-with(@text,'%s')]" % text + if text in ["image", "sticker", "audio"]: + self.message_locator = "//android.view.ViewGroup[@content-desc='%s-message']" % text + else: + self.message_locator = "//*[starts-with(@text,'%s')]" % text super().__init__(driver, prefix=self.message_locator, xpath="/ancestor::android.view.ViewGroup[@content-desc='chat-item']") @@ -338,8 +341,6 @@ class CommunityView(HomeView): self.close_button.click() - - class PreviewMessage(ChatElementByText): def __init__(self, driver, text:str): super().__init__(driver, text=text) @@ -572,9 +573,10 @@ class ChatView(BaseView): self.show_images_button = Button(self.driver, accessibility_id="show-photo-icon") self.take_photo_button = Button(self.driver, accessibility_id="take-picture") self.image_from_gallery_button = Button(self.driver, accessibility_id="open-gallery") + self.image_message_in_chat = Button(self.driver, accessibility_id="image-message") self.first_image_from_gallery = Button(self.driver, xpath="//*[@content-desc='open-gallery']/following-sibling::android.view.ViewGroup[1]") - self.image_chat_item = Button(self.driver, accessibility_id="message-image") + self.image_message_in_chat = Button(self.driver, accessibility_id="message-image") self.save_image_button = Button(self.driver, translation_id="save") self.recent_image_in_gallery = Button(self.driver, xpath="//*[contains(@resource-id,'thumbnail')]") @@ -583,6 +585,7 @@ class ChatView(BaseView): xpath="//*[@content-desc='icon']/android.widget.ImageView") #Audio + self.audio_message_in_chat = Button(self.driver, accessibility_id="audio-message") self.audio_message_button = Button(self.driver, accessibility_id="show-audio-message-icon") self.record_audio_button = Button(self.driver, accessibility_id="start-stop-audio-recording-button") self.cancel_audio_message_button = Button(self.driver, accessibility_id="cancel-message-button") @@ -785,10 +788,18 @@ class ChatView(BaseView): self.element_by_text_part(message).long_press_element() self.reply_message_button.click() - def set_reaction(self, message: str, emoji: str = 'thumbs-up'): + def set_reaction(self, message: str, emoji: str = 'thumbs-up', emoji_message=False): self.driver.info("**Setting '%s' reaction**" % emoji) key = emojis[emoji] - self.element_by_text_part(message).long_press_element() + # Audio message is obvious should be tapped not on audio-scroll-line + # so we tap on its below element as exception here (not the case for link/tag message!) + if message == 'audio': + self.audio_message_in_chat_timer.long_press_element() + else: + if not emoji_message: + self.chat_element_by_text(message).long_press_element() + else: + self.element_by_text_part(message).long_press_element() element = Button(self.driver, accessibility_id ='pick-emoji-%s' % key) element.click() element.wait_for_invisibility_of_element()