test(Wallet) Test Manage a saved address automated (#12034)

This commit is contained in:
Valentina1133 2023-09-01 18:18:04 +07:00 committed by GitHub
parent 0d17fafb88
commit e56aac906f
14 changed files with 343 additions and 3 deletions

View File

@ -0,0 +1,15 @@
import allure
from gui.elements.qt.object import QObject
class ContextMenu(QObject):
def __init__(self):
super(ContextMenu, self).__init__('contextMenu_PopupItem')
self._menu_item = QObject('contextMenuItem')
@allure.step('Select in context menu')
def select(self, value: str):
self._menu_item.real_name['text'] = value
self._menu_item.click()

View File

@ -0,0 +1,16 @@
import allure
from gui.components.base_popup import BasePopup
from gui.elements.qt.button import Button
class SigningPhrasePopup(BasePopup):
def __init__(self):
super(SigningPhrasePopup, self).__init__()
self._ok_got_it_button = Button('signPhrase_Ok_Button')
@allure.step('Confirm signing phrase in popup')
def confirm_phrase(self):
self._ok_got_it_button.click()
SigningPhrasePopup().wait_until_hidden()

View File

@ -0,0 +1,103 @@
import allure
from gui.components.base_popup import BasePopup
from gui.elements.qt.button import Button
from gui.elements.qt.check_box import CheckBox
from gui.elements.qt.object import QObject
from gui.elements.qt.text_edit import TextEdit
from gui.elements.qt.text_label import TextLabel
class AddSavedAddressPopup(BasePopup):
def __init__(self):
super(AddSavedAddressPopup, self).__init__()
self._name_text_edit = TextEdit('mainWallet_Saved_Addreses_Popup_Name_Input')
self._save_add_address_button = Button('mainWallet_Saved_Addreses_Popup_Address_Add_Button')
self._add_networks_selector = QObject('mainWallet_Saved_Addreses_Popup_Add_Network_Selector_Tag')
self._add_networks_button = Button('mainWallet_Saved_Addreses_Popup_Add_Network_Button')
self._ethereum_mainnet_checkbox = CheckBox(
'mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Mainnet_checkbox')
self._optimism_mainnet_checkbox = CheckBox(
'mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Optimism_checkbox')
self._arbitrum_mainnet_checkbox = CheckBox(
'mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Arbitrum_checkbox')
self._ethereum_mainnet_network_tag = QObject(
'mainWallet_Saved_Addresses_Popup_Network_Selector_Mainnet_network_tag')
self._optimism_mainnet_network_tag = QObject(
'mainWallet_Saved_Addresses_Popup_Network_Selector_Optimism_network_tag')
self._arbitrum_mainnet_network_tag = QObject(
'mainWallet_Saved_Addresses_Popup_Network_Selector_Arbitrum_network_tag')
@allure.step('Set ethereum mainnet network checkbox')
def set_ethereum_mainnet_network(self, value: bool):
self._ethereum_mainnet_checkbox.set(value)
return self
@allure.step('Set optimism mainnet network checkbox')
def set_optimism_mainnet_network(self, value: bool):
self._optimism_mainnet_checkbox.set(value)
return self
@allure.step('Set arbitrum mainnet network checkbox')
def set_arbitrum_mainnet_network(self, value: bool):
self._arbitrum_mainnet_checkbox.set(value)
return self
@allure.step('Verify that network selector enabled')
def verify_network_selector_enabled(self):
assert self._add_networks_selector.is_visible, f'Network selector is not enabled'
@allure.step('Verify that etherium mainnet network present')
def verify_ethereum_mainnet_network_tag_present(self):
assert self._ethereum_mainnet_network_tag.is_visible, f'Ethereum Mainnet network tag is not present'
@allure.step('Verify that etherium mainnet network present')
def verify_otimism_mainnet_network_tag_present(self):
assert self._optimism_mainnet_network_tag.is_visible, f'Optimism Mainnet network tag is not present'
@allure.step('Verify that arbitrum mainnet network present')
def verify_arbitrum_mainnet_network_tag_present(self):
assert self._arbitrum_mainnet_network_tag.is_visible, f'Arbitrum Mainnet network tag is not present'
class AddressPopup(AddSavedAddressPopup):
def __init__(self):
super(AddressPopup, self).__init__()
self._address_text_edit = TextEdit('mainWallet_Saved_Addreses_Popup_Address_Input_Edit')
@allure.step('Add saved address')
def add_saved_address(self, name: str, address: str):
self._name_text_edit.text = name
self._address_text_edit.clear(verify=False)
self._address_text_edit.type_text(address)
if address.startswith("0x"):
self.verify_network_selector_enabled()
self._add_networks_selector.click(1, 1)
self.set_ethereum_mainnet_network(True)
self.set_optimism_mainnet_network(True)
self.set_arbitrum_mainnet_network(True)
self._save_add_address_button.click() # click it twice to close the network selector pop up
self.verify_ethereum_mainnet_network_tag_present()
self.verify_otimism_mainnet_network_tag_present()
self.verify_arbitrum_mainnet_network_tag_present(),
self._save_add_address_button.click()
self.wait_until_hidden()
class EditSavedAddressPopup(AddSavedAddressPopup):
def __init__(self):
super(EditSavedAddressPopup, self).__init__()
self._address_text_label = TextLabel('mainWallet_Saved_Addreses_Popup_Address_Input_Edit')
@allure.step('Edit saved address')
def edit_saved_address(self, new_name: str, address: str):
self._name_text_edit.text = new_name
if address.startswith("0x"):
self._add_networks_button.click()
self.set_ethereum_mainnet_network(False)
self.set_optimism_mainnet_network(False)
self.set_arbitrum_mainnet_network(False)
self._save_add_address_button.click()
self._save_add_address_button.click()
self.wait_until_hidden()

View File

@ -0,0 +1,16 @@
import allure
from gui.elements.qt.button import Button
from gui.elements.qt.object import QObject
class ConfirmationPopup(QObject):
def __init__(self):
super(ConfirmationPopup, self).__init__('contextMenu_PopupItem')
self._confirm_button = Button('confirmButton')
@allure.step('Confirm action')
def confirm(self):
self._confirm_button.click()
self.wait_until_hidden()

View File

@ -26,8 +26,9 @@ class TextEdit(QObject):
return self
@allure.step('Clear {0}')
def clear(self):
def clear(self, verify: bool = True):
self.object.clear()
if verify:
assert driver.waitFor(lambda: not self.text), \
f'Clear text field failed, value in field: "{self.text}"'
return self

View File

@ -18,6 +18,7 @@ from gui.screens.community import CommunityScreen
from gui.screens.community_portal import CommunitiesPortal
from gui.screens.onboarding import AllowNotificationsView, WelcomeView, TouchIDAuthView, LoginView
from gui.screens.settings import SettingsScreen
from gui.screens.wallet import WalletScreen
from scripts.tools.image import Image
_logger = logging.getLogger(__name__)
@ -31,6 +32,7 @@ class LeftPanel(QObject):
self._communities_portal_button = Button('communities_Portal_navbar_StatusNavBarTabButton')
self._community_template_button = Button('statusCommunityMainNavBarListView_CommunityNavBarButton')
self._settings_button = Button('settings_navbar_StatusNavBarTabButton')
self._wallet_button = Button('wallet_navbar_StatusNavBarTabButton')
@property
@allure.step('Get communities names')
@ -89,6 +91,10 @@ class LeftPanel(QObject):
self._settings_button.click()
return SettingsScreen().wait_until_appears()
@allure.step('Open Wallet section')
def open_wallet(self) -> WalletScreen:
self._wallet_button.click()
return WalletScreen().wait_until_appears()
class MainWindow(Window):

View File

@ -4,3 +4,4 @@ from .main_names import *
from .onboarding_names import *
from .os_names import *
from .settings_names import *
from .wallet_names import *

View File

@ -1,6 +1,7 @@
from objectmaphelper import *
from . main_names import statusDesktop_mainWindow_overlay
from . main_names import statusDesktop_mainWindow
# Scroll
o_Flickable = {"container": statusDesktop_mainWindow_overlay, "type": "Flickable", "unnamed": 1, "visible": True}
@ -99,3 +100,29 @@ communitySettings_SaveColor_Button = {"container": statusDesktop_mainWindow_over
# Select Tag Popup
o_StatusCommunityTag = {"container": statusDesktop_mainWindow_overlay, "type": "StatusCommunityTag", "unnamed": 1, "visible": True}
confirm_Community_Tags_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "type": "StatusButton", "unnamed": 1, "visible": True}
# Signing phrase popup
signPhrase_Ok_Button = {"container": statusDesktop_mainWindow, "type": "StatusFlatButton", "objectName": "signPhraseModalOkButton", "visible": True}
# Add saved address popup
mainWallet_Saved_Addreses_Popup_Name_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressNameInput", "type": "TextEdit"}
mainWallet_Saved_Addreses_Popup_Address_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressAddressInput", "type": "StatusInput"}
mainWallet_Saved_Addreses_Popup_Address_Input_Edit = {"container": statusDesktop_mainWindow, "objectName": "savedAddressAddressInputEdit", "type": "TextEdit"}
mainWallet_Saved_Addreses_Popup_Address_Add_Button = {"container": statusDesktop_mainWindow, "objectName": "addSavedAddress", "type": "StatusButton"}
mainWallet_Saved_Addreses_Popup_Add_Network_Selector = {"container": statusDesktop_mainWindow, "objectName": "addSavedAddressNetworkSelector", "type": "StatusNetworkSelector", "visible": True}
mainWallet_Saved_Addreses_Popup_Add_Network_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "addNetworkTagItemButton", "type": "StatusRoundButton", "visible": True}
mainWallet_Saved_Addreses_Popup_Add_Network_Selector_Tag = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkSelectorTag", "type": "StatusNetworkListItemTag"}
mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Mainnet_checkbox = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkSelectionCheckbox_Mainnet", "type": "StatusCheckBox", "visible": True}
mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Optimism_checkbox = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkSelectionCheckbox_Optimism", "type": "StatusCheckBox", "visible": True}
mainWallet_Saved_Addresses_Popup_Add_Network_Selector_Arbitrum_checkbox = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkSelectionCheckbox_Arbitrum", "type": "StatusCheckBox", "visible": True}
mainWallet_Saved_Addresses_Popup_Network_Selector_Mainnet_network_tag = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_Mainnet", "type": "Rectangle", "visible": True}
mainWallet_Saved_Addresses_Popup_Network_Selector_Optimism_network_tag = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_Optimism", "type": "Rectangle", "visible": True}
mainWallet_Saved_Addresses_Popup_Network_Selector_Arbitrum_network_tag = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_Arbitrum", "type": "Rectangle", "visible": True}
# Context Menu
contextMenu_PopupItem = {"container": statusDesktop_mainWindow_overlay, "type": "PopupItem", "unnamed": 1, "visible": True}
contextMenuItem = {"container": statusDesktop_mainWindow_overlay, "type": "StatusBaseText", "unnamed": 1, "visible": True}
# Confirmation Popup
confirmButton = {"container": statusDesktop_mainWindow_overlay, "objectName": RegularExpression("confirm*"), "type": "StatusButton"}

View File

@ -2,6 +2,9 @@ statusDesktop_mainWindow = {"name": "mainWindow", "type": "StatusWindow", "visib
statusDesktop_mainWindow_overlay = {"container": statusDesktop_mainWindow, "type": "Overlay", "unnamed": 1, "visible": True}
splashScreen = {"container": statusDesktop_mainWindow, "objectName": "splashScreen", "type": "DidYouKnowSplashScreen"}
# Main right panel
mainWindow_RighPanel = {"container": statusDesktop_mainWindow, "type": "ColumnLayout", "objectName": "mainRightView", "visible": True}
# Navigation Panel
mainWindow_StatusAppNavBar = {"container": statusDesktop_mainWindow, "type": "StatusAppNavBar", "unnamed": 1, "visible": True}
messages_navbar_StatusNavBarTabButton = {"checkable": True, "container": mainWindow_StatusAppNavBar, "objectName": "Messages-navbar", "type": "StatusNavBarTabButton", "visible": True}

View File

@ -0,0 +1,20 @@
from objectmaphelper import *
from . main_names import *
mainWindow_WalletLayout = {"container": statusDesktop_mainWindow, "type": "WalletLayout", "unnamed": 1, "visible": True}
# Left Wallet Panel
mainWallet_LeftTab = {"container": statusDesktop_mainWindow, "objectName": "walletLeftTab", "type": "LeftTabView", "visible": True}
mainWallet_Saved_Addresses_Button = {"container": mainWindow_RighPanel, "objectName": "savedAddressesBtn", "type": "StatusFlatButton"}
walletAccounts_StatusListView = {"container": statusDesktop_mainWindow, "objectName": "walletAccountsListView", "type": "StatusListView", "visible": True}
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}
# Saved Address View
mainWindow_SavedAddressesView = {"container": mainWindow_WalletLayout, "type": "SavedAddressesView", "unnamed": 1, "visible": True}
mainWallet_Saved_Addreses_Add_Buttton = {"container": mainWindow_SavedAddressesView, "objectName": "addNewAddressBtn", "type": "StatusButton"}
mainWallet_Saved_Addreses_List = {"container": mainWindow_SavedAddressesView, "objectName": "SavedAddressesView_savedAddresses", "type": "StatusListView"}
savedAddressView_Delegate = {"container": mainWallet_Saved_Addreses_List, "objectName": RegularExpression("savedAddressView_Delegate*"), "type": "SavedAddressesDelegate", "visible": True}
send_StatusRoundButton = {"container": "", "type": "StatusRoundButton", "unnamed": 1, "visible": True}
savedAddressView_Delegate_menuButton = {"container": mainWindow_SavedAddressesView, "objectName": RegularExpression("savedAddressView_Delegate_menuButton*"), "type": "StatusRoundButton", "visible": True}

View File

@ -0,0 +1,76 @@
import allure
import driver
from gui.components.base_popup import BasePopup
from gui.components.wallet.add_saved_address_popup import AddressPopup, EditSavedAddressPopup
from gui.components.wallet.confirmation_popup import ConfirmationPopup
from gui.components.context_menu import ContextMenu
from gui.elements.qt.button import Button
from gui.elements.qt.object import QObject
from scripts.utils.decorators import close_exists
class WalletScreen(QObject):
def __init__(self):
super().__init__('mainWindow_WalletLayout')
self.left_panel = LeftPanel()
class LeftPanel(QObject):
def __init__(self):
super(LeftPanel, self).__init__('mainWallet_LeftTab')
self._saved_addresses_button = Button('mainWallet_Saved_Addresses_Button')
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')
@allure.step('Choose saved addresses on left wallet panel')
@close_exists(BasePopup())
def open_saved_addresses(self) -> 'SavedAddressesView':
self._saved_addresses_button.click()
return SavedAdressesView().wait_until_appears()
class SavedAdressesView(QObject):
def __init__(self):
super(SavedAdressesView, self).__init__('mainWindow_SavedAddressesView')
self._add_new_address_button = Button('mainWallet_Saved_Addreses_Add_Buttton')
self._address_list_item = QObject('savedAddressView_Delegate')
self._send_button = Button('send_StatusRoundButton')
self._open_menu_button = Button('savedAddressView_Delegate_menuButton')
@property
@allure.step('Get saved addresses names')
def address_names(self):
names = [str(address.name) for address in driver.findAllObjects(self._address_list_item.real_name)]
return names
@allure.step('Open add new address popup')
def open_add_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)
else:
raise err
@allure.step('Open edit address popup for saved address')
def open_edit_address_popup(self, name: str) -> 'EditSavedAddressPopup':
self.open_context_menu(name).select('Edit')
return EditSavedAddressPopup().wait_until_appears()
@allure.step('Delete saved address from the list')
def delete_saved_address(self, address_name):
self.open_context_menu(address_name).select('Delete')
ConfirmationPopup().wait_until_appears().confirm()
@allure.step('Open context menu in saved address')
def open_context_menu(self, name) -> ContextMenu:
self._open_menu_button.real_name['objectName'] = 'savedAddressView_Delegate_menuButton' + '_' + name
self._open_menu_button.click()
return ContextMenu().wait_until_appears()

View File

@ -0,0 +1,10 @@
def close_exists(element):
def _wrapper(method_to_decorate):
def wrapper(*args, **kwargs):
if element.is_visible:
element.close()
return method_to_decorate(*args, **kwargs)
return wrapper
return _wrapper

View File

@ -0,0 +1,46 @@
import time
import allure
import pytest
from allure import step
import configs.timeouts
import driver
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.main_window import MainWindow
pytestmark = allure.suite("Wallet")
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703021', 'Manage a saved address')
@pytest.mark.case(703021)
@pytest.mark.parametrize('name, address, new_name', [
pytest.param('Saved address name before', '0x8397bc3c5a60a1883174f722403d63a8833312b7', 'Saved address name after'),
pytest.param('Ens name before', 'nastya.stateofus.eth', 'Ens name after')
])
def test_manage_saved_address(main_screen: MainWindow, name: str, address: str, new_name: str):
with step('Add new address'):
wallet = main_screen.left_panel.open_wallet()
SigningPhrasePopup().wait_until_appears().confirm_phrase()
wallet.left_panel.open_saved_addresses().open_add_address_popup().add_saved_address(name, address)
with step('Verify that saved address is in the list of saved addresses'):
assert driver.waitFor(
lambda: name in wallet.left_panel.open_saved_addresses().address_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found'
with step('Edit saved address to new name'):
wallet.left_panel.open_saved_addresses().open_edit_address_popup(name).edit_saved_address(new_name, address)
with step('Verify that saved address with new name is in the list of saved addresses'):
assert driver.waitFor(
lambda: new_name in wallet.left_panel.open_saved_addresses().address_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found'
with step('Delete address with new name'):
wallet.left_panel.open_saved_addresses().delete_saved_address(new_name)
with step('Verify that saved address with new name is not in the list of saved addresses'):
assert driver.waitFor(
lambda: new_name not in wallet.left_panel.open_saved_addresses().address_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found'