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 62282078d1..8ac24416d1 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -5,7 +5,7 @@ import emoji from datetime import datetime from selenium.common.exceptions import TimeoutException from tests import marks, get_current_time -from tests.users import transaction_senders +from tests.users import transaction_senders, transaction_recipients from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase from views.sign_in_view import SignInView @@ -496,3 +496,88 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase): if not chat.chat_element_by_text(emoji_unicode).is_element_displayed(): self.errors.append('Message with emoji was not sent in 1-1 chat') self.verify_no_errors() + + @marks.testrail_id(5393) + @marks.high + def test_that_fiat_value_is_correct_for_token_transactions(self): + sender_passphrase = transaction_senders['X']['passphrase'] + recipient_public_key = transaction_recipients['H']['public_key'] + recipient_user_name = transaction_recipients['H']['username'] + default_currency = 'USD' + user_currency = 'EUR' + sigin_view = SignInView(self.driver) + home_view = sigin_view.recover_access(sender_passphrase) + wallet = home_view.wallet_button.click() + wallet.set_up_wallet() + + wallet.get_back_to_home_view() + + chat = home_view.add_contact(recipient_public_key) + send_amount, request_amount = [chat.get_unique_amount() for _ in range(2)] + # Send and request some tokens in 1x1 chat and check whether the fiat currency value of the messages is equal + # to default + chat.send_transaction_in_1_1_chat('STT', send_amount) + chat.request_transaction_in_1_1_chat('STT', request_amount) + + send_message = chat.chat_element_by_text(send_amount) + if not send_message.is_element_displayed() or not send_message.contains_text(default_currency): + self.errors.append('Wrong fiat value while sending assets in 1-1 chat with default currency.') + + request_message = chat.chat_element_by_text(request_amount) + if not request_message.is_element_displayed() or not request_message.contains_text(default_currency): + self.errors.append('Wrong fiat value while requesting assets in 1-1 chat with default currency.') + + chat.get_back_to_home_view() + + # Switch default currency to user-selected + profile_view = sigin_view.profile_button.click() + profile_view.set_currency(user_currency) + profile_view.get_back_to_home_view() + + chat = home_view.get_chat_with_user(recipient_user_name).click() + + # Check whether the fiat currency value of the messages sent is not changed to user-selected + send_message = chat.chat_element_by_text(send_amount) + if not send_message.is_element_displayed() or not send_message.contains_text(default_currency): + self.errors.append('Wrong fiat value while sending assets in 1-1 chat with default currency.') + + request_message = chat.chat_element_by_text(request_amount) + if not request_message.is_element_displayed() or not request_message.contains_text(default_currency): + self.errors.append('Wrong fiat value while requesting assets in 1-1 chat with default currency.') + + # Send and request some tokens in 1x1 chat and check whether the fiat currency value of + # the new messages is equal to user-selected + send_amount, request_amount = [chat.get_unique_amount() for _ in range(2)] + chat.send_transaction_in_1_1_chat('STT', send_amount) + chat.request_transaction_in_1_1_chat('STT', request_amount) + + send_message = chat.chat_element_by_text(send_amount) + if not send_message.is_element_displayed() or not send_message.contains_text(user_currency): + self.errors.append('Wrong fiat value while sending assets in 1-1 chat with user selected currency.') + + request_message = chat.chat_element_by_text(request_amount) + if not request_message.is_element_displayed() or not request_message.contains_text(user_currency): + self.errors.append('Wrong fiat value while requesting assets in 1-1 chat with user selected currency.') + + chat.get_back_to_home_view() + + wallet = home_view.wallet_button.click() + send_amount, request_amount = [chat.get_unique_amount() for _ in range(2)] + + # Send and request some tokens from wallet and check whether the fiat currency value of + # the new messages is equal to user-selected + wallet.send_transaction(asset_name='STT', recipient=recipient_user_name, amount=send_amount) + wallet.receive_transaction(asset_name='STT', recipient=recipient_user_name, amount=request_amount) + + wallet.get_back_to_home_view() + chat = home_view.get_chat_with_user(recipient_user_name).click() + + send_message = chat.chat_element_by_text(send_amount) + if not send_message.is_element_displayed() or not send_message.contains_text(user_currency): + self.errors.append('Wrong fiat value while sending assets from wallet with user selected currency.') + + request_message = chat.chat_element_by_text(request_amount) + if not request_message.is_element_displayed() or not request_message.contains_text(user_currency): + self.errors.append('Wrong fiat value while requesting assets from wallet with user selected currency.') + + self.verify_no_errors() diff --git a/test/appium/tests/users.py b/test/appium/tests/users.py index fe72993f54..12108135d8 100644 --- a/test/appium/tests/users.py +++ b/test/appium/tests/users.py @@ -188,6 +188,13 @@ transaction_senders['W']['address'] = "d5de9a58a3eab0643ecbd01729312215ef647a4d" transaction_senders['W']['public_key'] = "0x04fe5b77e1f0aa15b36090db04d830cd080a716982503d6b962a6ba2ed8f42bdbcc66bba8" \ "9dba8c35620313c50f7ac625c9c75199d2164b07253143717f6ef0834" +transaction_senders['X'] = dict() +transaction_senders['X']['passphrase'] = "denial lend kit learn jacket mail ceiling crack affair stool spike sound" +transaction_senders['X']['username'] = "Infatuated Zesty Ballpython" +transaction_senders['X']['address'] = "0xc9cf2ff3ca98a91f2e3dfc35a13cf8425ecaf082" +transaction_senders['X']['public_key'] = "0x04a712634920a012cd45d63a23832d494518d992b77d3b8aa81131a302657193e2d174e3a" \ + "ffda80dad81bc3bf3edaf84334437cfecfb248f37fdcb1d882773cf08" + transaction_recipients = dict() transaction_recipients['A'] = dict() @@ -236,3 +243,10 @@ transaction_recipients['G']['username'] = "Amused Dazzling Badger" transaction_recipients['G']['address'] = "b1f8b0db0f12e45d7712625bc53535235d245a9f" transaction_recipients['G']['public_key'] = "0x04f08a05551c3704284ca03ea2ff7fe613a00e52be86d6b433f7e38fa31fd0741eebf" \ "4344ad8d1652896440dada4017665e9b16ae328cb829b9e647b65c7024df7" + +transaction_recipients['H'] = dict() +transaction_recipients['H']['passphrase'] = "rail change device celery metal husband panda avoid often shiver payment real" +transaction_recipients['H']['username'] = "Glum Tricky Indianskimmer" +transaction_recipients['H']['address'] = "0xe9676a57a28800d83301d9d3f9c77fd2e933609c" +transaction_recipients['H']['public_key'] = "0x0400b4d2cb69c49d147af128a596a2160fb7ac1d2abc54156b26598feb5630e8e7529" \ + "f5a8363a73d6a9df86fdda87c095a9462aca8b4cbf1f331152a9a22cdb35d" \ No newline at end of file diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 39b27a05d5..41ecbffcc2 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -461,7 +461,7 @@ class BaseView(object): self.back_button.click() except (NoSuchElementException, TimeoutException): counter += 1 - return self.get_home_view() + return self.home_button.click() def relogin(self, password=common_password): self.get_back_to_home_view() diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index e987bd45f3..8296c8b736 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -542,9 +542,12 @@ class ProfileView(BaseView): self.logout_button.click() return self.logout_dialog.logout_button.click() - def set_currency(self, desired_currency='Euro (EUR)'): + def set_currency(self, desired_currency='EUR'): + """ + :param desired_currency: defines a currency designator which is expressed by ISO 4217 code + """ self.main_currency_button.click() - desired_currency = self.element_by_text(desired_currency) + desired_currency = self.element_by_text_part(desired_currency) desired_currency.scroll_to_element() desired_currency.click() diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index edfa6b305c..758dba629d 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -79,6 +79,10 @@ class SendTransactionRequestButton(BaseButton): super(SendTransactionRequestButton, self).__init__(driver) self.locator = self.Locator.accessibility_id('sent-transaction-request-button') + def navigate(self): + from views.send_transaction_view import SendTransactionView + return SendTransactionView(self.driver) + class OptionsButton(BaseButton): def __init__(self, driver): @@ -265,3 +269,56 @@ class WalletView(BaseView): def asset_checkbox_by_name(self, asset_name): return AssetCheckBox(self.driver, asset_name) + + def send_transaction(self, **kwargs): + send_transaction_view = self.send_transaction_button.click() + send_transaction_view.select_asset_button.click() + asset_name = kwargs.get('asset_name', 'ETHro') + asset_button = send_transaction_view.asset_by_name(asset_name) + send_transaction_view.select_asset_button.click_until_presence_of_element(asset_button) + asset_button.click() + send_transaction_view.amount_edit_box.click() + + transaction_amount = str(kwargs.get('amount')) if kwargs.get('amount') else \ + send_transaction_view.get_unique_amount() + + send_transaction_view.amount_edit_box.set_value(transaction_amount) + send_transaction_view.confirm() + send_transaction_view.chose_recipient_button.click() + + recipient = kwargs.get('recipient') + + if '0x' in recipient: + send_transaction_view.enter_recipient_address_button.click() + send_transaction_view.enter_recipient_address_input.set_value(recipient) + send_transaction_view.done_button.click() + else: + send_transaction_view.recent_recipients_button.click() + recent_recipient = send_transaction_view.element_by_text(recipient) + send_transaction_view.recent_recipients_button.click_until_presence_of_element(recent_recipient) + recent_recipient.click() + send_transaction_view.sign_transaction() + + def receive_transaction(self, **kwargs): + self.receive_transaction_button.click() + send_transaction_view = self.send_transaction_request.click() + send_transaction_view.select_asset_button.click() + asset_name = kwargs.get('asset_name', 'ETHro') + asset_button = send_transaction_view.asset_by_name(asset_name) + send_transaction_view.select_asset_button.click_until_presence_of_element(asset_button) + asset_button.click() + send_transaction_view.amount_edit_box.click() + + transaction_amount = str(kwargs.get('amount')) if kwargs.get('amount') else \ + send_transaction_view.get_unique_amount() + + send_transaction_view.amount_edit_box.set_value(transaction_amount) + send_transaction_view.confirm() + send_transaction_view.chose_recipient_button.click() + + recipient = kwargs.get('recipient') + send_transaction_view.recent_recipients_button.click() + recent_recipient = send_transaction_view.element_by_text(recipient) + send_transaction_view.recent_recipients_button.click_until_presence_of_element(recent_recipient) + recent_recipient.click() + self.send_request_button.click()