From 3127f2fcb21d11d8a8cf47560eb860dbb00aa71b Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Wed, 13 Nov 2019 18:38:41 +0100 Subject: [PATCH] Reworked test_ens Signed-off-by: Andrey Shovkoplyas --- .../atomic/account_management/test_profile.py | 31 +++++++++++++++++-- test/appium/views/chat_view.py | 6 ++++ test/appium/views/profile_view.py | 7 +++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index 7d090b563e..8e165c2829 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -840,8 +840,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(6226) @marks.critical - # TODO: should be completed after https://github.com/status-im/status-react/issues/8854 is ready - def test_ens_in_public_chat(self): + def test_ens_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) @@ -857,8 +856,13 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): dapp_view_1 = DappsView(device_1) dapp_view_1.element_by_text('Get started').click() dapp_view_1.ens_name.set_value(ens_user['ens']) - dapp_view_1.check_ens_name.click() + expected_text = 'This user name is owned by you and connected with your Chat key.' + if not dapp_view_1.wait_for_element_starts_with_text(expected_text): + sign_in_1.driver.fail("No %s is shown" % expected_text) + dapp_view_1.check_ens_name.click_until_presence_of_element(dapp_view_1.element_by_text('Ok, got it')) dapp_view_1.element_by_text('Ok, got it').click() + if profile_1.username_in_ens_chat_settings_text.text != user_1['username']: + self.errors.append('Default username is not shown in ENS usernames') dapp_view_1.back_button.click() profile_1.home_button.click() @@ -877,6 +881,8 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): home_1.profile_button.click() profile_1.element_by_text('Your ENS name').click() profile_1.show_ens_name_in_chats.click() + if profile_1.username_in_ens_chat_settings_text.text != '@' + user_1['ens']: + 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_with_user('#' + chat_name).click() @@ -885,4 +891,23 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): if not chat_2.wait_for_element_starts_with_text('@' + user_1['ens']): 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']: + 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(): + 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(): + 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') + self.errors.verify_no_errors() diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 9762c52c3b..587d8d0f5f 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -234,6 +234,11 @@ class ProfileBlockContactButton(BaseButton): super(ProfileBlockContactButton, self).__init__(driver) self.locator = self.Locator.accessibility_id('block-contact') +class ProfileAddToContactsButton(BaseButton): + def __init__(self, driver): + super(ProfileAddToContactsButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('add-to-contacts-button') + class JoinChatButton(BaseButton): def __init__(self, driver): @@ -423,6 +428,7 @@ class ChatView(BaseView): self.profile_send_transaction = ProfileSendTransactionButton(self.driver) self.profile_address_text = ProfileAddressText(self.driver) self.profile_block_contact = ProfileBlockContactButton(self.driver) + self.profile_add_to_contacts = ProfileAddToContactsButton(self.driver) def wait_for_syncing_complete(self): self.driver.info('Waiting for syncing complete:') diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index c60bfa1f13..db9224b4e7 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -527,6 +527,12 @@ class AskMeWhenOnMobileNetworkToggle(BaseButton): self.locator = self.Locator.xpath_selector( "//*[@text='Ask me when on mobile network']/../*[name()='android.widget.Switch']") +class ENSUsernameInChatSettings(BaseElement): + def __init__(self, driver): + super(ENSUsernameInChatSettings, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//*[@content-desc='chat-icon']/../android.widget.TextView[2]") + class ProfileView(BaseView): @@ -614,6 +620,7 @@ class ProfileView(BaseView): # ENS self.show_ens_name_in_chats = ShowENSNameInChatsToggle(self.driver) + self.username_in_ens_chat_settings_text = ENSUsernameInChatSettings(self.driver) # Mobile Data self.use_mobile_data = UseMobileDataToggle(self.driver)