From c1583249f6890bd3d3ad79cf4ffb9264bbd66dbe Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Tue, 23 Jun 2020 11:01:06 +0200 Subject: [PATCH] e2e for scanning chat key and small fixes Signed-off-by: Churikova Tetiana --- .../tests/atomic/chats/test_one_to_one.py | 80 +++++++++++++++++++ .../tests/atomic/transactions/test_wallet.py | 9 +-- test/appium/views/base_view.py | 6 ++ test/appium/views/profile_view.py | 2 +- test/appium/views/wallet_view.py | 7 -- 5 files changed, 91 insertions(+), 13 deletions(-) diff --git a/test/appium/tests/atomic/chats/test_one_to_one.py b/test/appium/tests/atomic/chats/test_one_to_one.py index 68dda65ac1..965f67e725 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -669,3 +669,83 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase): self.errors.append('Offline status is not shown in a public chat') self.errors.verify_no_errors() + + @marks.testrail_id(6298) + @marks.medium + def test_can_scan_qr_with_chat_key_from_new_contact_view(self): + sign_in_view = SignInView(self.driver) + home_view = sign_in_view.recover_access(basic_user['passphrase']) + profile = home_view.profile_button.click() + profile.switch_network() + + url_data = { + 'ens_with_stateofus_domain_deep_link': { + 'url': 'https://join.status.im/u/%s.stateofus.eth' % ens_user['ens'], + 'username': ens_user['username'] + }, + 'ens_without_stateofus_domain_deep_link': { + 'url': 'https://join.status.im/u/%s' % ens_user['ens'], + 'username': ens_user['username'] + }, + 'ens_another_domain_deep_link': { + 'url': 'status-im://u/%s' % ens_user['ens_another_domain'], + 'username': ens_user['username'] + }, + 'own_profile_key_deep_link': { + 'url': 'https://join.status.im/u/%s' % basic_user['public_key'], + 'error': "That's you" + }, + 'other_user_profile_key_deep_link':{ + 'url': 'https://join.status.im/u/%s' % ens_user['public_key'], + 'username': ens_user['username'] + }, + 'other_user_profile_key_deep_link_invalid':{ + 'url': 'https://join.status.im/u/%sinvalid' % ens_user['public_key'], + 'error': 'Please enter or scan a valid chat key' + }, + 'ens_another_domain':{ + 'url': ens_user['ens_another_domain'], + 'username': ens_user['username'] + }, + 'own_profile_key': { + 'url': basic_user['public_key'], + 'error': "That's you" + }, + 'ens_without_stateofus_domain': { + 'url': ens_user['ens'], + 'username': ens_user['username'] + }, + 'other_user_profile_key': { + 'url': ens_user['public_key'], + 'username': ens_user['username'] + }, + 'other_user_profile_key_invalid': { + 'url': '%s123' % ens_user['public_key'], + 'error': 'Please enter or scan a valid chat key' + }, + } + + for key in url_data: + home_view.plus_button.click_until_presence_of_element(home_view.start_new_chat_button) + contact_view = home_view.start_new_chat_button.click() + sign_in_view.just_fyi('Checking %s case' % key) + contact_view.scan_contact_code_button.click() + if contact_view.allow_button.is_element_displayed(): + contact_view.allow_button.click() + contact_view.enter_qr_edit_box.set_value(url_data[key]['url']) + contact_view.ok_button.click() + from views.chat_view import ChatView + chat_view = ChatView(self.driver) + if url_data[key].get('error'): + if not chat_view.element_by_text_part(url_data[key]['error']).is_element_displayed(): + self.errors.append('Expected error %s is not shown' % url_data[key]['error']) + chat_view.ok_button.click() + if url_data[key].get('username'): + if not chat_view.chat_message_input.is_element_displayed(): + self.errors.append('In %s case chat input is not found after scanning' % key) + if not chat_view.element_by_text(url_data[key]['username']).is_element_displayed(): + self.errors.append('In %s case username not found after scanning' % key) + chat_view.back_button.click() + + self.errors.verify_no_errors() + diff --git a/test/appium/tests/atomic/transactions/test_wallet.py b/test/appium/tests/atomic/transactions/test_wallet.py index ea4b322c2e..d9f4ec80fa 100644 --- a/test/appium/tests/atomic/transactions/test_wallet.py +++ b/test/appium/tests/atomic/transactions/test_wallet.py @@ -133,9 +133,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): send_transaction.chose_recipient_button.click() send_transaction.enter_recipient_address_button.click() send_transaction.enter_recipient_address_input.set_value(recipient['public_key']) - send_transaction.done_button.click() - if not send_transaction.find_text_part('Invalid address'): - self.errors.append("Invalid address accepted for input as recipient!") + send_transaction.done_button.click_until_presence_of_element(send_transaction.element_by_text_part('Invalid address')) send_transaction.ok_button.click() send_transaction.enter_recipient_address_input.set_value('0xDE709F2102306220921060314715629080E2fB77') send_transaction.done_button.click() @@ -635,7 +633,8 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): recipient = "0x" + basic_user['address'] amount = '0.0%s' % str(random.randint(10000, 99999)) + '1' wallet_view.send_transaction(asset_name=symbol, amount=amount, recipient=recipient) - transactions_view = wallet_view.transaction_history_button.click() - transactions_view.transactions_table.find_transaction(amount=amount, asset=symbol) + # TODO: disabled due to 10838 + # transactions_view = wallet_view.transaction_history_button.click() + # transactions_view.transactions_table.find_transaction(amount=amount, asset=symbol) self.errors.verify_no_errors() diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index de8ef866cb..0df4212458 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -325,6 +325,11 @@ class StatusInBackgroundButton(BaseButton): super(StatusInBackgroundButton, self).__init__(driver) self.locator = self.Locator.xpath_selector('//*[contains(@content-desc,"Status")]') +class EnterQRcodeEditBox(BaseEditBox): + def __init__(self, driver): + super(EnterQRcodeEditBox, self).__init__(driver) + self.locator = self.Locator.text_selector('Type a message...') + class OkGotItButton(BaseButton): def __init__(self,driver): @@ -399,6 +404,7 @@ class BaseView(object): self.status_app_icon = StatusAppIcon(self.driver) self.airplane_mode_button = AirplaneModeButton(self.driver) + self.enter_qr_edit_box = EnterQRcodeEditBox(self.driver) self.element_types = { 'base': BaseElement, diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index e9fc173b94..7da33107ad 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -646,7 +646,7 @@ class ProfileView(BaseView): self.use_mobile_data = UseMobileDataToggle(self.driver) self.ask_me_when_on_mobile_network = AskMeWhenOnMobileNetworkToggle(self.driver) - def switch_network(self, network): + def switch_network(self, network='Mainnet with upstream RPC'): self.advanced_button.click() self.network_settings_button.click() network_button = NetworkSettingsButton.NetworkButton(self.driver, network) diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index 5492704d69..a418c4ac9c 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -40,12 +40,6 @@ class ScanQRButton(BaseButton): self.locator = self.Locator.accessibility_id("accounts-qr-code") -class EnterQRcodeEditBox(BaseEditBox): - def __init__(self, driver): - super(EnterQRcodeEditBox, self).__init__(driver) - self.locator = self.Locator.text_selector('Type a message...') - - class AssetText(BaseText): def __init__(self, driver, asset): super(AssetText, self).__init__(driver) @@ -440,7 +434,6 @@ class WalletView(BaseView): self.add_account_generate_account_button = AddAccountGenerateAnAccountButton(self.driver) self.status_account_total_usd_value = StatusAccountTotalValueText(self.driver) self.scan_qr_button = ScanQRButton(self.driver) - self.enter_qr_edit_box = EnterQRcodeEditBox(self.driver) # individual account settings self.account_settings_button = AccountSettingsButton(self.driver)