From 5809cba0df43527ceef7211a4fe9f4c3db54bda4 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Tue, 24 Mar 2020 16:45:15 +0100 Subject: [PATCH] 1-1 send ETH test Signed-off-by: Churikova Tetiana --- .../tests/atomic/chats/test_commands.py | 97 ++++++++++++------- test/appium/views/chat_view.py | 65 ++++++++++++- test/appium/views/send_transaction_view.py | 29 ++++++ 3 files changed, 156 insertions(+), 35 deletions(-) diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index b1c9c0e11a..55906e62cb 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -1,7 +1,7 @@ -import pytest from _pytest.outcomes import Failed from decimal import Decimal as d from selenium.common.exceptions import TimeoutException +import time from tests import marks, unique_password from tests.users import transaction_senders, basic_user, transaction_recipients @@ -75,10 +75,8 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): self.errors.append('Request funds message was not received') self.errors.verify_no_errors() - @marks.testrail_id(5306) + @marks.testrail_id(6253) @marks.critical - @marks.skip - # TODO: temporary skipped due to 8601 def test_send_eth_in_1_1_chat(self): recipient = transaction_recipients['A'] sender = transaction_senders['A'] @@ -90,43 +88,76 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): wallet_1.set_up_wallet() wallet_1.home_button.click() wallet_2.set_up_wallet() - init_balance = wallet_2.get_asset_amount_by_name('ETHro') wallet_2.home_button.click() chat_1 = home_1.add_contact(recipient['public_key']) amount = chat_1.get_unique_amount() + + home_1.just_fyi('Send %s ETH in 1-1 chat and check it for sender and receiver: Address requested' % amount) chat_1.commands_button.click() - chat_1.send_command.click() - chat_1.asset_by_name('ETHro').click() - chat_1.send_as_keyevent(amount) - send_transaction_view = chat_1.get_send_transaction_view() - chat_1.send_message_button.click_until_presence_of_element(send_transaction_view.sign_with_password) + send_transaction = chat_1.send_command.click() + if not send_transaction.get_username_in_transaction_bottom_sheet_button(recipient['username']).is_element_displayed(): + self.driver.fail('%s is not shown in "Send Transaction" bottom sheet' % recipient['username']) + send_transaction.get_username_in_transaction_bottom_sheet_button(recipient['username']).click() + if send_transaction.scan_qr_code_button.is_element_displayed(): + self.driver.fail('Recipient is editable in bootom sheet when send ETH from 1-1 chat') + send_transaction.amount_edit_box.set_value(amount) + send_transaction.confirm() + send_transaction.sign_transaction_button.click() + chat_1_sender_message = chat_1.chat_element_by_text('↑ Outgoing transaction') + if not chat_1_sender_message.is_element_displayed(): + self.driver.fail('No message is shown after sending ETH in 1-1 chat for sender') + if chat_1_sender_message.transaction_status.text != 'Address requested': + self.errors.append('Wrong state is shown for outgoing transaction: "Address requested" is expected, in fact' + ' %s ' % chat_1_sender_message.transaction_status.text) - send_transaction_view.network_fee_button.click() - gas_limit = '25000' - send_transaction_view.gas_limit_input.clear() - send_transaction_view.gas_limit_input.set_value(gas_limit) - gas_price = str(round(float(send_transaction_view.gas_price_input.text)) + 10) - send_transaction_view.gas_price_input.clear() - send_transaction_view.gas_price_input.set_value(gas_price) - if send_transaction_view.total_fee_input.text != '%s ETHro' % (d(gas_limit) * d(gas_price) / d(1000000000)): - self.errors.append('Gas limit and/or gas price fields were not edited') - send_transaction_view.update_fee_button.click() - send_transaction_view.sign_transaction() - - if not chat_1.chat_element_by_text(amount).is_element_displayed(): - self.errors.append('Message with the sent amount is not shown for the sender') chat_2 = home_2.get_chat(sender['username']).click() - if not chat_2.chat_element_by_text(amount).is_element_displayed(): - self.errors.append('Message with the sent amount is not shown for the recipient') + chat_2_receiver_message = chat_2.chat_element_by_text('↓ Incoming transaction') + timestamp_sender = chat_1_sender_message.timestamp_message.text + if not chat_2_receiver_message.is_element_displayed(): + self.driver.fail('No message about incoming transaction in 1-1 chat is shown for receiver') + if chat_2_receiver_message.transaction_status.text != 'Address requested': + self.errors.append('Wrong state is shown for incoming transaction: "Address requested" is expected, in fact' + ' %s' % chat_2_receiver_message.transaction_status.text) - chat_2.get_back_to_home_view() - home_2.wallet_button.click() - try: - wallet_2.wait_balance_is_equal_expected_amount('ETHro', expected_balance=init_balance + float(amount)) - self.network_api.find_transaction_by_unique_amount(recipient['address'], amount) - except Failed as e: - self.errors.append(e.msg) + home_2.just_fyi('Accept and share address for sender and receiver') + for text in ('Accept and share address', 'Decline'): + if not chat_2_receiver_message.contains_text(text): + self.driver.fail("Transaction message doesn't contain required option %s" % text) + select_account_bottom_sheet = chat_2_receiver_message.accept_and_share_address.click() + if not select_account_bottom_sheet.get_account_in_select_account_bottom_sheet_button('Status').is_element_displayed(): + self.errors.append('Not expected value in "From" in "Select account": "Status" is expected') + select_account_bottom_sheet.select_button.click() + if chat_2_receiver_message.transaction_status.text != "Shared 'Status account'": + self.errors.append('Wrong state is shown for incoming transaction: "Shared \'Status account\' is expected, ' + 'in fact %s ' % chat_2_receiver_message.transaction_status.text) + if chat_1_sender_message.transaction_status.text != 'Address request accepted': + self.errors.append('Wrong state is shown for outgoing transaction: "Address request accepted" is expected, ' + 'in fact %s ' % chat_1_sender_message.transaction_status.text) + + home_1.just_fyi("Sign and send transaction and check that timestamp on message is updated") + time.sleep(40) + send_message = chat_1_sender_message.sign_and_send.click() + send_message.next_button.click() + send_message.sign_transaction() + if chat_1_sender_message.transaction_status.text != 'Pending': + self.errors.append('Wrong state is shown for outgoing transaction: "Pending" is expected, in fact' + ' %s ' % chat_1_sender_message.transaction_status.text) + updated_timestamp_sender = chat_1_sender_message.timestamp_message.text + if updated_timestamp_sender == timestamp_sender: + self.errors.append("Timestamp of message is not updated after signing transaction") + + chat_1.wallet_button.click() + wallet_1.accounts_status_account.click() + transactions_view = wallet_1.transaction_history_button.click() + transactions_view.transactions_table.find_transaction(amount=amount) + self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount) + wallet_1.home_button.click() + + home_1.just_fyi("Check 'Confirmed' state for sender") + if chat_1_sender_message.transaction_status.text != 'Confirmed': + self.errors.append('Wrong state is shown for outgoing transaction: "Confirmed" is expected, in fact' + ' %s ' % chat_1_sender_message.transaction_status.text) self.errors.verify_no_errors() @marks.testrail_id(5318) diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 2071d11da0..94dd645b20 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -73,7 +73,11 @@ class TransactionPopupText(BaseText): class SendCommand(BaseButton): def __init__(self, driver): super(SendCommand, self).__init__(driver) - self.locator = self.Locator.accessibility_id('send-button') + self.locator = self.Locator.text_selector('Send transaction') + + def navigate(self): + from views.send_transaction_view import SendTransactionView + return SendTransactionView(self.driver) def click(self): self.wait_for_element().click() @@ -211,7 +215,7 @@ class OpenInStatusButton(BaseButton): class CommandsButton(BaseButton): def __init__(self, driver): super(CommandsButton, self).__init__(driver) - self.locator = self.Locator.accessibility_id('chat-commands-button') + self.locator = self.Locator.accessibility_id('show-extensions-icon') class ShowStickersButton(BaseButton): @@ -319,6 +323,16 @@ class ChatElementByText(BaseText): return StatusText(self.driver, self.locator.value).wait_for_element(10) + @property + def timestamp_message(self): + class TimeStampText(BaseText): + def __init__(self, driver, parent_locator: str): + super(TimeStampText, self).__init__(driver) + text = "//*[1]/*[1]/*[6]" + self.locator = self.Locator.xpath_selector(parent_locator + text) + + return TimeStampText(self.driver, self.locator.value) + @property def progress_bar(self): return ProgressBar(self.driver, self.locator.value) @@ -350,12 +364,59 @@ class ChatElementByText(BaseText): return SendRequestButton(self.driver, self.locator.value) + @property + def transaction_status(self): + class TransactionStatus(BaseText): + def __init__(self, driver, parent_locator): + super(TransactionStatus, self).__init__(driver) + self.locator = self.Locator.xpath_selector(parent_locator + "/*[1]/*[1]/*[5]/android.widget.TextView") + + return TransactionStatus(self.driver, self.locator.value) + def contains_text(self, text, wait_time=5) -> bool: element = BaseText(self.driver) element.locator = element.Locator.xpath_selector( self.locator.value + "//android.view.ViewGroup//android.widget.TextView[contains(@text,'%s')]" % text) return element.is_element_displayed(wait_time) + @property + def accept_and_share_address(self): + class AcceptAndShareAddress(BaseButton): + def __init__(self, driver, parent_locator): + super(AcceptAndShareAddress, self).__init__(driver) + self.locator = self.Locator.xpath_selector(parent_locator + "//*[@text='Accept and share address']") + + def navigate(self): + from views.send_transaction_view import SendTransactionView + return SendTransactionView(self.driver) + + def click(self): + self.wait_for_element().click() + self.driver.info('Tap on %s' % self.name) + return self.navigate() + + return AcceptAndShareAddress(self.driver, self.locator.value) + + @property + def sign_and_send(self): + class SignAndSend(BaseButton): + def __init__(self, driver, parent_locator): + super(SignAndSend, self).__init__(driver) + self.locator = self.Locator.xpath_selector(parent_locator + "//*[@text='Sign and send']") + + def navigate(self): + from views.send_transaction_view import SendTransactionView + return SendTransactionView(self.driver) + + def click(self): + self.wait_for_element().click() + self.driver.info('Tap on %s' % self.name) + return self.navigate() + + return SignAndSend(self.driver, self.locator.value) + + + @property def replied_message_text(self): class RepliedMessageText(BaseText): diff --git a/test/appium/views/send_transaction_view.py b/test/appium/views/send_transaction_view.py index ea0b6f6e4b..3c4577f521 100644 --- a/test/appium/views/send_transaction_view.py +++ b/test/appium/views/send_transaction_view.py @@ -204,6 +204,26 @@ class SignButton(BaseButton): super(SignButton, self).__init__(driver) self.locator = self.Locator.xpath_selector('//*[@text="Sign"]') +# Elements for commands in 1-1 chat +class UserNameInSendTransactionBottomSheet(BaseButton): + def __init__(self, driver, username_part): + super(UserNameInSendTransactionBottomSheet, self).__init__(driver) + self.username = username_part + self.locator = self.Locator.xpath_selector( + "//*[@content-desc='amount-input']/..//*[starts-with(@text,'%s')]" % self.username) + +class AccountNameInSelectAccountBottomSheet(BaseButton): + def __init__(self, driver, account_part): + super(AccountNameInSelectAccountBottomSheet, self).__init__(driver) + self.username = account_part + self.locator = self.Locator.xpath_selector( + "//*[@text='Select account']/..//*[starts-with(@text,'%s')]" % self.username) + +class SelectButton(BaseButton): + + def __init__(self, driver): + super(SelectButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('select-account-bottom-sheet') class SendTransactionView(BaseView): def __init__(self, driver): @@ -245,6 +265,9 @@ class SendTransactionView(BaseView): self.onboarding_message = OnboardingMessage(self.driver) self.validation_warnings = ValidationWarnings(self.driver) + # Elements for commands in 1-1 chat + self.select_button = SelectButton(self.driver) + def complete_onboarding(self): if self.onboarding_message.is_element_displayed(): from views.wallet_view import WalletView @@ -264,3 +287,9 @@ class SendTransactionView(BaseView): def get_formatted_recipient_address(self, address): return address[:6] + '…' + address[-4:] + def get_username_in_transaction_bottom_sheet_button(self, username_part): + return UserNameInSendTransactionBottomSheet(self.driver, username_part) + + def get_account_in_select_account_bottom_sheet_button(self, account_name): + return AccountNameInSelectAccountBottomSheet(self.driver, account_name) +