diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index abf19d7635..2a333f291c 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -6,6 +6,7 @@ from tests import marks, bootnode_address, mailserver_address, camera_access_err from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase from tests.users import transaction_senders, basic_user, ens_user, ens_user_ropsten from views.sign_in_view import SignInView +from time import time class TestProfileSingleDevice(SingleDeviceTestCase): @@ -115,7 +116,7 @@ class TestProfileSingleDevice(SingleDeviceTestCase): sign_in_view.just_fyi("Enable mobile network to see popup and stop syncing") sign_in_view.toggle_mobile_data() sign_in_view.wait_for_element_starts_with_text('Stop syncing').click() - if not sign_in_view.wait_for_element_starts_with_text(offline_banner_text, 60): + if not sign_in_view.wait_for_element_starts_with_text(offline_banner_text, 120): self.driver.fail('No popup about offline history is shown') sign_in_view.element_by_text_part(offline_banner_text).click() for item in offline_banner_text, "Start syncing", "Go to settings": @@ -1072,7 +1073,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(6226) @marks.critical - def test_ens_in_public_and_1_1_chats(self): + def test_ens_and_nickname_in_public_and_1_1_chats(self): self.create_drivers(2) device_1, device_2 = self.drivers[0], self.drivers[1] sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2) @@ -1108,34 +1109,58 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): chat_1 = home_1.join_public_chat(chat_name) chat_1.get_back_to_home_view() home_1.profile_button.click() + ens_name = '@' + user_1['ens'] profile_1.element_by_text('Your ENS name').click() - if profile_1.username_in_ens_chat_settings_text.text != '@' + user_1['ens']: + if profile_1.username_in_ens_chat_settings_text.text != ens_name: self.errors.append('ENS username is not shown in ENS usernames Chat Settings after enabling') profile_1.back_button.click() profile_1.home_button.click() home_1.get_chat('#' + chat_name).click() message_text_2 = 'message test text 1' chat_1.send_message(message_text_2) - if not chat_2.wait_for_element_starts_with_text('@' + user_1['ens']): + if not chat_2.wait_for_element_starts_with_text(ens_name): self.errors.append('ENS username is not shown in public chat') home_2.just_fyi('check that ENS name is shown in 1-1 chat without adding user as contact in header, profile, options') chat_2.get_back_to_home_view() chat_2_one_to_one = home_2.add_contact(ens_user['public_key'], False) - if chat_2_one_to_one.user_name_text.text != '@' + user_1['ens']: + if chat_2_one_to_one.user_name_text.text != ens_name: self.errors.append('ENS username is not shown in 1-1 chat header') chat_2_one_to_one.chat_options.click() - if not chat_2_one_to_one.element_by_text('@' + user_1['ens']).is_element_displayed(): + if not chat_2_one_to_one.element_by_text(ens_name).is_element_displayed(): self.errors.append('ENS username is not shown in 1-1 chat options') chat_2_one_to_one.view_profile_button.click() - if not chat_2_one_to_one.element_by_text('@' + user_1['ens']).is_element_displayed(): + if not chat_2_one_to_one.element_by_text(ens_name).is_element_displayed(): self.errors.append('ENS username is not shown in user profile') home_2.just_fyi('add user to contacts and check that ENS name is shown in contact') chat_2_one_to_one.profile_add_to_contacts.click() profile_2 = chat_2_one_to_one.profile_button.click() - profile_2.contacts_button.click() - if not profile_2.element_by_text('@' + user_1['ens']).is_element_displayed(): - self.errors.append('ENS username is not shown in contacts') + profile_2.open_contact_from_profile(ens_name) + + home_2.just_fyi('set nickname and recheck username in 1-1 header, profile, options, contacts') + nickname = 'test user' + str(round(time())) + chat_2.set_nickname(nickname) + profile_2.back_button.click() + for name in (nickname, ens_name): + if not profile_2.element_by_text(name).is_element_displayed(): + self.errors.append('%s is not shown in contact list' % name) + profile_2.home_button.click() + if not chat_2_one_to_one.element_by_text(nickname).is_element_displayed(): + self.errors.append('Nickname for user with ENS is not shown in user profile') + chat_2.back_button.click() + if chat_2_one_to_one.user_name_text.text != nickname: + self.errors.append('Nickname for user with ENS is not shown in 1-1 chat header') + chat_2_one_to_one.chat_options.click() + if not chat_2_one_to_one.element_by_text(nickname).is_element_displayed(): + self.errors.append('Nickname for user with ENS is not shown in 1-1 chat options') + + home_2.just_fyi('check nickname in public chat') + chat_2.get_back_to_home_view() + home_2.get_chat('#' + chat_name).click() + chat_element = chat_2.chat_element_by_text(message_text_2) + chat_element.find_element() + if chat_element.username.text != '%s %s' % (nickname, ens_name): + self.errors.append('Nickname for user with ENS is not shown in public chat') self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 8d4e5a2bee..74011b60b6 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -366,14 +366,23 @@ class TestChatManagement(SingleDeviceTestCase): chat_name = home.get_random_chat_name() public_chat = home.join_public_chat(chat_name) public_chat.get_back_to_home_view() - for public_key in (basic_user['public_key'], ens_user_ropsten['ens']): + for public_key in (basic_user['public_key'], ens_user_ropsten['ens'], dummy_user['public_key']): chat = home.add_contact(public_key) chat.get_back_to_home_view() + profile = home.profile_button.click() + profile.open_contact_from_profile(dummy_user['username']) + nickname = 'dummy_user' + public_chat.set_nickname(nickname) + profile.home_button.click() + public_chat.get_back_to_home_view() search_list = { basic_user['username']: basic_user['username'], ens_user_ropsten['username']: ens_user_ropsten['ens'], - chat_name: chat_name + chat_name: chat_name, + nickname: nickname, + dummy_user['username']: nickname, + ens_user_ropsten['ens']: ens_user_ropsten['ens'] } home.just_fyi('Can search for public chat name, ens name, username') @@ -523,7 +532,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(5332) @marks.critical - def test_add_and_remove_contact_from_public_chat(self): + def test_add_and_remove_contact_with_nickname_from_public_chat(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) home_1, home_2 = device_1.create_user(), device_2.create_user() @@ -546,31 +555,47 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat_1.element_by_text(username, 'text'), chat_1.add_to_contacts, chat_1.profile_send_message, - chat_1.profile_address_text]: + chat_1.profile_address_text, + chat_1.profile_nickname]: if not element.scroll_to_element(): self.errors.append('%s is not visible' % element.name) + if chat_1.profile_nickname.text != 'None': + self.errors.append('Default nickname is %s instead on "None"' % chat_1.profile_nickname.text) + + device_1.just_fyi('Set nickname for user without adding him to contacts, check it in public chat') + nickname = 'Name1' + chat_1.set_nickname(nickname) + chat_1.back_button.click() + expected_username = '%s %s' % (nickname, username) + if chat_element.username.text != expected_username: + self.errors.append('Username %s in public chat does not match expected %s' % (chat_element.username.text, expected_username)) device_1.just_fyi('Add user to contacts, check contact list in Profile') + chat_element.member_photo.click() chat_1.add_to_contacts.click() if not chat_1.remove_from_contacts.is_element_displayed(): - self.errors.append("'Add to contacts' is not changed to 'Remove from contacts'") + self.errors.append("'Add to contacts' is not changed to 'Remove from contacts'") chat_1.get_back_to_home_view() profile_1 = chat_1.profile_button.click() - userprofile = profile_1.open_contact_from_profile(username) + userprofile = profile_1.open_contact_from_profile(nickname) if not userprofile.remove_from_contacts.is_element_displayed(): - self.errors.append("'Add to contacts' is not changed to 'Remove from contacts'") + self.errors.append("'Add to contacts' is not changed to 'Remove from contacts' in profile contacts") profile_1.get_back_to_home_view() device_1.just_fyi('Check that user is added to contacts below "Start new chat" and you redirected to 1-1 on tap') home_1.plus_button.click() home_1.start_new_chat_button.click() - if not home_1.element_by_text(username).is_element_displayed(): - home_1.driver.fail('List of contacts below "Start new chat" does not contain added user') + for name in (nickname, username): + if not home_1.element_by_text(name).is_element_displayed(): + home_1.driver.fail('List of contacts below "Start new chat" does not contain added user') home_1.element_by_text(username).click() if not chat_1.chat_message_input.is_element_displayed(): home_1.driver.fail('No redirect to 1-1 chat if tap on Contact below "Start new chat"') + for element in (chat_1.chat_message_input, chat_1.element_by_text(nickname)): + if not element.is_element_displayed(): + self.errors.append('Expected element is not found in 1-1 after adding user to contacts from profile') if chat_1.add_to_contacts.is_element_displayed(): - self.errors.append('"Add to contacts" button is shown in 1-1 after adding user to contacts from profile') + self.errors.append('"Add to contacts" button is shown in 1-1 after adding user to contacts from profile') device_1.just_fyi('Remove user from contacts') chat_1.profile_button.click() @@ -578,6 +603,8 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): userprofile.remove_from_contacts.click() if userprofile.remove_from_contacts.is_element_displayed(): self.errors.append("'Remove from contacts' is not changed to 'Add to contacts'") + if chat_1.profile_nickname.text != nickname: + self.errors.append("Nickname is changed after removing user from contacts") device_1.just_fyi('Check that user is removed from contact list in profile') userprofile.back_button.click() @@ -589,7 +616,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): home_1.get_back_to_home_view() home_1.plus_button.click() home_1.start_new_chat_button.click() - if home_1.get_username_below_start_new_chat_button(username).is_element_displayed(): + if home_1.get_username_below_start_new_chat_button(nickname).is_element_displayed(): self.errors.append('List of contacts below "Start new chat" contains removed user') self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/chats/test_public.py b/test/appium/tests/atomic/chats/test_public.py index 8b40693861..a2efa264a9 100644 --- a/test/appium/tests/atomic/chats/test_public.py +++ b/test/appium/tests/atomic/chats/test_public.py @@ -232,8 +232,8 @@ class TestPublicChatSingleDevice(SingleDeviceTestCase): for message in (yesterday, quiet_time_yesterday): if not chat.element_by_text_part(message).is_element_displayed(): self.driver.fail('"%s" is not shown' % message) - chat.element_starts_with_text("↓ Fetch more messages").click() - chat.wait_for_element_starts_with_text("↓ Fetch more messages", 30) + chat.element_by_text_part("↓ Fetch more messages").wait_and_click(120) + chat.element_by_text_part("↓ Fetch more messages").wait_for_visibility_of_element(180) for message in (before_yesterday, quiet_time_before_yesterday): if not chat.element_by_text_part(message).is_element_displayed(): self.driver.fail('"%s" is not shown' % message) diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 73033cc70d..06d993d121 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -144,6 +144,17 @@ class ProfileDetailsOtherUser(BaseButton): self.locator = self.Locator.accessibility_id('profile-public-key') +class ProfileNicknameOtherUser(BaseButton): + def __init__(self, driver): + super(ProfileNicknameOtherUser, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@content-desc="profile-nickname-item"]/android.widget.TextView[2]') + + +class NicknameInputOtherUser(BaseEditBox): + def __init__(self, driver): + super(NicknameInputOtherUser, self).__init__(driver) + self.locator = self.Locator.accessibility_id('nickname-input') + class ShareChatButton(BaseButton): def __init__(self, driver): super(ShareChatButton, self).__init__(driver) @@ -786,6 +797,8 @@ class ChatView(BaseView): self.profile_block_contact = ProfileBlockContactButton(self.driver) self.profile_add_to_contacts = ProfileAddToContactsButton(self.driver) self.profile_details = ProfileDetailsOtherUser(self.driver) + self.profile_nickname = ProfileNicknameOtherUser(self.driver) + self.nickname_input_field = NicknameInputOtherUser(self.driver) def delete_chat(self): self.chat_options.click() @@ -929,6 +942,11 @@ class ChatView(BaseView): self.profile_block_contact.click() self.block_contact_button.click() + def set_nickname(self, nickname): + self.profile_nickname.click() + self.nickname_input_field.send_keys(nickname) + self.element_by_text('Done').click() + def convert_device_time_to_chat_timestamp(self): sent_time_object = dateutil.parser.parse(self.driver.device_time) timestamp = datetime.strptime("%s:%s" % (sent_time_object.hour, sent_time_object.minute), '%H:%M').strftime("%I:%M %p")