diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 3ba721ff8b..9a5532d9bf 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -1,18 +1,15 @@ import random -import time from datetime import timedelta import emoji import pytest from dateutil import parser +from selenium.common.exceptions import NoSuchElementException from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase -from views.sign_in_view import SignInView from views.chat_view import CommunityView -from views.base_view import BaseView -from views.chat_view import ChatView -from selenium.common.exceptions import NoSuchElementException +from views.sign_in_view import SignInView @pytest.mark.xdist_group(name="three_1") @@ -313,7 +310,8 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): self.home.communities_tab.click_until_presence_of_element(self.home.plus_button) self.community_name = self.home.get_random_chat_name() self.channel_name = self.home.get_random_chat_name() - self.community = self.home.create_community(name=self.community_name, description='test description', require_approval=False) + self.community = self.home.create_community(name=self.community_name, description='test description', + require_approval=False) self.channel = self.community.add_channel(name=self.channel_name) @marks.testrail_id(702846) @@ -328,39 +326,27 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): if not self.channel.chat_element_by_text(text_message).is_element_displayed(30): self.drivers[0].fail("Not navigated to channel view after reopening app") - # @marks.testrail_id(702847) - # # TODO long press and assertion of text in input field is currently not working on e2e builds. needs to be investigated - # @marks.skip('needs to be refactored') - # def test_community_copy_and_paste_message_in_chat_input(self): - # message_text = {'text_message': 'mmmeowesage_text'} - # formatted_message = {'message_with_link': 'https://status.im' - # } - # message_input = self.channel.chat_message_input - # if not message_input.is_element_displayed(): - # self.home.communities_tab.double_click() - # self.home.get_chat(self.community_name, community=True).click() - # self.community.get_chat(self.channel_name).click() - # message_input.send_keys(message_text['text_message']) - # self.channel.send_message_button.click() - # - # self.channel.copy_message_text(message_text['text_message']) - # - # message_input.paste_text_from_clipboard() - # if message_input.text != message_text['text_message']: - # self.errors.append('Message %s text was not copied in a public chat' % message_text['text_message']) - # message_input.clear() - # - # for message in formatted_message: - # message_input.send_keys(formatted_message[message]) - # self.channel.send_message_button.click() - # - # self.channel.copy_message_text(formatted_message[message]) - # message_input.paste_text_from_clipboard() - # if message_input.text != formatted_message[message]: - # self.errors.append('Message %s text was not copied in community channel' % formatted_message[message]) - # message_input.clear() - # - # self.errors.verify_no_errors() + @marks.testrail_id(702742) + def test_community_copy_and_paste_message_in_chat_input(self): + message_texts = ['mmmeowesage_text', 'https://status.im'] + + message_input = self.channel.chat_message_input + if not message_input.is_element_displayed(): + self.home.communities_tab.double_click() + self.home.get_chat(self.community_name, community=True).click() + self.community.get_chat(self.channel_name).click() + + for message in message_texts: + message_input.send_keys(message) + self.channel.send_message_button.click() + + self.channel.copy_message_text(message) + message_input.paste_text_from_clipboard() + if message_input.text != message: + self.errors.append('Message %s text was not copied in community channel' % message) + message_input.clear() + + self.errors.verify_no_errors() @pytest.mark.xdist_group(name="two_2") @@ -403,7 +389,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): community_view.get_channel(self.channel_name).click() self.channel_2 = self.home_2.get_chat_view() - @marks.testrail_id(702838) @marks.xfail(reason="blocked by 14797") def test_community_message_send_check_timestamps_sender_username(self): @@ -443,7 +428,8 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): if not self.channel_2.element_by_translation_id('message-deleted-for-everyone').is_element_displayed(30): self.errors.append("System message about deletion for everyone is not displayed") - self.home_2.just_fyi('Deleting message for me. Checking that message is deleted only for the author of the message') + self.home_2.just_fyi( + 'Deleting message for me. Checking that message is deleted only for the author of the message') self.channel_2.send_message(message_to_delete_for_me) self.channel_2.delete_message_in_chat(message_to_delete_for_me, everyone=False) if not self.channel_2.chat_element_by_text(message_to_delete_for_me).is_element_disappeared(30): @@ -464,13 +450,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): if not channel.chat_element_by_text(emoji_unicode).is_element_displayed(30): self.errors.append('Message with emoji was not sent or received in community channel') - # Commented as paste_text_from_clipboard() method doesn't work any more for some reason. Needs to be investigated - # self.channel_1.just_fyi("Can copy and paste emojis") - # self.channel_1.copy_message_text(emoji_unicode) - # self.channel_1.chat_message_input.click() - # self.channel_1.chat_message_input.paste_text_from_clipboard() - # if self.channel_1.chat_message_input.text != emoji_unicode: - # self.errors.append('Emoji message was not copied') + self.channel_1.just_fyi("Can copy and paste emojis") + self.channel_1.copy_message_text(emoji_unicode) + self.channel_1.chat_message_input.paste_text_from_clipboard() + if self.channel_1.chat_message_input.text != emoji_unicode: + self.errors.append('Emoji message was not copied') self.channel_1.just_fyi("Can reply to emojis") self.channel_2.quote_message(emoji_unicode) @@ -587,4 +571,3 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): if community.is_element_displayed(): self.errors.append('Community is still shown in the list after leave') self.errors.verify_no_errors() - diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 4c71160850..8f493569c6 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta from time import sleep import dateutil.parser +from appium.webdriver.common.touch_action import TouchAction from selenium.common.exceptions import NoSuchElementException, TimeoutException from tests import emojis @@ -629,6 +630,18 @@ class PinnedMessagesList(BaseElement): return pinned_by_element +class ChatMessageInput(EditBox): + def __init__(self, driver): + super().__init__(driver, accessibility_id="chat-message-input") + + def paste_text_from_clipboard(self): + action = TouchAction(self.driver) + location = self.find_element().location + x, y = location['x'], location['y'] + action.long_press(x=x + 250, y=y).release().perform() # long press + action.tap(x=x + 50, y=y - 50).release().perform() # tap Paste + + class ChatView(BaseView): def __init__(self, driver): super().__init__(driver) @@ -657,7 +670,7 @@ class ChatView(BaseView): xpath="//androidx.appcompat.widget.LinearLayoutCompat") # Chat input - self.chat_message_input = EditBox(self.driver, accessibility_id="chat-message-input") + self.chat_message_input = ChatMessageInput(self.driver) self.cancel_reply_button = Button(self.driver, accessibility_id="reply-cancel-button") self.quote_username_in_message_input = EditBox(self.driver, xpath="//*[@content-desc='reply-cancel-button']/preceding::android.widget.TextView[2]") @@ -774,7 +787,6 @@ class ChatView(BaseView): self.pin_limit_popover = BaseElement(self.driver, translation_id="pin-limit-reached") self.view_pinned_messages_button = Button(self.driver, accessibility_id="pinned-banner") - def get_outgoing_transaction(self, account=None, transaction_value=None) -> object: if account is None: account = self.status_account_name