Test: exclude from total balance (#288)

* chore: added verification for keypair name in status account and added steps

* test: test to check total balance for watched addresses added

* chore: added verification for keypair name in status account and added steps

* test: test to check total balance for watched addresses added

* review addressed
This commit is contained in:
Anastasiya 2023-11-10 18:04:49 +03:00 committed by GitHub
parent 3587f94106
commit 828b7fc02e
11 changed files with 181 additions and 32 deletions

View File

@ -27,7 +27,9 @@ class WalletNetworkSettings(Enum):
class WalletAccountSettings(Enum):
STATUS_ACCOUNT_ORIGIN = 'Derived from your default Status keypair'
WATCHED_ADDRESS_ORIGIN = 'Watched address'
STORED_ON_DEVICE = 'On device'
WATCHED_ADDRESSES_KEYPAIR_LABEL = 'Watched addresses'
class WalletNetworkNaming(Enum):

View File

@ -11,6 +11,7 @@ class ContextMenu(QObject):
self._context_add_watched_address_option = QObject('contextMenuItem_AddWatchOnly')
self._context_delete_account_option = QObject('contextMenuItem_Delete')
self._context_edit_account_option = QObject('contextMenuItem_Edit')
self._context_hide_include_in_total_balance = QObject('contextMenuItem_HideInclude')
@allure.step('Select in context menu')
def select(self, value: str):
@ -25,6 +26,10 @@ class ContextMenu(QObject):
def select_delete_account_from_context_menu(self):
self._context_delete_account_option.click()
@allure.step('Select Hide/Include in total balance option from context menu')
def select_hide_include_total_balance_from_context_menu(self):
self._context_hide_include_in_total_balance.click()
@allure.step('Select edit account option from context menu')
def select_edit_account_from_context_menu(self):
self._context_edit_account_option.click()

View File

@ -170,6 +170,7 @@ contextMenuItem = {"container": statusDesktop_mainWindow_overlay, "type": "Statu
contextMenuItem_AddWatchOnly = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": RegularExpression("AccountMenu-AddWatchOnlyAccountAction*"), "type": "StatusMenuItem"}
contextMenuItem_Delete = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": RegularExpression("AccountMenu-DeleteAction*"), "type": "StatusMenuItem"}
contextMenuItem_Edit = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": RegularExpression("AccountMenu-EditAction*"), "type": "StatusMenuItem"}
contextMenuItem_HideInclude = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": RegularExpression("AccountMenu-HideFromTotalBalance*"), "type": "StatusMenuItem"}
# Confirmation Popup
confirmButton = {"container": statusDesktop_mainWindow_overlay, "objectName": RegularExpression("confirm*"), "type": "StatusButton"}

View File

@ -69,6 +69,9 @@ networkSettingsNetworks_Mainnet_Goerli_sensor = {"container": networkSettingsNet
networkSettingsNetowrks_Mainnet_Testlabel = {"container": networkSettingsNetworks_Mainnet_Goerli_sensor, "objectName": "testnetLabel_Mainnet", "type": "StatusBaseText", "visible": True}
settingsWalletAccountDelegate_Status_account = {"container": settingsContentBase_ScrollView, "objectName": "Status account", "type": "WalletAccountDelegate", "visible": True}
settingsWalletAccountDelegate = {"container": settingsContentBase_ScrollView, "objectName": RegularExpression("*"), "type": "WalletAccountDelegate", "visible": True}
settingsWalletKeyPairDelegate = {"container": settingsContentBase_ScrollView, "objectName": "walletKeyPairDelegate", "type": "StatusListItem", "visible": True}
settingsWalletAccountTotalBalance = {"container": settingsContentBase_ScrollView, "objectName": "includeTotalBalanceListItem", "type": "StatusListItem", "visible": True}
settingsWalletAccountTotalBalanceToggle = {"checkable": True, "container": settingsWalletAccountTotalBalance, "type": "StatusSwitch", "visible": True}
# Wallet Account Details view
walletAccountViewEditAccountButton = {"container": statusDesktop_mainWindow, "objectName": "walletAccountViewEditAccountButton", "type": "StatusButton"}

View File

@ -10,6 +10,7 @@ walletAccounts_StatusListView = {"container": statusDesktop_mainWindow, "objectN
mainWallet_All_Accounts_Button = {"container": walletAccounts_StatusListView, "objectName": "allAccountsBtn", "type": "Button", "visible": True}
mainWallet_Add_Account_Button = {"container": statusDesktop_mainWindow, "objectName": "addAccountButton", "type": "StatusRoundButton", "visible": True}
walletAccount_StatusListItem = {"container": walletAccounts_StatusListView, "objectName": RegularExpression("walletAccount*"), "type": "StatusListItem", "visible": True}
mainWallet_All_Accounts_Balance = {"container": mainWallet_All_Accounts_Button, "objectName": "walletLeftListAmountValue", "type": "StatusTextWithLoadingState", "visible": True}
# Saved Address View
mainWindow_SavedAddressesView = {"container": mainWindow_WalletLayout, "type": "SavedAddressesView", "unnamed": 1, "visible": True}

View File

@ -42,7 +42,7 @@ class LeftPanel(QObject):
@allure.step('Open wallet settings')
def open_wallet_settings(self):
self._open_settings('4-AppMenuItem')
return WalletSettingsView()
return WalletSettingsView().wait_until_appears()
@allure.step('Open profile settings')
def open_profile_settings(self):

View File

@ -32,6 +32,9 @@ class WalletSettingsView(QObject):
self._account_order_button = Button('settingsContentBaseScrollView_accountOrderItem_StatusListItem')
self._status_account_in_keypair = QObject('settingsWalletAccountDelegate_Status_account')
self._wallet_account_from_keypair = QObject('settingsWalletAccountDelegate')
self._wallet_settings_keypair_item = QObject('settingsWalletKeyPairDelegate')
self._wallet_settings_total_balance_item = QObject('settingsWalletAccountTotalBalance')
self._wallet_settings_total_balance_toggle = CheckBox('settingsWalletAccountTotalBalanceToggle')
@allure.step('Open add account pop up in wallet settings')
def open_add_account_pop_up(self):
@ -59,12 +62,25 @@ class WalletSettingsView(QObject):
self._status_account_in_keypair.click()
return AccountDetailsView().wait_until_appears()
@allure.step('Get keypair names')
def get_keypairs_names(self):
return [str(getattr(item, 'title', '')) for item in
driver.findAllObjects(self._wallet_settings_keypair_item.real_name)]
@allure.step('Open account view in wallet settings by name')
def open_account_in_settings(self, name):
self._wallet_account_from_keypair.real_name['objectName'] = name
self._wallet_account_from_keypair.click()
return AccountDetailsView().wait_until_appears()
@allure.step('Check Include in total balance item is visible')
def is_include_in_total_balance_visible(self):
return self._wallet_settings_total_balance_item.is_visible
@allure.step('Interact with the total balance toggle')
def toggle_total_balance(self, value: bool):
self._wallet_settings_total_balance_toggle.set(value)
class AccountDetailsView(WalletSettingsView):
def __init__(self):
@ -101,6 +117,11 @@ class AccountDetailsView(WalletSettingsView):
def get_account_name_value(self):
return self._wallet_account_title.text
@allure.step('Get account balance value')
def get_account_balance_value(self):
balance = str(getattr(self._wallet_account_balance, 'subTitle'))[:-4]
return balance
@allure.step("Get account address value")
def get_account_address_value(self):
raw_value = str(getattr(self._wallet_account_address, 'subTitle'))
@ -125,12 +146,20 @@ class AccountDetailsView(WalletSettingsView):
def get_account_derivation_path_value(self):
return str(getattr(self._wallet_account_derivation_path, 'subTitle'))
@allure.step('Get derivation path visibility')
def is_derivation_path_visible(self):
return self._wallet_account_derivation_path.is_visible
@allure.step('Get account storage value')
def get_account_storage_value(self):
raw_value = str(getattr(self._wallet_account_stored, 'subTitle'))
storage = raw_value.split(">")[-1]
return storage
@allure.step('Get account storage visibility')
def is_account_storage_visible(self):
return self._wallet_account_stored.is_visible
class NetworkWalletSettings(WalletSettingsView):

View File

@ -33,6 +33,7 @@ class LeftPanel(QObject):
self._wallet_account_item = QObject('walletAccount_StatusListItem')
self._add_account_button = Button('mainWallet_Add_Account_Button')
self._all_accounts_button = Button('mainWallet_All_Accounts_Button')
self._all_accounts_balance = TextLabel('mainWallet_All_Accounts_Balance')
@property
@allure.step('Get all accounts from list')
@ -56,6 +57,10 @@ class LeftPanel(QObject):
return accounts
@allure.step('Get total balance value from All accounts')
def get_total_balance_value(self):
return self._all_accounts_balance.text[:-4]
@allure.step('Choose saved addresses on left wallet panel')
@close_exists(BasePopup())
def open_saved_addresses(self) -> 'SavedAddressesView':
@ -82,6 +87,10 @@ class LeftPanel(QObject):
self._wallet_account_item.wait_until_appears().open_context_menu()
return ContextMenu().wait_until_appears()
@allure.step("Select Hide/Include in total balance from context menu for account")
def hide_include_in_total_balance_from_context_menu(self, account_name: str):
self._open_context_menu_for_account(account_name).select_hide_include_total_balance_from_context_menu()
@allure.step('Open account popup for editing from context menu')
def open_edit_account_popup_from_context_menu(self, account_name: str, attempt: int = 2) -> AccountPopup:
try:

View File

@ -3,6 +3,7 @@ import string
import allure
import pytest
from allure_commons._allure import step
from constants.wallet import WalletNetworkSettings, DerivationPath, WalletAccountSettings
from gui.main_window import MainWindow
@ -16,39 +17,48 @@ from gui.main_window import MainWindow
string.digits, k=40)))
])
def test_settings_edit_status_account(main_screen: MainWindow, new_name):
with step('Open profile and wallet setting and check that display name equals to Status keypair name'):
status_keypair_title = \
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().get_keypairs_names()[0]
profile_display_name = main_screen.left_panel.open_settings().left_panel.open_profile_settings().display_name
assert profile_display_name in status_keypair_title, \
f"Status keypair name should be equal to display name but currently it is {status_keypair_title}, \
when display name is {profile_display_name}"
status_acc_view = (
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_status_account_in_settings())
assert status_acc_view.get_account_name_value() == WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME.value, \
f"Status main account name must be {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME.value}"
assert status_acc_view.get_account_color_value() == WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value, \
f"Status main account color must be {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value}"
with step('Check the default values on the account details view for Status account'):
assert status_acc_view.get_account_name_value() == WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME.value, \
f"Status main account name must be {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME.value}"
assert status_acc_view.get_account_color_value() == WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value, \
f"Status main account color must be {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value}"
assert status_acc_view.get_account_origin_value() == WalletAccountSettings.STATUS_ACCOUNT_ORIGIN.value, \
f"Status account origin label is incorrect"
assert status_acc_view.get_account_derivation_path_value() == DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value, \
f"Status account derivation path must be {DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value}"
assert status_acc_view.get_account_storage_value() == WalletAccountSettings.STORED_ON_DEVICE.value, \
f"Status account storage should be {WalletAccountSettings.STORED_ON_DEVICE.value}"
assert status_acc_view.get_account_origin_value() == WalletAccountSettings.STATUS_ACCOUNT_ORIGIN.value, \
f"Status account origin label is incorrect"
with step('Edit Status account by clicking Edit account button'):
account_emoji_id_before = status_acc_view.get_account_emoji_id()
edit_acc_pop_up = status_acc_view.click_edit_account_button()
edit_acc_pop_up.type_in_account_name(new_name)
edit_acc_pop_up.select_random_color_for_account()
edit_acc_pop_up.select_random_emoji_for_account()
edit_acc_pop_up.click_change_name_button()
edit_acc_pop_up.wait_until_hidden()
current_color = status_acc_view.get_account_color_value()
account_emoji_id_after = status_acc_view.get_account_emoji_id()
assert status_acc_view.get_account_derivation_path_value() == DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value, \
f"Status account derivation path must be {DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value}"
assert status_acc_view.get_account_storage_value() == WalletAccountSettings.STORED_ON_DEVICE.value, \
f"Status account storage should be {WalletAccountSettings.STORED_ON_DEVICE.value}"
account_emoji_id_before = status_acc_view.get_account_emoji_id()
edit_acc_pop_up = status_acc_view.click_edit_account_button()
edit_acc_pop_up.type_in_account_name(new_name)
edit_acc_pop_up.select_random_color_for_account()
edit_acc_pop_up.select_random_emoji_for_account()
edit_acc_pop_up.click_change_name_button()
edit_acc_pop_up.wait_until_hidden()
current_color = status_acc_view.get_account_color_value()
account_emoji_id_after = status_acc_view.get_account_emoji_id()
assert not status_acc_view.is_remove_account_button_visible(), \
f"Delete button should not be present for Status account"
assert status_acc_view.get_account_name_value() == new_name, f"Account name has not been changed"
assert account_emoji_id_before != account_emoji_id_after, f"Account emoji has not been changed"
assert WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value != current_color, \
(f"Account color has not been changed: color before was {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value},"
f" color after is {current_color}")
with step('Make sure Delete button is not present for Status account'):
assert not status_acc_view.is_remove_account_button_visible(), \
f"Delete button should not be present for Status account"
with step('Check the new values appear on account details view for Status account'):
assert status_acc_view.get_account_name_value() == new_name, f"Account name has not been changed"
assert account_emoji_id_before != account_emoji_id_after, f"Account emoji has not been changed"
assert WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value != current_color, \
(
f"Account color has not been changed: color before was {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value},"
f" color after is {current_color}")

View File

@ -29,7 +29,6 @@ def test_add_new_account_from_wallet_settings(
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_add_account_pop_up()
with step('Add a new generated account from wallet settings screen'):
add_account_popup.set_name(account_name).set_emoji(emoji).set_color(color).save()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
add_account_popup.wait_until_hidden()

View File

@ -0,0 +1,90 @@
import random
import string
import allure
import pytest
from allure_commons._allure import step
import configs
import driver
from constants.wallet import WalletAccountSettings
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.main_window import MainWindow
from gui.screens.settings_wallet import WalletSettingsView
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703508',
'Watched addresses: Excl. / Include in total balance functionality for watched address')
@pytest.mark.case(703508)
@pytest.mark.parametrize('watched_address, name', [
pytest.param('0x7f1502605A2f2Cc01f9f4E7dd55e549954A8cD0C', ''.join(random.choices(string.ascii_letters +
string.digits, k=20)))
])
def test_settings_include_in_total_balance(main_screen: MainWindow, name, watched_address):
with (step('Open wallet on main screen and check the total balance for new account is 0')):
wallet_main_screen = main_screen.left_panel.open_wallet()
SigningPhrasePopup().wait_until_appears().confirm_phrase()
total_balance_before = float(wallet_main_screen.left_panel.get_total_balance_value().replace("\xa0", ""
).replace(",",
""))
assert total_balance_before == 0.0, \
f"Balance for new account should be 0.0 but current balance is {total_balance_before}"
with step('Open wallet settings screen and add watched address using "+" button'):
add_account_popup = \
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_add_account_pop_up()
add_account_popup.set_name(name).set_origin_watched_address(watched_address).save()
add_account_popup.wait_until_hidden()
with step('Open wallet settings and verify the keypair for the watched address is present with default title'):
wallet_settings_view = main_screen.left_panel.open_settings().left_panel.open_wallet_settings()
keypairs_names = wallet_settings_view.get_keypairs_names()
assert WalletAccountSettings.WATCHED_ADDRESSES_KEYPAIR_LABEL.value in keypairs_names, \
f"Watched addresses keypair name must be present when watched address is added \
but currently the list is {keypairs_names}"
with step('Open account details view for the watched address'):
acc_view = WalletSettingsView().open_account_in_settings(name)
with step('Verify details view for the watched address'):
assert driver.waitFor(
lambda: acc_view.get_account_balance_value() != '0,00', configs.timeouts.UI_LOAD_TIMEOUT_MSEC), \
f"Watched address {watched_address} should have positive balance in account view"
assert acc_view.get_account_name_value() == name, \
f"Watched address name is incorrect, current name is {acc_view.get_account_name_value()}, expected {name}"
assert acc_view.get_account_address_value() == str(watched_address).lower(), \
f"Watched address in details view does not match {watched_address}"
assert acc_view.get_account_origin_value() == WalletAccountSettings.WATCHED_ADDRESS_ORIGIN.value, \
f"Watched address origin must be {WalletAccountSettings.WATCHED_ADDRESS_ORIGIN.value}"
assert acc_view.is_derivation_path_visible() is False, \
f"Watched address should not have derivation path value"
assert acc_view.is_account_storage_visible() is False, \
f"Watched address should not have storage value"
assert acc_view.is_include_in_total_balance_visible(), \
f"Include in total balance option must be present for watched addresses"
with step('Enable the "Include in total balance" toggle in account view'):
acc_view.toggle_total_balance(True)
with step('Open wallet main screen and make sure total balance is not 0 anymore'):
main_screen.left_panel.open_wallet()
total_balance_after = float(wallet_main_screen.left_panel.get_total_balance_value().replace("\xa0", "")
.replace(",", ""))
assert total_balance_after > 0, \
f"Balance after adding watched address can't less than 0, when current balance is {total_balance_after}"
with step('Right click the watched address and select Exclude from total balance option'):
main_screen.left_panel.open_wallet().left_panel.hide_include_in_total_balance_from_context_menu(name)
with step('Check the balance is back to 0 again'):
main_screen.left_panel.open_wallet()
total_balance_excluded = float(wallet_main_screen.left_panel.get_total_balance_value().replace("\xa0", "")
.replace(",", ""))
assert total_balance_excluded == 0.0, \
f"Balance after adding watched address should be back to 0, when current balance is {total_balance_after}"