test: adding test for ability to add saved address from wallet settings

This commit is contained in:
Anastasiya Semenkevich 2024-01-10 20:15:38 +03:00 committed by Anastasiya
parent 7b1e303156
commit e45da2c9b6
8 changed files with 108 additions and 7 deletions

View File

@ -16,6 +16,7 @@ from gui.elements.check_box import CheckBox
from gui.elements.object import QObject
from gui.elements.scroll import Scroll
from gui.elements.text_edit import TextEdit
from gui.elements.text_label import TextLabel
GENERATED_PAGES_LIMIT = 20
@ -28,6 +29,7 @@ class AccountPopup(BasePopup):
self._name_text_edit = TextEdit('mainWallet_AddEditAccountPopup_AccountName')
self._emoji_button = Button('mainWallet_AddEditAccountPopup_AccountEmojiPopupButton')
self._color_radiobutton = QObject('color_StatusColorRadioButton')
self._popup_header_title = TextLabel('mainWallet_AddEditAccountPopup_HeaderTitle')
# origin
self._origin_combobox = QObject('mainWallet_AddEditAccountPopup_SelectedOrigin')
self._watched_address_origin_item = QObject("mainWallet_AddEditAccountPopup_OriginOptionWatchOnlyAcc")
@ -45,6 +47,10 @@ class AccountPopup(BasePopup):
self._address_combobox_button = Button('mainWallet_AddEditAccountPopup_GeneratedAddressComponent')
self._non_eth_checkbox = CheckBox('mainWallet_AddEditAccountPopup_NonEthDerivationPathCheckBox')
def verify_account_popup_present(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
driver.waitFor(lambda: self._popup_header_title.exists, timeout_msec)
return self
@allure.step('Set name for account')
def set_name(self, value: str):
self._name_text_edit.text = value

View File

@ -235,6 +235,7 @@ mainWallet_AddEditAccountPopup_PrimaryButton = {"container": statusDesktop_mainW
mainWallet_AddEditAccountPopup_BackButton = {"container": statusDesktop_mainWindow, "objectName": "AddAccountPopup-BackButton", "type": "StatusBackButton", "visible": True}
mainWallet_AddEditAccountPopup_AccountNameComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-AccountName", "type": "StatusInput", "visible": True}
mainWallet_AddEditAccountPopup_AccountName = {"container": mainWallet_AddEditAccountPopup_AccountNameComponent, "type": "TextEdit", "unnamed": 1, "visible": True}
mainWallet_AddEditAccountPopup_HeaderTitle = {"container": statusDesktop_mainWindow_overlay, "objectName": "headerTitle", "type": "StatusBaseText", "visible": True}
mainWallet_AddEditAccountPopup_AccountColorComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-AccountColor", "type": "StatusColorSelectorGrid", "visible": True}
mainWallet_AddEditAccountPopup_AccountColorSelector = {"container": mainWallet_AddEditAccountPopup_AccountColorComponent, "type": "Repeater", "objectName": "statusColorRepeater", "visible": True, "enabled": True}
mainWallet_AddEditAccountPopup_AccountEmojiPopupButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-AccountEmoji", "type": "StatusFlatRoundButton", "visible": True}

View File

@ -58,9 +58,12 @@ mainWindow_WalletView = {"container": statusDesktop_mainWindow, "type": "WalletV
settings_Wallet_MainView_Networks = {"container": statusDesktop_mainWindow, "objectName": "networksItem", "type": "StatusListItem"}
settings_Wallet_MainView_AddNewAccountButton = {"container": statusDesktop_mainWindow, "objectName": "settings_Wallet_MainView_AddNewAccountButton", "type": "StatusButton", "visible": True}
settingsContentBaseScrollView_accountOrderItem_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "accountOrderItem", "type": "StatusListItem", "visible": True}
settingsContentBaseScrollView_savedAddressesItem_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "savedAddressesItem", "type": "StatusListItem", "visible": True}
settingsContentBaseScrollView_StatusListItem = {"container": settingsContentBase_ScrollView, "type": "StatusListItem", "unnamed": 1, "visible": True}
settings_Wallet_NetworksView_TestNet_Toggle = {"container": statusDesktop_mainWindow, "objectName": "testnetModeSwitch", "type": "StatusSwitch"}
settings_Wallet_NetworksView_TestNet_Toggle_Title = {"container": settingsContentBase_ScrollView, "objectName": "statusListItemSubTitle", "type": "StatusTextWithLoadingState", "visible": True}
settings_Wallet_SavedAddresses_AddAddressButton = {"container": statusDesktop_mainWindow, "objectName": "addNewSavedAddressButton", "type": "StatusButton", "visible": True}
settings_Wallet_SavedAddress_ItemDelegate ={"container": settingsContentBase_ScrollView, "objectName": RegularExpression("savedAddressView_Delegate*"), "type": "SavedAddressesDelegate", "visible": True}
settingsContentBaseScrollView_Goerli_testnet_active_StatusBaseText = {"container": settingsContentBase_ScrollView, "type": "StatusBaseText", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_accountsList_StatusListView = {"container": settingsContentBase_ScrollView, "id": "accountsList", "type": "StatusListView", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_draggableDelegate_StatusDraggableListItem = {"checkable": False, "container": settingsContentBase_ScrollView, "id": "draggableDelegate", "type": "StatusDraggableListItem", "unnamed": 1, "visible": True}

View File

@ -9,6 +9,7 @@ import driver
from constants import wallet_account_list_item
from constants.wallet import WalletNetworkSettings, WalletNetworkDefaultValues
from driver import objects_access
from gui.components.wallet.add_saved_address_popup import AddressPopup
from gui.components.wallet.popup_delete_account_from_settings import RemoveAccountConfirmationSettings
from gui.components.wallet.testnet_mode_popup import TestnetModePopup
@ -29,6 +30,7 @@ class WalletSettingsView(QObject):
self._wallet_settings_add_new_account_button = Button('settings_Wallet_MainView_AddNewAccountButton')
self._wallet_network_button = Button('settings_Wallet_MainView_Networks')
self._account_order_button = Button('settingsContentBaseScrollView_accountOrderItem_StatusListItem')
self._saved_addresses_button = Button('settingsContentBaseScrollView_savedAddressesItem_StatusListItem')
self._status_account_in_keypair = QObject('settingsWalletAccountDelegate_Status_account')
self._wallet_account_from_keypair = QObject('settingsWalletAccountDelegate')
self._wallet_settings_keypair_item = QObject('settingsWalletKeyPairDelegate')
@ -36,16 +38,33 @@ class WalletSettingsView(QObject):
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):
def open_add_account_pop_up(self, attempts: int = 2) -> 'AccountPopup':
self._wallet_settings_add_new_account_button.click()
return AccountPopup().wait_until_appears()
try:
return AccountPopup()
except Exception as ex:
if attempts:
return self.open_add_account_pop_up(attempts - 1)
else:
raise ex
@allure.step('Open saved addresses in wallet settings')
def open_saved_addresses(self, attempts: int = 2) -> 'SavedAddressesWalletSettings':
self._saved_addresses_button.click()
try:
return SavedAddressesWalletSettings()
except Exception as ex:
if attempts:
return self.open_saved_addresses(attempts - 1)
else:
raise ex
@allure.step('Open networks in wallet settings')
def open_networks(self, attempts: int = 2) -> 'NetworkWalletSettings':
self._wallet_network_button.click()
try:
return NetworkWalletSettings().wait_until_appears()
except AssertionError as err:
except Exception as err:
if attempts:
return self.open_networks(attempts - 1)
else:
@ -170,11 +189,34 @@ class AccountDetailsView(WalletSettingsView):
self._back_button.click()
class SavedAddressesWalletSettings(WalletSettingsView):
def __init__(self):
super(SavedAddressesWalletSettings, self).__init__()
self.add_new_address_button = Button('settings_Wallet_SavedAddresses_AddAddressButton')
self.saved_address_item = QObject('settings_Wallet_SavedAddress_ItemDelegate')
@allure.step('Click add new address button')
def open_add_saved_address_popup(self, attempt: int = 2) -> 'AddressPopup':
self.add_new_address_button.click()
try:
return AddressPopup()
except AssertionError as err:
if attempt:
self.open_add_saved_address_popup(attempt - 1)
else:
raise err
@allure.step('Get saved addresses names list')
def get_saved_address_names_list(self):
names = [str(address.name) for address in driver.findAllObjects(self.saved_address_item.real_name)]
return names
class NetworkWalletSettings(WalletSettingsView):
def __init__(self):
super(NetworkWalletSettings, self).__init__()
self._testnet_text_item = QObject('settingsContentBaseScrollView_Goerli_testnet_active_StatusBaseText')
self._testnet_text_item = QObject('s')
self._testnet_mode_toggle = Button('settings_Wallet_NetworksView_TestNet_Toggle')
self._testnet_mode_title = TextLabel('settings_Wallet_NetworksView_TestNet_Toggle_Title')
self._back_button = Button('main_toolBar_back_button')

View File

@ -151,13 +151,13 @@ class SavedAddressesView(QObject):
return names
@allure.step('Open add new address popup')
def open_add_address_popup(self, attempt=2) -> 'AddressPopup':
def open_add_saved_address_popup(self, attempt=2) -> 'AddressPopup':
self._add_new_address_button.click()
try:
return AddressPopup().wait_until_appears()
except AssertionError as err:
if attempt:
self.open_add_address_popup(attempt - 1)
self.open_add_saved_address_popup(attempt - 1)
else:
raise err

View File

@ -0,0 +1,47 @@
import random
import string
import allure
import pytest
from allure_commons._allure import step
from gui.components.toast_message import ToastMessage
from . import marks
import configs
import driver
from gui.main_window import MainWindow
pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704620',
'Saved addresses: Add new saved address (ethereum address)')
@pytest.mark.parametrize('name, address',
[
pytest.param(
''.join(random.choices(string.ascii_letters, k=24)),
'0x8397bc3c5a60a1883174f722403d63a8833312b7')
])
# @pytest.mark.case(704620) TODO: enable that after i test multiple references
def test_wallet_settings_add_saved_address(main_screen: MainWindow, address: str, name: str):
with (step('Open wallet settings - Saved addresses section')):
settings_saved_addresses = \
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_saved_addresses()
with step('Click Add new address button and open add saved address popup'):
add_saved_address_popup = settings_saved_addresses.open_add_saved_address_popup()
with step('Fill in the form and preferred networks and add the address'):
add_saved_address_popup.add_saved_address(name, address)
with step('Verify toast message when adding saved address'):
messages = ToastMessage().get_toast_messages
assert f'{name} successfully added to your saved addresses' in messages, \
f"Toast message about adding saved address is not correct or not present. \
Current list of messages: {messages}"
with step('Verify recently added saved address is present in the list'):
assert driver.waitFor(
lambda: name in settings_saved_addresses.get_saved_address_names_list(),
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found'

View File

@ -12,6 +12,8 @@ pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703010', 'Settings - Sign out & Quit')
# TODO: Experimental link for testing multiple references in test rail report by nightly job. Has to be removed!
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704620', 'Wallet -> Settings -> Saved addresses: Add new saved address')
@pytest.mark.case(703010)
@pytest.mark.case(704620)
@pytest.mark.flaky
# reason='https://github.com/status-im/status-desktop/issues/13013'
def test_sign_out_and_quit(aut, main_screen: MainWindow):

View File

@ -33,7 +33,7 @@ def test_manage_saved_address(main_screen: MainWindow, name: str, address: str,
with step('Add new address'):
wallet = main_screen.left_panel.open_wallet()
SigningPhrasePopup().confirm_phrase()
wallet.left_panel.open_saved_addresses().open_add_address_popup().add_saved_address(name, address)
wallet.left_panel.open_saved_addresses().open_add_saved_address_popup().add_saved_address(name, address)
with step('Verify toast message when adding saved address'):
messages = ToastMessage().get_toast_messages