Refactoring amount validation errors e2e

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Churikova Tetiana 2020-06-24 15:25:53 +02:00
parent 3443afc51c
commit c32057d3fd
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
4 changed files with 140 additions and 281 deletions

View File

@ -341,9 +341,11 @@
:accessories (if (or gas-price-loading? gas-loading?)
[[react/small-loading-indicator]]
(if (= :gas-isnt-set gas-error-state)
[[react/text {:style {:color colors/blue}}
[[react/text {:style {:color colors/blue}
:accessibility-label :custom-gas-fee}
(i18n/label :t/set-custom-fee)]]
[[react/view {:style {:flex-direction :row}}
[[react/view {:style {:flex-direction :row}
:accessibility-label :custom-gas-fee}
[react/nested-text {:style {:color colors/gray}}
[{:style {:color colors/black}} (utils/format-decimals fee 6)]
" "

View File

@ -146,158 +146,3 @@ class TestTransactionDApp(SingleDeviceTestCase):
if not send_transaction_view.onboarding_message.is_element_displayed():
self.driver.fail('It seems onboarding screen is not shown.')
@marks.testrail_id(5685)
@marks.medium
def test_not_enough_eth_for_gas_validation_from_dapp(self):
sign_in_view = SignInView(self.driver)
home_view = sign_in_view.create_user()
wallet = home_view.wallet_button.click()
wallet.set_up_wallet()
wallet_address = wallet.get_wallet_address()
home_view = wallet.get_back_to_home_view()
status_test_dapp = home_view.open_status_test_dapp()
status_test_dapp.wait_for_d_aap_to_load()
status_test_dapp.transactions_button.click()
send_transaction_view = status_test_dapp.deploy_contract_button.click()
warning = 'No "Not enough ETH for gas" warning appeared while {}'
sign_button_warning = 'Signin transaction button is enabled while {}'
wallet.just_fyi('Check whether deploying simple contract with an empty ETH balance triggers the warning')
if not send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append(warning.format('deploying a contract with an empty ETH balance'))
wallet.just_fyi('Check whether sign transaction button is disabled')
send_transaction_view.sign_with_password.click()
if send_transaction_view.enter_password_input.is_element_displayed():
self.errors.append(sign_button_warning.format('deploying a contract with an empty ETH balance'))
wallet.just_fyi('Requesting test ETH and waiting till the balance updates')
send_transaction_view.cancel_button.click()
self.network_api.get_donate(wallet_address[2:])
self.network_api.verify_balance_is_updated(initial_balance=0, recipient_address=wallet_address[2:])
status_test_dapp.transactions_button.click()
send_transaction_view = status_test_dapp.send_one_tx_in_batch_button.click()
send_transaction_view.network_fee_button.click()
gas_limit = '100000'
send_transaction_view.gas_limit_input.clear()
send_transaction_view.gas_limit_input.set_value(gas_limit)
gas_price = '99999.00000001'
send_transaction_view.gas_price_input.clear()
send_transaction_view.gas_price_input.set_value(gas_price)
send_transaction_view.update_fee_button.click()
wallet.just_fyi('Check whether sending a tx in batch with big gas limit and price triggers the warning and sign'
' button is still disabled (no funds to pay gas)')
if not send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append(warning.format('sending one transaction in batch with big gas '
'limit and price (no funds to pay gas)'))
wallet.just_fyi('Check whether sign transaction button is disabled')
send_transaction_view.sign_with_password.click()
if send_transaction_view.enter_password_input.is_element_displayed():
self.errors.append(sign_button_warning.
format('sending one transaction in batch with big gas '
'limit and price (no funds to pay gas)'))
send_transaction_view.network_fee_button.click()
gas_price = '999.9'
send_transaction_view.gas_price_input.clear()
send_transaction_view.gas_price_input.set_value(gas_price)
send_transaction_view.update_fee_button.click()
wallet.just_fyi('Check whether sending a tx in batch with normal gas limit and price does not trigger the '
'warning so the transaction can be signed')
if send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append(warning.format('"Not enough ETH for gas" warning appeared while sending '
'one transaction in batch with normal gas limit and price'))
send_transaction_view.sign_transaction()
if not status_test_dapp.assets_button.is_element_displayed():
self.errors.append('Could not sign the transaction!')
self.errors.verify_no_errors()
@marks.testrail_id(5686)
@marks.medium
def test_not_enough_eth_for_gas_validation_from_wallet(self):
sign_in_view = SignInView(self.driver)
home_view = sign_in_view.create_user()
wallet = home_view.wallet_button.click()
wallet.set_up_wallet()
wallet.select_asset("STT")
wallet_address = wallet.get_wallet_address()
recipient = '0x' + basic_user['address']
wallet.send_transaction(asset_name='ETH', amount=0, recipient=recipient, sign_transaction=False)
send_transaction_view = SendTransactionView(self.driver)
warning = 'No "Not enough ETH for gas" warning appeared while {}'
sign_button_warning = 'Sign transaction button is enabled {}'
wallet.just_fyi('Check whether sending 0 ETH with an empty ETH balance triggers the warning')
send_transaction_view.sign_transaction_button.click()
if not send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append(warning.format('sending 0 ETH with an empty ETH balance'))
wallet.just_fyi('Check whether sign transaction button is disabled')
if send_transaction_view.enter_password_input.is_element_displayed():
self.errors.append(sign_button_warning.format('sending 0 ETH with an empty ETH balance'))
send_transaction_view.cancel_button.click()
wallet.send_transaction_button.click()
asset_button = send_transaction_view.asset_by_name('STT')
send_transaction_view.select_asset_button.click_until_presence_of_element(send_transaction_view.eth_asset_in_select_asset_bottom_sheet_button)
asset_button.click()
send_transaction_view.amount_edit_box.set_value('0')
send_transaction_view.confirm()
send_transaction_view.sign_transaction_button.click()
wallet.just_fyi('Check whether sending 0 STT with an empty ETH balance triggers the warning')
if not send_transaction_view.element_by_text_part('Insufficient funds').is_element_displayed():
self.errors.append(warning.format('sending 0 STT with an empty ETH balance'))
wallet.just_fyi('Check whether sign transaction button is disabled')
send_transaction_view.sign_transaction_button.click()
if send_transaction_view.enter_password_input.is_element_displayed():
self.errors.append(sign_button_warning.format('sending 0 STT with an empty ETH balance'))
send_transaction_view.cancel_button.click()
home_view = send_transaction_view.get_back_to_home_view()
wallet.just_fyi('Requesting test ETH and waiting till the balance updates')
self.network_api.faucet(wallet_address[2:])
self.network_api.verify_balance_is_updated(initial_balance=0, recipient_address=wallet_address[2:])
wallet = home_view.wallet_button.click()
wallet.wait_balance_is_changed()
wallet.accounts_status_account.click()
wallet.send_transaction(asset_name='ETH', amount=0.1, recipient=recipient, sign_transaction=False)
send_transaction_view.sign_transaction_button.click()
wallet.just_fyi('Check whether sending all available ETH triggers the warning')
if not send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append(warning.format('sending all available ETH (no funds to pay gas)'))
wallet.just_fyi('Check whether sign transaction button is disabled')
send_transaction_view.sign_with_password.click()
if send_transaction_view.enter_password_input.is_element_displayed():
self.errors.append(warning.format('sending all available ETH (no funds to pay gas)'))
wallet.just_fyi('Because tx gas price may change we calculate eth value according to current gas fee value')
transaction_fee_total = send_transaction_view.get_transaction_fee_total()
eth_available_for_tx = str(Decimal('0.1') - Decimal(transaction_fee_total))
send_transaction_view.cancel_button.click()
wallet.send_transaction_button.click()
wallet.send_transaction(asset_name='ETH', amount=eth_available_for_tx, recipient=recipient, sign_transaction=False)
wallet.just_fyi('Check whether sending normal amount of ETH does not trigger the warning')
if send_transaction_view.validation_warnings.not_enough_eth_for_gas.is_element_displayed():
self.errors.append('"Not enough ETH for gas" warning appeared while sending normal amount of ETH')
send_transaction_view.sign_transaction_button.click()
send_transaction_view.sign_transaction()
if not wallet.send_transaction_button.is_element_displayed():
self.errors.append('Could not sign the transaction!')
self.errors.verify_no_errors()

View File

@ -4,7 +4,7 @@ import string
from support.utilities import get_merged_txs_list
from tests import marks, unique_password, common_password
from tests.base_test_case import SingleDeviceTestCase
from tests.users import transaction_senders, basic_user, wallet_users
from tests.users import transaction_senders, basic_user, wallet_users, ens_user_ropsten
from views.send_transaction_view import SendTransactionView
from views.sign_in_view import SignInView
@ -170,74 +170,6 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
send_transaction.sign_transaction()
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount, token=True, decimals=7)
@marks.testrail_id(6245)
@marks.high
def test_token_with_more_than_allowed_decimals(self):
sender = wallet_users['C']
sign_in_view = SignInView(self.driver)
sign_in_view.recover_access(sender['passphrase'])
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.accounts_status_account.click()
send_transaction = wallet_view.send_transaction_button.click()
adi_button = send_transaction.asset_by_name('ADI')
send_transaction.select_asset_button.click_until_presence_of_element(send_transaction.eth_asset_in_select_asset_bottom_sheet_button)
adi_button.click()
send_transaction.amount_edit_box.click()
amount = '0.0%s' % str(random.randint(100000, 999999)) + '1'
send_transaction.amount_edit_box.set_value(amount)
error_text = 'Amount is too precise. Max number of decimals is 7.'
if not send_transaction.element_by_text(error_text).is_element_displayed():
self.driver.fail('Warning about too precise amount is not shown when sending a transaction')
@marks.testrail_id(5423)
@marks.medium
def test_send_valid_amount_after_insufficient_funds_error(self):
sender = transaction_senders['T']
sign_in_view = SignInView(self.driver)
sign_in_view.recover_access(sender['passphrase'])
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.accounts_status_account.click()
bigger_amount = wallet_view.get_asset_amount_by_name('ETHro') + 1
send_transaction = wallet_view.send_transaction_button.click()
amount_edit_box = send_transaction.amount_edit_box
amount_edit_box.click()
amount_edit_box.set_value(bigger_amount)
send_transaction.element_by_text('Insufficient funds').wait_for_visibility_of_element(5)
valid_amount = send_transaction.get_unique_amount()
amount_edit_box.clear()
amount_edit_box.set_value(valid_amount)
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.enter_recipient_address_button.click()
send_transaction.enter_recipient_address_input.set_value(basic_user['address'])
send_transaction.done_button.click()
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction()
self.network_api.find_transaction_by_unique_amount(sender['address'], valid_amount)
@marks.testrail_id(5471)
@marks.medium
def test_insufficient_funds_wallet_0_balance(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.select_asset("STT")
wallet_view.accounts_status_account.click()
send_transaction = wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.set_value(1)
error_text = send_transaction.element_by_text('Insufficient funds')
if not error_text.is_element_displayed():
self.errors.append("'Insufficient funds' error is now shown when sending 1 ETH from wallet with balance 0")
send_transaction.select_asset_button.click()
send_transaction.asset_by_name('STT').click()
send_transaction.amount_edit_box.set_value(1)
if not error_text.is_element_displayed():
self.errors.append("'Insufficient funds' error is now shown when sending 1 STT from wallet with balance 0")
self.errors.verify_no_errors()
@marks.testrail_id(5412)
@marks.high
@ -269,60 +201,6 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
round(stt_value + 1), stt_value))
self.errors.verify_no_errors()
@marks.testrail_id(5359)
@marks.critical
@marks.skip
def test_modify_transaction_fee_values(self):
sender = transaction_senders['U']
sign_in_view = SignInView(self.driver)
sign_in_view.recover_access(sender['passphrase'])
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.accounts_status_account.click()
send_transaction = wallet_view.send_transaction_button.click()
amount = send_transaction.get_unique_amount()
send_transaction.amount_edit_box.set_value(amount)
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.enter_recipient_address_button.click()
recipient_address = basic_user['address']
send_transaction.enter_recipient_address_input.set_value(recipient_address)
send_transaction.done_button.click()
send_transaction.sign_transaction_button.click()
send_transaction.network_fee_button.click_until_presence_of_element(send_transaction.gas_limit_input)
gas_prices = {
"1.0000000009": "Invalid number",
"0.0000000009": "Min 1 wei",
"-1": "Min 1 wei"
}
gas_limit = {
"20999": "Min 21000 units",
"21000.1": "Invalid number",
"-21000": "Min 21000 units"
}
for key in gas_prices:
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys(key)
if not send_transaction.element_by_text(gas_prices[key]).is_element_displayed():
self.errors.append("With %s Gas Price value there is no %s error displayed" % key, gas_prices[key])
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys('10')
for key in gas_limit:
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys(key)
if not send_transaction.element_by_text(gas_limit[key]).is_element_displayed():
self.errors.append("With %s Gas Limit value there is no %s error displayed" % key, gas_prices[key])
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys('21000')
send_transaction.update_fee_button.click_until_absense_of_element(send_transaction.update_fee_button)
send_transaction.sign_with_password.click_until_presence_of_element(send_transaction.enter_password_input)
send_transaction.enter_password_input.send_keys(common_password)
send_transaction.sign_button.click()
send_transaction.ok_button.click()
@marks.testrail_id(5314)
@marks.critical
def test_can_see_all_transactions_in_history(self):
@ -638,3 +516,121 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
# transactions_view.transactions_table.find_transaction(amount=amount, asset=symbol)
self.errors.verify_no_errors()
@marks.testrail_id(5437)
@marks.medium
def test_validation_amount_errors(self):
sender = wallet_users['C']
sign_in_view = SignInView(self.driver)
errors = {'send_transaction_screen': {
'too_precise': 'Amount is too precise. Max number of decimals is 7.',
'insufficient_funds': 'Insufficient funds'
},
'sending_screen': {
'Amount': 'Insufficient funds',
'Network fee': 'Not enough ETH for gas'
},
'gas_prices': {
'1.0000000009': 'Invalid number',
'0.0000000009': 'Min 1 wei',
'-1': 'Min 1 wei'
},
'gas_limit': {
'20999': 'Min 21000 units',
'21000.1': 'Invalid number',
'-21000': 'Min 21000 units'
}
}
warning = 'Warning %s is not shown on %s'
sign_in_view.recover_access(sender['passphrase'])
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.accounts_status_account.click()
screen = 'send transaction screen from wallet'
sign_in_view.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['too_precise'], screen))
initial_amount_ADI = wallet_view.get_asset_amount_by_name('ADI')
send_transaction = wallet_view.send_transaction_button.click()
adi_button = send_transaction.asset_by_name('ADI')
send_transaction.select_asset_button.click_until_presence_of_element(send_transaction.eth_asset_in_select_asset_bottom_sheet_button)
adi_button.click()
send_transaction.amount_edit_box.click()
amount = '0.0%s' % str(random.randint(100000, 999999)) + '1'
send_transaction.amount_edit_box.set_value(amount)
if not send_transaction.element_by_text(errors['send_transaction_screen']['too_precise']).is_element_displayed():
self.errors.append(warning % (errors['send_transaction_screen']['too_precise'], screen))
sign_in_view.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['insufficient_funds'], screen))
send_transaction.amount_edit_box.clear()
send_transaction.amount_edit_box.set_value(str(initial_amount_ADI) + '1')
if not send_transaction.element_by_text(errors['send_transaction_screen']['insufficient_funds']).is_element_displayed():
self.errors.append(warning % (errors['send_transaction_screen']['insufficient_funds'], screen))
send_transaction.cancel_button.click()
wallet_view.back_button.click()
screen = 'sending screen from wallet'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'],screen))
account_name = 'new'
wallet_view.add_account(account_name)
wallet_view.get_account_by_name(account_name).click()
wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.set_value('0')
send_transaction.chose_recipient_button.click()
send_transaction.enter_recipient_address_button.click()
send_transaction.enter_recipient_address_input.set_value(ens_user_ropsten['ens'])
send_transaction.done_button.click()
send_transaction.next_button.click()
if not send_transaction.validation_error_element.is_element_displayed(10):
self.errors.append('Validation icon is not shown when testing %s on %s' % (errors['sending_screen']['Network fee'],screen))
send_transaction.get_validation_icon().click()
if not send_transaction.element_by_text_part(errors['sending_screen']['Network fee']).is_element_displayed(10):
self.errors.append(warning % (errors['sending_screen']['Network fee'],screen))
send_transaction.sign_with_password.click()
if send_transaction.enter_password_input.is_element_displayed():
self.errors.append('Sign button is active when not enough ETH for gas')
sign_in_view.just_fyi('check validation for Gas Limit and Gas Price')
send_transaction.network_fee_button.click_until_presence_of_element(send_transaction.gas_limit_input)
for key in errors['gas_prices']:
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys(key)
if not send_transaction.element_by_text(errors['gas_prices'][key]).is_element_displayed():
self.errors.append("With %s Gas Price value there is no %s error displayed" % (key, errors['gas_prices'][key]))
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys('0.1')
for key in errors['gas_limit']:
send_transaction.gas_limit_input.clear()
send_transaction.gas_limit_input.send_keys(key)
if not send_transaction.element_by_text(errors['gas_limit'][key]).is_element_displayed():
self.errors.append("With %s Gas Limit value there is no %s error displayed" % (key, errors['gas_limit'][key]))
send_transaction.gas_limit_input.clear()
send_transaction.gas_limit_input.send_keys('21000')
send_transaction.update_fee_button.click_until_absense_of_element(send_transaction.update_fee_button)
if send_transaction.validation_error_element.is_element_displayed():
self.errors.append('Warning about insufficient funds for gas is shown after updating transaction fee')
send_transaction.cancel_button.click()
screen = 'sending screen from DApp'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'],screen))
home_view = wallet_view.home_button.click()
dapp_view = sign_in_view.dapp_tab_button.click()
dapp_view.select_account_button.click()
dapp_view.select_account_by_name(account_name).wait_for_element(30)
dapp_view.select_account_by_name(account_name).click()
status_test_dapp = home_view.open_status_test_dapp()
status_test_dapp.wait_for_d_aap_to_load()
status_test_dapp.transactions_button.click_until_presence_of_element(
status_test_dapp.send_two_tx_in_batch_button)
status_test_dapp.send_two_tx_in_batch_button.click()
if not send_transaction.validation_error_element.is_element_displayed(10):
self.errors.append(warning % (errors['sending_screen']['Network fee'],screen))
send_transaction.cancel_button.click()
for element in errors['sending_screen']:
send_transaction.get_validation_icon(element).click()
if not send_transaction.element_by_text_part(errors['sending_screen'][element]).is_element_displayed(10):
self.errors.append(warning % (errors['sending_screen'][element], screen))
self.errors.verify_no_errors()

View File

@ -125,7 +125,7 @@ class ErrorDialog(BaseView):
class NetworkFeeButton(BaseButton):
def __init__(self, driver):
super(NetworkFeeButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="Network fee"]')
self.locator = self.Locator.accessibility_id('custom-gas-fee')
class TransactionFeeButton(BaseButton):
@ -181,6 +181,18 @@ class UpdateFeeButton(BaseButton):
return self.navigate()
class ValidationErrorOnSendTransaction(BaseButton):
def __init__(self, driver, field):
super(ValidationErrorOnSendTransaction, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='%s']/../*[@content-desc='icon']" % field)
class ValidationIconOnSendTransaction(BaseButton):
def __init__(self, driver):
super(ValidationIconOnSendTransaction, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@content-desc="custom-gas-fee"]/../android.view.ViewGroup/*[@content-desc="icon"]')
class ShareButton(BaseButton):
def __init__(self, driver):
@ -276,6 +288,7 @@ class SendTransactionView(BaseView):
self.enter_recipient_address_text = EnterRecipientAddressInputText(self.driver)
self.recent_recipients_button = RecentRecipientsButton(self.driver)
self.amount_edit_box = AmountEditBox(self.driver)
self.validation_error_element = ValidationIconOnSendTransaction(self.driver)
self.network_fee_button = NetworkFeeButton(self.driver)
self.transaction_fee_button = TransactionFeeButton(self.driver)
@ -349,6 +362,9 @@ class SendTransactionView(BaseView):
def get_account_in_select_account_bottom_sheet_button(self, account_name):
return AccountNameInSelectAccountBottomSheet(self.driver, account_name)
def get_validation_icon(self, field='Network fee'):
return ValidationErrorOnSendTransaction(self.driver, field)
def get_values_from_send_transaction_bottom_sheet(self, gas=False):
data = {
'amount': self.amount_edit_box.text,