Skip to content

Commit

Permalink
e2e: image test
Browse files Browse the repository at this point in the history
  • Loading branch information
churik committed May 15, 2023
1 parent 4b2d62e commit 7ef4660
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 84 deletions.
11 changes: 6 additions & 5 deletions src/status_im2/contexts/chat/composer/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@
(defn image-button
[props animations insets]
[quo/button
{:on-press #(open-photo-selector props animations insets)
:icon true
:type :outline
:size 32
:style {:margin-right 12}}
{:on-press #(open-photo-selector props animations insets)
:accessibility-label :open-images-button
:icon true
:type :outline
:size 32
:style {:margin-right 12}}
:i/image])

(defn reaction-button
Expand Down
75 changes: 0 additions & 75 deletions test/appium/tests/critical/chats/test_1_1_public_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,81 +256,6 @@ def test_1_1_chat_audio_message_with_push(self):

self.errors.verify_no_errors()

@marks.testrail_id(6305)
def test_1_1_chat_image_send_save_reply(self):
self.home_1.get_app_from_background()
self.home_2.get_app_from_background()

self.home_1.home_button.click()
self.home_1.get_chat(username=self.default_username_2).click()

self.home_1.just_fyi('send image in 1-1 chat from Gallery, check options for sender')
image_description = 'description'
self.chat_1.show_images_button.click()
self.chat_1.allow_button.click_if_shown()
self.chat_1.first_image_from_gallery.click()
if not self.chat_1.cancel_send_image_button.is_element_displayed():
self.errors.append("Can't cancel sending images, expected image preview is not shown!")
self.chat_1.chat_message_input.set_value(image_description)
self.chat_1.send_message_button.click()
self.chat_1.chat_message_input.click()
for message in self.chat_1.image_message_in_chat, self.chat_1.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')
self.chat_1.image_message_in_chat.long_press_element()
for element in self.chat_1.reply_message_button, self.chat_1.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 self.chat_1.view_profile_button.is_element_displayed():
self.errors.append('"View profile" is shown on long-press on own message')

self.home_2.just_fyi('check image, description and options for receiver')
self.home_2.get_chat(self.default_username_1).click()
for message in self.chat_2.image_message_in_chat, self.chat_2.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')

self.home_2.just_fyi('check options on long-press image for receiver')
self.chat_2.image_message_in_chat.long_press_element()
for element in (self.chat_2.reply_message_button, self.chat_2.save_image_button):
if not element.is_element_displayed():
self.errors.append('Save and reply are not available on long-press on received image messages')

self.home_1.just_fyi('save image')
self.chat_1.save_image_button.click_until_presence_of_element(self.chat_1.show_images_button)
self.chat_1.show_images_button.click_until_presence_of_element(self.chat_1.image_from_gallery_button)
self.chat_1.image_from_gallery_button.click_until_presence_of_element(self.chat_1.recent_image_in_gallery)
if not self.chat_1.recent_image_in_gallery.is_element_displayed():
self.errors.append('Saved image is not shown in Recent')
self.home_1.click_system_back_button(2)

self.home_2.just_fyi('reply to image message')
self.chat_2.reply_message_button.click()
if self.chat_2.quote_username_in_message_input.text != "↪ Replying to %s" % self.default_username_1:
self.errors.append("Username is not displayed in reply quote snippet replying to image message")
reply_to_message_from_receiver = "image reply"
self.chat_2.send_message(reply_to_message_from_receiver)
reply_message = self.chat_2.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.home_2.just_fyi('check share and save options on opened image')
self.chat_2.image_message_in_chat.scroll_to_element(direction='up')
self.chat_2.image_message_in_chat.click_until_presence_of_element(self.chat_2.share_image_icon_button)
self.chat_2.share_image_icon_button.click()
self.chat_2.share_via_messenger()
if not self.chat_2.image_in_android_messenger.is_element_displayed():
self.errors.append("Can't share image")
self.chat_2.click_system_back_button_until_element_is_shown(element=self.chat_2.save_image_icon_button)
self.chat_2.save_image_icon_button.click()
self.chat_2.show_images_button.click()
self.chat_2.allow_button.wait_and_click()

if not self.chat_2.first_image_from_gallery.is_element_image_similar_to_template('saved.png'):
self.errors.append("New picture was not saved!")

self.errors.verify_no_errors()

@marks.testrail_id(5387)
# think about priority of this
def test_1_1_chat_delete_via_delete_button_relogin(self):
Expand Down
53 changes: 53 additions & 0 deletions test/appium/tests/critical/test_public_chat_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,59 @@ def test_community_message_delete(self):
self.errors.append("Deleted for me message is deleted all channel members")
self.errors.verify_no_errors()

@marks.testrail_id(702859)
def test_1_1_chat_image_send_reply(self):

self.home_1.just_fyi('Send image in 1-1 chat from Gallery')
image_description = 'description'
self.channel_1.show_images_button.click()
self.channel_1.allow_button.click_if_shown()
self.channel_1.first_image_from_gallery.click()
self.channel_1.images_confirm_selection_button.click()
self.channel_1.chat_message_input.set_value(image_description)
self.channel_1.send_message_button.click()
self.channel_1.chat_message_input.click()
self.channel_1.chat_element_by_text(image_description).image_in_message.click()
self.channel_1.click_system_back_button()

# TODO: options for image are still WIP; add case with edit description of image and after 15901 fix
# self.home_2.just_fyi('check image, description and options for receiver')
# self.channel_2.chat_element_by_text(image_description).image_in_message.click()
# self.home_1.just_fyi('save image')
# self.chat_1.save_image_button.click_until_presence_of_element(self.chat_1.show_images_button)
# self.chat_1.show_images_button.click_until_presence_of_element(self.chat_1.image_from_gallery_button)
# self.chat_1.image_from_gallery_button.click_until_presence_of_element(self.chat_1.recent_image_in_gallery)
# if not self.chat_1.recent_image_in_gallery.is_element_displayed():
# self.errors.append('Saved image is not shown in Recent')
# self.home_1.click_system_back_button(2)
# self.home_2.just_fyi('check share and save options on opened image')
# self.chat_2.image_message_in_chat.scroll_to_element(direction='up')
# self.chat_2.image_message_in_chat.click_until_presence_of_element(self.chat_2.share_image_icon_button)
# self.chat_2.share_image_icon_button.click()
# self.chat_2.share_via_messenger()
# if not self.chat_2.image_in_android_messenger.is_element_displayed():
# self.errors.append("Can't share image")
# self.chat_2.click_system_back_button_until_element_is_shown(element=self.chat_2.save_image_icon_button)
# self.chat_2.save_image_icon_button.click()
# self.chat_2.show_images_button.click()
# self.chat_2.allow_button.wait_and_click()
#
# if not self.chat_2.first_image_from_gallery.is_element_image_similar_to_template('saved.png'):
# self.errors.append("New picture was not saved!")
#
# self.channel_2.chat_element_by_text(image_description).image_in_message.save_new_screenshot_of_element('images_test.png')

self.channel_2.just_fyi("Can reply to images")
self.channel_2.quote_message(image_description)
message_text = 'reply to image'
self.channel_2.chat_message_input.send_keys(message_text)
self.channel_2.send_message_button.click()
chat_element_1 = self.channel_1.chat_element_by_text(message_text)
if not chat_element_1.is_element_displayed(sec=60) or chat_element_1.replied_message_text != 'Image':
self.errors.append('Reply message was not received by the sender')

self.errors.verify_no_errors()

@marks.testrail_id(702840)
def test_community_emoji_send_copy_paste_reply(self):
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
Expand Down
16 changes: 12 additions & 4 deletions test/appium/views/chat_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def wait_for_sent_state(self, wait_time=30):
return BaseElement(self.driver, prefix=self.locator,
xpath="//*[@content-desc='message-sent']").is_element_displayed(wait_time)


@property
def uncollapse(self) -> bool:
class Collapse(Button):
Expand Down Expand Up @@ -274,6 +273,15 @@ def text(self):

return EmojisNumber(self.driver, self.locator)

@property
def image_in_message(self):
try:
self.driver.info("Trying to access image inside message with text '%s'" % self.message_text)
ChatElementByText(self.driver, self.message_text).wait_for_sent_state(60)
return Button(self.driver, xpath='%s//android.view.ViewGroup/android.widget.ImageView' % self.locator)
except NoSuchElementException:
self.driver.fail("No image is found in message!")

@property
def pinned_by_label(self):
class PinnedByLabelText(Text):
Expand Down Expand Up @@ -728,11 +736,11 @@ def __init__(self, driver):
self.sticker_message = Button(self.driver, accessibility_id="sticker-message")

# Images
self.show_images_button = Button(self.driver, accessibility_id="show-photo-icon")
self.show_images_button = Button(self.driver, accessibility_id="open-images-button")
self.take_photo_button = Button(self.driver, accessibility_id="take-picture")
self.image_from_gallery_button = Button(self.driver, accessibility_id="open-gallery")
self.first_image_from_gallery = Button(self.driver,
xpath="//*[@content-desc='open-gallery']/following-sibling::android.view.ViewGroup[1]")
self.first_image_from_gallery = Button(self.driver, accessibility_id="image-0")
self.images_confirm_selection_button = Button(self.driver, accessibility_id="confirm-selection")
self.images_area_in_gallery = Button(self.driver,
xpath="//*[@content-desc='open-gallery']/following-sibling::android.view.ViewGroup[1]")
self.image_message_in_chat = Button(self.driver, accessibility_id="image-message")
Expand Down

0 comments on commit 7ef4660

Please sign in to comment.