diff --git a/src/status_im/ui/screens/chat/image/views.cljs b/src/status_im/ui/screens/chat/image/views.cljs index 0feefbcb44..add53d5078 100644 --- a/src/status_im/ui/screens/chat/image/views.cljs +++ b/src/status_im/ui/screens/chat/image/views.cljs @@ -37,12 +37,14 @@ [react/view [react/touchable-highlight {:on-press take-picture} [react/view {:style {:width 44 :height 44 - :align-items :center :justify-content :center}} + :align-items :center :justify-content :center} + :accessibility-label :take-picture} [icons/icon :main-icons/camera {:color colors/black}]]] [react/touchable-highlight {:on-press #(re-frame/dispatch [:chat.ui/open-image-picker]) :style {:margin-top 8}} - [react/view {:width 44 :height 44 - :align-items :center :justify-content :center} + [react/view {:style {:width 44 :height 44 + :align-items :center :justify-content :center} + :accessibility-label :open-gallery} [icons/icon :main-icons/gallery {:color colors/black}]]]]) (defn image-preview [uri first? panel-height] diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index 3cc80e001d..79cd56b22e 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -239,6 +239,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): chat_2 = home_2.get_chat(sender['username']).click() chat_2_receiver_message = chat_2.chat_element_by_text('↓ Incoming transaction') chat_2_receiver_message.decline_transaction.click() + chat_1.element_by_text_part('Transaction declined').wait_for_element(20) for status in chat_2_receiver_message.transaction_status.text, chat_1_sender_message.transaction_status.text: if status != 'Transaction declined': self.errors.append('Wrong state is shown: "Transaction declined" is expected, in fact' @@ -254,7 +255,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): chat_1_request_message = chat_1.chat_element_by_text('↓ Incoming transaction') chat_2_sender_message = chat_2.chat_element_by_text('↑ Outgoing transaction') chat_2_sender_message.decline_transaction.click() - + chat_1.element_by_text_part('Transaction declined').wait_for_element(20) for status in chat_2_sender_message.transaction_status.text, chat_1_request_message.transaction_status.text: if status != 'Transaction declined': self.errors.append('Wrong state is shown: "Transaction declined" is expected, in fact' 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 22161d9d25..68dda65ac1 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -209,6 +209,81 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): self.errors.verify_no_errors() + @marks.testrail_id(6305) + @marks.critical + def test_image_in_one_to_one_send_save_reply(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(), device_2.create_user() + + device_1_home.just_fyi('start 1-1 chat') + device_1_profile, device_2_profile = device_1_home.profile_button.click(), device_2_home.profile_button.click() + device_2_public_key = device_2_profile.get_public_key_and_username() + device_1_public_key, device_1_username = device_1_profile.get_public_key_and_username(return_username=True) + image_description = 'description' + [home.click() for home in [device_1_profile.home_button, device_2_profile.home_button]] + device_1_chat = device_1_home.add_contact(device_2_public_key) + + device_1_home.just_fyi('send image in 1-1 chat from Gallery, check options for sender') + device_1_chat.show_images_button.click() + device_1_chat.image_from_gallery_button.click() + device_1_chat.allow_button.click() + device_1_chat.click_system_back_button() + device_1_chat.chat_message_input.click() + device_1_chat.show_images_button.click() + device_1_chat.first_image_from_gallery.click() + if not device_1_chat.cancel_reply_button.is_element_displayed(): + self.errors.append("Can't cancel sending images, expected image preview is not shown!") + device_1_chat.chat_message_input.set_value(image_description) + device_1_chat.send_message_button.click() + device_1_chat.chat_message_input.click() + for message in device_1_chat.image_chat_item, device_1_chat.chat_element_by_text(image_description): + if not message.is_element_displayed(): + self.errors.append('Image or description is not shown in chat after sending for sender') + if not device_1_chat.image_chat_item.is_element_image_equals_template('message_image_sender.png'): + self.errors.append("Image doesn't match expected template for sender") + device_1_chat.show_images_button.click() + device_1_chat.image_from_gallery_button.click() + device_1_chat.click_system_back_button() + device_1_chat.image_chat_item.long_press_element() + for element in device_1_chat.reply_message_button, device_1_chat.save_image_button: + if not element.is_element_displayed(): + self.errors.append('Save and reply are not available on long-press on own image messages') + if device_1_chat.view_profile_button.is_element_displayed(): + self.errors.append('Options are not shown on long-press on image messages') + + device_2_home.just_fyi('check image, description and options for receiver') + device_2_chat = device_2_home.get_chat(device_1_username).click() + for message in device_2_chat.image_chat_item, device_2_chat.chat_element_by_text(image_description): + if not message.is_element_displayed(): + self.errors.append('Image or description is not shown in chat after sending for receiver') + if not device_2_chat.image_chat_item.is_element_image_equals_template('message_image_receiver.png'): + self.errors.append("Image doesn't match expected template for receiver") + device_2_chat.image_chat_item.long_press_element() + for element in device_2_chat.reply_message_button, device_2_chat.save_image_button, device_2_chat.view_profile_button: + if not element.is_element_displayed(): + self.errors.append('Save and reply are not available on long-press on own image messages') + + device_1_home.just_fyi('save image') + device_1_chat.save_image_button.click() + device_1_chat.show_images_button.click_until_presence_of_element(device_1_chat.image_from_gallery_button) + device_1_chat.image_from_gallery_button.click() + device_1_chat.wait_for_element_starts_with_text('Recent') + if not device_1_chat.recent_image_in_gallery.is_element_displayed(): + self.errors.append('Saved image is not shown in Recent') + + device_2_home.just_fyi('reply to image message') + device_2_chat.reply_message_button.click() + if device_2_chat.quote_username_in_message_input.text != "↪ %s" % device_1_username: + self.errors.append("Username is not displayed in reply quote snippet replying to image message") + reply_to_message_from_receiver = "image reply" + device_2_chat.send_message(reply_to_message_from_receiver) + reply_message = device_2_chat.chat_element_by_text(reply_to_message_from_receiver) + if not reply_message.image_in_reply.is_element_displayed(): + self.errors.append("Image is not displayed in reply") + + self.errors.verify_no_errors() + @marks.testrail_id(5316) @marks.critical def test_add_to_contacts(self): diff --git a/test/appium/tests/atomic/chats/test_public.py b/test/appium/tests/atomic/chats/test_public.py index cf4d9bbf5d..bd8c2eb057 100644 --- a/test/appium/tests/atomic/chats/test_public.py +++ b/test/appium/tests/atomic/chats/test_public.py @@ -219,8 +219,10 @@ class TestPublicChatSingleDevice(SingleDeviceTestCase): if not chat.user_name_text.text == tag_message: self.driver.fail('Could not redirect a user to a public chat tapping the tag message.') home_view = chat.get_back_to_home_view() - if not home_view.chat_name_text.text == tag_message: + if not home_view.element_by_text(tag_message).is_element_displayed(): self.driver.fail('Could not find the public chat in user chat list.') + #if not home_view.chat_name_text.text == tag_message: + @marks.testrail_id(6205) @marks.high diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index ed4051414b..b8345c0c1c 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -121,6 +121,16 @@ class ReplyMessageButton(BaseButton): super(ReplyMessageButton, self).__init__(driver) self.locator = self.Locator.text_selector("Reply") +class SaveImageButton(BaseButton): + def __init__(self, driver): + super(SaveImageButton, self).__init__(driver) + self.locator = self.Locator.text_selector("Save") + + +class ImageInRecentInGalleryElement(BaseElement): + def __init__(self, driver): + super(ImageInRecentInGalleryElement, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[contains(@resource-id,"thumbnail")]') class ProfileDetailsOtherUser(BaseButton): def __init__(self, driver): @@ -229,6 +239,26 @@ class StickerIcon(BaseButton): super(StickerIcon, self).__init__(driver) self.locator = self.Locator.accessibility_id('sticker-icon') +class ShowImagesButton(BaseButton): + def __init__(self, driver): + super(ShowImagesButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('show-photo-icon') + + +class TakePhotoButton(BaseButton): + def __init__(self, driver): + super(TakePhotoButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('take-picture') + +class ImageFromGalleryButton(BaseButton): + def __init__(self, driver): + super(ImageFromGalleryButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('open-gallery') + +class FirstElementFromGalleryButton(BaseButton): + def __init__(self, driver): + super(FirstElementFromGalleryButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@content-desc="open-gallery"]/../following-sibling::android.view.ViewGroup[1]') class ViewProfileButton(BaseButton): def __init__(self, driver): @@ -316,6 +346,18 @@ class ChatElementByText(BaseText): return StatusText(self.driver, self.locator.value).wait_for_element(10) + @property + def image_in_reply(self): + class ImageInReply(BaseElement): + def __init__(self, driver, parent_locator): + super(ImageInReply, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + parent_locator + "//android.widget.ImageView") + try: + return ImageInReply(self.driver, self.locator.value) + except NoSuchElementException: + return '' + @property def timestamp_message(self): class TimeStampText(BaseText): @@ -458,6 +500,11 @@ class ChatItem(BaseElement): super().__init__(driver) self.locator = self.Locator.xpath_selector('//*[@content-desc="chat-item"]') +class ImageChatItem(BaseElement): + def __init__(self, driver): + super().__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@content-desc="chat-item"]//android.widget.ImageView') + class HistoryTimeMarker(BaseText): def __init__(self, driver, marker='Today'): @@ -547,6 +594,17 @@ class ChatView(BaseView): self.get_stickers = GetStickers(self.driver) self.sticker_icon = StickerIcon(self.driver) + # Images + self.show_images_button = ShowImagesButton(self.driver) + self.take_photo_button = TakePhotoButton(self.driver) + self.image_from_gallery_button = ImageFromGalleryButton(self.driver) + self.first_image_from_gallery = FirstElementFromGalleryButton(self.driver) + self.image_chat_item = ImageChatItem(self.driver) + self.save_image_button = SaveImageButton(self.driver) + self.recent_image_in_gallery = ImageInRecentInGalleryElement(self.driver) + + + self.chat_options = ChatMenuButton(self.driver) self.members_button = MembersButton(self.driver) self.delete_chat_button = DeleteChatButton(self.driver) diff --git a/test/appium/views/elements_templates/message_image_receiver.png b/test/appium/views/elements_templates/message_image_receiver.png new file mode 100644 index 0000000000..868c3737ca Binary files /dev/null and b/test/appium/views/elements_templates/message_image_receiver.png differ diff --git a/test/appium/views/elements_templates/message_image_sender.png b/test/appium/views/elements_templates/message_image_sender.png new file mode 100644 index 0000000000..a78db0ee95 Binary files /dev/null and b/test/appium/views/elements_templates/message_image_sender.png differ