diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index ee2caa8554..abf1735921 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -1131,9 +1131,11 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): if not element.is_element_displayed(): self.errors.append('Was not redirected to user profile after tapping on mention!') - home_1.just_fyi('check that PN is received and after tap you are redirected to public chat') + home_1.just_fyi('check that PN is received and after tap you are redirected to public chat, mention is highligted') home_1.open_notification_bar() home_1.element_by_text_part(username_2).click() + if home_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth').is_element_differs_from_template('mentioned.png', 2): + self.errors.append('Mention is not highlighted!') chat_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth','button').click() if not profile_1.contacts_button.is_element_displayed(): self.errors.append('Was not redirected to own profile after tapping on mention of myself from another user!') diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 2dc6028441..0bdabc8540 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -1,4 +1,6 @@ import time +import random +import emoji from tests import marks from tests.users import basic_user, dummy_user, ens_user_ropsten, ens_user, ens_user_message_sender @@ -837,6 +839,26 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): if public_replied_message.replied_message_text != message_from_sender: self.errors.append("Reply is not present in message received in public chat") + device_1.just_fyi('Can reply to link') + link_message, reply = 'Test with link: https://status.im/', 'reply to link' + chat_public_1.send_message(link_message) + chat_public_2.quote_message(link_message[:10]) + chat_public_2.send_message(reply) + public_replied_message = chat_public_1.chat_element_by_text(reply) + if public_replied_message.replied_message_text != link_message: + self.errors.append("Reply for '%s' not present in message received in public chat" % link_message) + + device_1.just_fyi('Can reply to emoji message') + reply = 'reply to emoji' + emoji_message = random.choice(list(emoji.EMOJI_UNICODE)) + emoji_unicode = emoji.EMOJI_UNICODE[emoji_message] + chat_public_1.send_message(emoji.emojize(emoji_message)) + chat_public_2.quote_message(emoji.emojize(emoji_message)) + chat_public_2.send_message(reply) + public_replied_message = chat_public_1.chat_element_by_text(reply) + if public_replied_message.replied_message_text != emoji_unicode: + self.errors.append("Reply for '%s' emoji not present in message received in public chat" % emoji_unicode) + self.errors.verify_no_errors() @marks.testrail_id(6315) diff --git a/test/appium/tests/atomic/chats/test_group_chat.py b/test/appium/tests/atomic/chats/test_group_chat.py index 47417edab8..2bbeadfc54 100644 --- a/test/appium/tests/atomic/chats/test_group_chat.py +++ b/test/appium/tests/atomic/chats/test_group_chat.py @@ -1,16 +1,17 @@ from tests import marks from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase -from tests.users import transaction_senders, basic_user +from tests.users import transaction_senders, ens_user from views.sign_in_view import SignInView from views.chat_view import ChatView from time import sleep +import random, emoji class TestGroupChatMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(3994) @marks.high - def test_create_new_group_chat_messaging_pn_delived(self): + def test_create_new_group_chat_messaging_pn_delivered(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(enable_notifications=True) @@ -407,6 +408,117 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase): self.errors.verify_no_errors() + @marks.testrail_id(6327) + @marks.medium + def test_nicknames_ens_group_chats(self): + self.create_drivers(2) + home_1 = SignInView(self.drivers[0]).create_user() + home_2 = SignInView(self.drivers[1]).recover_access(ens_user['passphrase']) + profile_1, profile_2 = [home.profile_button.click() for home in (home_1, home_2)] + key_1, username_1 = profile_1.get_public_key_and_username(return_username=True) + ens, full_ens, username_2 = ens_user['ens'], '@%s' % ens_user['ens'], ens_user['username'] + [profile.switch_network() for profile in (profile_1, profile_2)] + + home_2.just_fyi('Set ENS') + profile_2 = home_2.profile_button.click() + dapp_view = profile_2.ens_usernames_button.click() + dapp_view.element_by_text('Get started').click() + dapp_view.ens_name_input.set_value(ens) + dapp_view.check_ens_name.click_until_presence_of_element(dapp_view.element_by_translation_id("ens-got-it")) + dapp_view.element_by_translation_id("ens-got-it").click() + home_2.home_button.click() + + home_1.just_fyi('Set nickname, using emojis, special chars and cyrrilic chars without adding to contact') + emoji_message = random.choice(list(emoji.EMOJI_UNICODE)) + emoji_unicode = emoji.EMOJI_UNICODE[emoji_message] + special_char, cyrrilic = '"£¢€¥~`•|√π¶∆×°™®©%$@', 'стат' + nickname_to_set = emoji.emojize(emoji_message) + special_char + cyrrilic + nickname_expected = emoji_unicode + special_char + cyrrilic + chat_1 = home_1.add_contact(ens, add_in_contacts=False, nickname=nickname_to_set) + if chat_1.user_name_text.text != nickname_expected: + self.errors.append('Expected special char nickname %s does not match actual %s' % (nickname_expected, chat_1.user_name_text.text)) + + home_1.just_fyi('Can remove nickname without adding to contact') + chat_1.chat_options.click() + chat_1.view_profile_button.click() + chat_1.profile_nickname_button.click() + chat_1.nickname_input_field.clear() + chat_1.element_by_text('Done').click() + chat_1.back_button.click() + if chat_1.user_name_text.text != full_ens: + self.errors.append('Nickname was not removed! real chat name is %s instead of %s' % (chat_1.user_name_text.text, full_ens)) + + home_1.just_fyi('Adding ENS user to contacts and start group chat with him') + group_name = 'ens_group' + chat_1.add_to_contacts.click() + chat_2 = home_2.add_contact(key_1) + chat_2.send_message("first") + chat_2.home_button.click() + chat_1.home_button.click() + chat_1 = home_1.create_group_chat([full_ens], group_name) + chat_2 = home_2.get_chat(group_name).click() + chat_2.join_chat_button.click() + + home_1.just_fyi('Check ENS and in group chat and suggestions list') + chat_1.element_by_text_part(full_ens).wait_for_visibility_of_element(60) + chat_1.select_mention_from_suggestion_list(ens, typed_search_pattern=ens[:2]) + if chat_1.chat_message_input.text != '@' + ens + ' ': + self.errors.append( + 'ENS username is not resolved in chat input after selecting it in mention suggestions list!') + additional_text = 'and more' + chat_1.send_as_keyevent(additional_text) + chat_1.send_message_button.click() + message_text = '%s %s' % (full_ens, additional_text) + if not chat_1.chat_element_by_text(message_text).is_element_displayed(): + self.errors.append("ENS name is not resolved on sent message") + chat_1 = home_1.get_chat_view() + + home_1.just_fyi('Set nickname via group info and check that can mention by nickname /username in group chat') + nickname = 'funny_bunny' + device_2_options = chat_1.get_user_options(full_ens) + device_2_options.view_profile_button.click() + chat_1.set_nickname(nickname) + if not chat_1.element_by_text(nickname).is_element_displayed(): + self.errors.append('Nickname is not shown in profile view after setting from froup info') + chat_1.back_button.click() + if not chat_1.element_by_text(nickname).is_element_displayed(): + self.errors.append('Nickname is not shown in group info view after setting from froup info') + chat_1.back_button.click() + message_text = '%s %s' % (nickname, additional_text) + if not chat_1.chat_element_by_text(message_text).is_element_displayed(): + self.errors.append("ENS name was not replaced with nickname on sent message") + chat_1.chat_message_input.send_keys('@') + if not chat_1.element_by_text('%s %s' %(nickname, full_ens)).is_element_displayed(): + self.errors.append("ENS name with nickname is not shown in mention input after set") + if not chat_1.element_by_text(username_2).is_element_displayed(): + self.errors.append("3-random name is not shown in mention input after set from group info") + chat_1.chat_message_input.clear() + chat_1.select_mention_from_suggestion_list('%s %s' %(nickname, full_ens), typed_search_pattern=username_2[:2]) + if chat_1.chat_message_input.text != '@' + ens + ' ': + self.errors.append('ENS is not resolved in chat input after setting nickname in mention suggestions list (search by 3-random name)!') + chat_1.chat_message_input.clear() + chat_1.select_mention_from_suggestion_list('%s %s' % (nickname, full_ens), typed_search_pattern=nickname[:2]) + if chat_1.chat_message_input.text != '@' + ens + ' ': + self.errors.append('ENS is not resolved in chat input after setting nickname in mention suggestions list (search by nickname)!') + chat_1.chat_message_input.clear() + + home_1.just_fyi('Can delete nickname via group info and recheck received messages') + device_2_options = chat_1.get_user_options(full_ens) + device_2_options.view_profile_button.click() + chat_1.profile_nickname_button.click() + chat_1.nickname_input_field.clear() + chat_1.element_by_text('Done').click() + chat_1.back_button.click() + chat_1.back_button.click() + message_text = '%s %s' % (full_ens, additional_text) + if not chat_1.chat_element_by_text(message_text).is_element_displayed(): + self.errors.append("ENS name is not resolved on sent message after removing nickname") + chat_1.chat_message_input.send_keys('@') + if chat_1.element_by_text_part(nickname).is_element_displayed(): + self.errors.append("Nickname is shown in group chat after removing!") + + self.errors.verify_no_errors() + @marks.testrail_id(5752) @marks.medium def test_block_and_unblock_user_from_group_chat_via_group_info(self): diff --git a/test/appium/tests/atomic/chats/test_public.py b/test/appium/tests/atomic/chats/test_public.py index 2c386dbe70..1a68527c01 100644 --- a/test/appium/tests/atomic/chats/test_public.py +++ b/test/appium/tests/atomic/chats/test_public.py @@ -64,10 +64,14 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): self.create_drivers(2) driver_2 = self.drivers[1] home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() + profile_1 = home_1.profile_button.click() + username_1 = profile_1.default_username_text.text + profile_1.home_button.click() chat_name = home_1.get_random_chat_name() chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name) - home_1.get_back_to_home_view() + chat_1.send_message('пиу') + chat_1.home_button.click() message, message_2 = 'test message', 'test message2' chat_2.send_message(message) @@ -77,6 +81,14 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): chat_element = home_1.get_chat('#' + chat_name) if not chat_element.new_messages_public_chat.is_element_displayed(): self.errors.append('New messages counter is not shown in public chat') + + home_1.just_fyi("Check unread message counter when mentioned in public chat") + chat_2 = home_2.get_chat_view() + chat_2.select_mention_from_suggestion_list(username_1, username_1[:2]) + chat_2.send_message_button.click() + if chat_element.new_messages_counter.text == '1': + self.errors.append('Counter is not shown for mention in public chat') + chat_element.click() home_1.home_button.double_click() diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index 097e8cd207..420e68287a 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -4,7 +4,7 @@ import os import time from timeit import timeit -from PIL import Image, ImageChops +from PIL import Image, ImageChops, ImageStat from appium.webdriver.common.mobileby import MobileBy from appium.webdriver.common.touch_action import TouchAction from selenium.common.exceptions import NoSuchElementException @@ -205,11 +205,23 @@ class BaseElement(object): screen = Image.open(BytesIO(base64.b64decode(self.find_element().screenshot_as_base64))) screen.save(full_path_to_file) - def is_element_image_equals_template(self, file_name: str = ''): + def is_element_image_equals_template(self, file_name: str = '', diff: int = 0): if file_name: self.template = file_name return not ImageChops.difference(self.image, self.template).getbbox() + def is_element_differs_from_template(self, file_name: str = '', diff: int = 0): + if file_name: + self.template = file_name + result = False + difference = ImageChops.difference(self.image, self.template) + stat = ImageStat.Stat(difference) + diff_ratio = sum(stat.mean) / (len(stat.mean) * 255) + if diff_ratio*100 > diff: + self.driver.info('Image differs from template to %s percents' % str(diff_ratio*100)) + result = True + return result + def is_element_image_similar_to_template(self, template_path: str = ''): image_template = os.sep.join(__file__.split(os.sep)[:-1]) + '/elements_templates/%s' % template_path template = imagehash.average_hash(Image.open(image_template)) diff --git a/test/appium/views/elements_templates/mentioned.png b/test/appium/views/elements_templates/mentioned.png new file mode 100644 index 0000000000..90416c37c5 Binary files /dev/null and b/test/appium/views/elements_templates/mentioned.png differ