chore: remove repetitive code and re-order some classes
This commit is contained in:
parent
ed8c727673
commit
d814ec12ef
|
@ -9,3 +9,4 @@ def get_platform():
|
|||
DISPLAY = os.getenv('DISPLAY', ':0')
|
||||
|
||||
TEST_MODE = os.getenv('STATUS_RUNTIME_TEST_MODE')
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import random
|
||||
import time
|
||||
|
||||
import configs.timeouts
|
||||
from constants.wallet import *
|
||||
from gui.screens.settings_keycard import KeycardSettingsView
|
||||
from gui.screens.settings_wallet import *
|
||||
from gui.components.base_popup import BasePopup
|
||||
from gui.components.emoji_popup import EmojiPopup
|
||||
|
@ -155,7 +157,8 @@ class AccountPopup(BasePopup):
|
|||
self._origin_combobox.click()
|
||||
self.click_new_master_key()
|
||||
self._use_keycard_button.click()
|
||||
return self
|
||||
assert KeycardSettingsView().exists, 'Keycard settings view was not opened'
|
||||
return KeycardSettingsView()
|
||||
|
||||
@allure.step('Click confirmation (add account / save changes) button')
|
||||
def save_changes(self):
|
||||
|
|
|
@ -18,7 +18,6 @@ from gui.components.online_identifier import OnlineIdentifier
|
|||
from gui.elements.button import Button
|
||||
from gui.elements.object import QObject
|
||||
from gui.elements.window import Window
|
||||
from gui.mocked_keycard_controller import MockedKeycardController
|
||||
from gui.objects_map import names
|
||||
from gui.screens.community import CommunityScreen
|
||||
from gui.screens.community_portal import CommunitiesPortal
|
||||
|
@ -153,7 +152,7 @@ class LeftPanel(QObject):
|
|||
|
||||
@allure.step('Open Wallet section')
|
||||
def open_wallet(self, attempts: int = 3) -> WalletScreen:
|
||||
self._wallet_button.click()
|
||||
self._wallet_button.click(timeout=10)
|
||||
try:
|
||||
return WalletScreen()
|
||||
except Exception as ex:
|
||||
|
@ -169,9 +168,7 @@ class MainWindow(Window):
|
|||
super(MainWindow, self).__init__(names.statusDesktop_mainWindow)
|
||||
self.left_panel = LeftPanel()
|
||||
|
||||
# TODO: we need to handle all the issues with keycard mock var before using keycard window in tests
|
||||
def prepare(self) -> 'Window':
|
||||
# MockedKeycardController().wait_until_appears().hide()
|
||||
return super().prepare()
|
||||
|
||||
@allure.step('Sign Up user')
|
||||
|
|
|
@ -65,6 +65,7 @@ factoryResetKeycard_StatusListItem = {"container": settingsContentBase_ScrollVie
|
|||
# Wallet Settings View
|
||||
mainWindow_WalletView = {"container": statusDesktop_mainWindow, "type": "WalletView", "unnamed": 1, "visible": True}
|
||||
settings_Wallet_MainView_Networks = {"container": statusDesktop_mainWindow, "objectName": "networksItem", "type": "StatusListItem"}
|
||||
settings_Wallet_MainView_Manage_Tokens = {"container": settingsContentBase_ScrollView, "objectName": "manageTokensItem", "type": "StatusListItem", "visible": True}
|
||||
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}
|
||||
|
|
|
@ -42,7 +42,6 @@ arrow_icon_StatusIcon = {"container": statusDesktop_mainWindow_overlay, "objectN
|
|||
collectible_item = {"container": mainWindow_RightTabView, "type": "CollectibleView", "unnamed": 1, "visible": True}
|
||||
mainWindow_settingsContentBaseScrollView_StatusScrollView_general = {"container": statusDesktop_mainWindow, "objectName": "settingsContentBaseScrollView", "type": "StatusScrollView", "visible": True}
|
||||
settingsContentBaseScrollView_manageTokensDelegate_ManageTokensDelegate = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView_general, "objectName": RegularExpression("manageTokensDelegate-*"), "type": "ManageTokensDelegate", "visible": True}
|
||||
settingsContentBaseScrollView_manageTokensView_ManageTokensView = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView_general, "id": "manageTokensView", "type": "ManageTokensView", "unnamed": 1, "visible": True}
|
||||
|
||||
mainWindow_Save_and_apply_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "text": "Save and apply", "type": "StatusButton", "visible": True}
|
||||
mainWindow_Save_StatusFlatButton = {"checkable": False, "container": statusDesktop_mainWindow, "id": "saveForLaterButton", "text": "Save", "type": "StatusFlatButton", "unnamed": 1, "visible": True}
|
||||
|
|
|
@ -2,7 +2,7 @@ import time
|
|||
|
||||
import allure
|
||||
|
||||
import driver
|
||||
import configs.system
|
||||
from gui.components.back_up_your_seed_phrase_popup import BackUpYourSeedPhrasePopUp
|
||||
from gui.elements.object import QObject
|
||||
from gui.elements.scroll import Scroll
|
||||
|
@ -17,6 +17,26 @@ from gui.screens.settings_syncing import SyncingSettingsView
|
|||
from gui.screens.settings_wallet import WalletSettingsView
|
||||
from gui.screens.settings_password import ChangePasswordView
|
||||
from gui.components.settings.sign_out_popup import SignOutPopup
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def handle_settings_opening(view_class, menu_item):
|
||||
def open_settings_decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(self, click_attempts=2):
|
||||
self._open_settings(menu_item)
|
||||
try:
|
||||
return func(self)
|
||||
except (LookupError, AssertionError) as ex:
|
||||
if click_attempts:
|
||||
|
||||
return func(self, click_attempts - 1)
|
||||
else:
|
||||
raise ex
|
||||
|
||||
return wrapper
|
||||
|
||||
return open_settings_decorator
|
||||
|
||||
|
||||
class LeftPanel(QObject):
|
||||
|
@ -25,7 +45,7 @@ class LeftPanel(QObject):
|
|||
super().__init__(settings_names.mainWindow_LeftTabView)
|
||||
self._settings_section_template = QObject(settings_names.scrollView_MenuItem_StatusNavigationListItem)
|
||||
self._scroll = Scroll(settings_names.mainWindow_scrollView_StatusScrollView)
|
||||
self._settings_section_back_up_seed_option = QObject(settings_names.settingsBackUpSeedPhraseOption)
|
||||
self.settings_section_back_up_seed_option = QObject(settings_names.settingsBackUpSeedPhraseOption)
|
||||
self._settings_section_wallet_option = QObject(settings_names.settingsWalletOption)
|
||||
|
||||
def _open_settings(self, object_name: str):
|
||||
|
@ -34,78 +54,70 @@ class LeftPanel(QObject):
|
|||
self._scroll.vertical_scroll_down(self._settings_section_template)
|
||||
self._settings_section_template.click()
|
||||
|
||||
@allure.step('Check back up seed option menu item presence')
|
||||
def check_back_up_seed_option_present(self):
|
||||
return self._settings_section_back_up_seed_option.exists
|
||||
|
||||
@allure.step('Open messaging settings')
|
||||
def open_messaging_settings(self) -> 'MessagingSettingsView':
|
||||
self._open_settings('4-AppMenuItem')
|
||||
@handle_settings_opening(MessagingSettingsView, '4-AppMenuItem')
|
||||
def open_messaging_settings(self, click_attempts: int = 2) -> 'MessagingSettingsView':
|
||||
assert MessagingSettingsView().exists, 'Messaging settings view was not opened'
|
||||
return MessagingSettingsView()
|
||||
|
||||
@allure.step('Open communities settings')
|
||||
@handle_settings_opening(CommunitiesSettingsView, '13-AppMenuItem')
|
||||
def open_communities_settings(self, attempts: int = 2) -> 'CommunitiesSettingsView':
|
||||
self._open_settings('13-AppMenuItem')
|
||||
try:
|
||||
return CommunitiesSettingsView()
|
||||
except Exception as ex:
|
||||
if attempts:
|
||||
self.open_communities_settings(attempts-1)
|
||||
else:
|
||||
raise ex
|
||||
assert CommunitiesSettingsView().exists, 'Community settings view was not opened'
|
||||
return CommunitiesSettingsView()
|
||||
|
||||
@allure.step('Open wallet settings')
|
||||
def open_wallet_settings(self) -> 'WalletSettingsView':
|
||||
self._open_settings('5-AppMenuItem')
|
||||
assert WalletSettingsView().exists, 'Wallet view was not opened'
|
||||
@handle_settings_opening(WalletSettingsView, '5-AppMenuItem')
|
||||
def open_wallet_settings(self, click_attempts: int = 2) -> 'WalletSettingsView':
|
||||
assert WalletSettingsView().exists, 'Wallet settings view was not opened'
|
||||
return WalletSettingsView()
|
||||
|
||||
@allure.step('Open profile settings')
|
||||
def open_profile_settings(self) -> 'ProfileSettingsView':
|
||||
self._open_settings('0-MainMenuItem')
|
||||
@handle_settings_opening(ProfileSettingsView, '0-MainMenuItem')
|
||||
def open_profile_settings(self, click_attempts: int = 2) -> 'ProfileSettingsView':
|
||||
assert ProfileSettingsView().exists, 'Profile settings view was not opened'
|
||||
return ProfileSettingsView()
|
||||
|
||||
@allure.step('Open password settings')
|
||||
def open_password_settings(self) -> 'ChangePasswordView':
|
||||
self._open_settings('1-MainMenuItem')
|
||||
@handle_settings_opening(ChangePasswordView, '1-MainMenuItem')
|
||||
def open_password_settings(self, click_attempts: int = 2) -> 'ChangePasswordView':
|
||||
assert ChangePasswordView().exists, 'Password settings view was not opened'
|
||||
return ChangePasswordView()
|
||||
|
||||
@allure.step('Choose back up seed phrase in settings')
|
||||
def open_back_up_seed_phrase(self) -> 'BackUpYourSeedPhrasePopUp':
|
||||
self._open_settings('18-MainMenuItem')
|
||||
@handle_settings_opening(BackUpYourSeedPhrasePopUp, '18-MainMenuItem')
|
||||
def open_back_up_seed_phrase(self, click_attempts: int = 2) -> 'BackUpYourSeedPhrasePopUp':
|
||||
assert BackUpYourSeedPhrasePopUp().exists, 'Back up your seed phrase modal was not opened'
|
||||
return BackUpYourSeedPhrasePopUp()
|
||||
|
||||
@allure.step('Open syncing settings')
|
||||
def open_syncing_settings(self, attempts: int = 2) -> 'SyncingSettingsView':
|
||||
self._open_settings('9-MainMenuItem')
|
||||
try:
|
||||
return SyncingSettingsView().wait_until_appears()
|
||||
except (AssertionError, LookupError) as ec:
|
||||
if attempts:
|
||||
return self.open_syncing_settings(attempts - 1)
|
||||
else:
|
||||
raise ec
|
||||
@handle_settings_opening(SyncingSettingsView, '9-MainMenuItem')
|
||||
def open_syncing_settings(self, click_attempts: int = 2) -> 'SyncingSettingsView':
|
||||
assert SyncingSettingsView().exists, 'Syncing settings view was not opened'
|
||||
return SyncingSettingsView()
|
||||
|
||||
@allure.step('Choose sign out and quit in settings')
|
||||
def open_sign_out_and_quit(self) -> 'SignOutPopup':
|
||||
self._open_settings('17-ExtraMenuItem')
|
||||
@handle_settings_opening(SignOutPopup, '17-ExtraMenuItem')
|
||||
def open_sign_out_and_quit(self, click_attempts: int = 2) -> 'SignOutPopup':
|
||||
assert SignOutPopup().exists, 'Sign out modal was not opened'
|
||||
return SignOutPopup()
|
||||
|
||||
@allure.step('Open keycard settings')
|
||||
def open_keycard_settings(self) -> 'KeycardSettingsView':
|
||||
self._open_settings('14-MainMenuItem')
|
||||
@handle_settings_opening(KeycardSettingsView, '14-MainMenuItem')
|
||||
def open_keycard_settings(self, click_attempts: int = 2) -> 'KeycardSettingsView':
|
||||
assert KeycardSettingsView().exists, 'Keycard settings view was not opened'
|
||||
return KeycardSettingsView()
|
||||
|
||||
@allure.step('Open ENS usernames settings')
|
||||
def open_ens_usernames_settings(self) -> 'ENSSettingsView':
|
||||
time.sleep(1)
|
||||
self._open_settings('3-MainMenuItem')
|
||||
@handle_settings_opening(ENSSettingsView, '3-MainMenuItem')
|
||||
def open_ens_usernames_settings(self, click_attempts: int = 2) -> 'ENSSettingsView':
|
||||
assert ENSSettingsView().exists, 'ENS settings view was not opened'
|
||||
return ENSSettingsView()
|
||||
|
||||
@allure.step('Open advanced settings')
|
||||
def open_advanced_settings(self) -> 'AdvancedSettingsView':
|
||||
time.sleep(1)
|
||||
self._open_settings('11-SettingsMenuItem')
|
||||
@handle_settings_opening(AdvancedSettingsView, '11-SettingsMenuItem')
|
||||
def open_advanced_settings(self, click_attempts: int = 2) -> 'AdvancedSettingsView':
|
||||
assert AdvancedSettingsView().exists, 'Advanced settings view was not opened'
|
||||
return AdvancedSettingsView()
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import allure
|
|||
from objectmaphelper import RegularExpression
|
||||
|
||||
import configs.timeouts
|
||||
import constants
|
||||
import driver
|
||||
from constants import wallet_account_list_item
|
||||
from constants.wallet import WalletNetworkSettings, WalletNetworkDefaultValues
|
||||
|
@ -22,7 +23,7 @@ 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
|
||||
from gui.objects_map import settings_names
|
||||
from gui.objects_map import settings_names, wallet_names
|
||||
|
||||
|
||||
class WalletSettingsView(QObject):
|
||||
|
@ -32,6 +33,7 @@ class WalletSettingsView(QObject):
|
|||
self._scroll = Scroll(settings_names.settingsContentBase_ScrollView)
|
||||
self._wallet_settings_add_new_account_button = Button(settings_names.settings_Wallet_MainView_AddNewAccountButton)
|
||||
self._wallet_network_button = Button(settings_names.settings_Wallet_MainView_Networks)
|
||||
self._wallet_manage_tokens_button = Button(settings_names.settings_Wallet_MainView_Manage_Tokens)
|
||||
self._account_order_button = Button(settings_names.settingsContentBaseScrollView_accountOrderItem_StatusListItem)
|
||||
self._saved_addresses_button = Button(settings_names.settingsContentBaseScrollView_savedAddressesItem_StatusListItem)
|
||||
self._status_account_in_keypair = QObject(settings_names.settingsWalletAccountDelegate_Status_account)
|
||||
|
@ -74,6 +76,17 @@ class WalletSettingsView(QObject):
|
|||
else:
|
||||
raise err
|
||||
|
||||
@allure.step('Open manage tokens in wallet settings')
|
||||
def open_manage_tokens(self, attempts: int = 2) -> 'ManageTokensSettingsView':
|
||||
self._wallet_manage_tokens_button.click()
|
||||
try:
|
||||
return ManageTokensSettingsView().wait_until_appears()
|
||||
except Exception as err:
|
||||
if attempts:
|
||||
return self.open_manage_tokens(attempts - 1)
|
||||
else:
|
||||
raise err
|
||||
|
||||
@allure.step('Open account order in wallet settings')
|
||||
def open_account_order(self):
|
||||
self._account_order_button.click()
|
||||
|
@ -559,3 +572,30 @@ class EditAccountOrderSettings(WalletSettingsView):
|
|||
@allure.step('Verify that back button is present')
|
||||
def is_back_button_present(self) -> bool:
|
||||
return self._back_button.is_visible
|
||||
|
||||
|
||||
class ManageTokensSettingsView(WalletSettingsView):
|
||||
|
||||
def __init__(self):
|
||||
super(ManageTokensSettingsView, self).__init__()
|
||||
self._window_item = QObject(wallet_names.statusDesktop_mainWindow)
|
||||
self._token_item = QObject(wallet_names.settingsContentBaseScrollView_manageTokensDelegate_ManageTokensDelegate)
|
||||
|
||||
@property
|
||||
@allure.step('Get tokens')
|
||||
def tokens(self) -> typing.List[constants.token_list_item]:
|
||||
_tokens = []
|
||||
for token_item in driver.findAllObjects(self._token_item.real_name):
|
||||
element = QObject(real_name=driver.objectMap.realName(token_item))
|
||||
name = str(token_item.title)
|
||||
_tokens.append(constants.token_list_item(name, element))
|
||||
|
||||
return sorted(_tokens, key=lambda token: token.object.y)
|
||||
|
||||
@allure.step('Drag token to change the order')
|
||||
def drag_token(self, name: str, index: int):
|
||||
assert driver.waitFor(lambda: len([token for token in self.tokens if token.title == name]) == 1), \
|
||||
'Token not found or found more then one'
|
||||
bounds = [token for token in self.tokens if token.title == name][0].object.bounds
|
||||
d_bounds = self.tokens[index].object.bounds
|
||||
driver.mouse.press_and_move(self._window_item.object, bounds.x, bounds.y, d_bounds.x, d_bounds.y + 1)
|
||||
|
|
|
@ -6,7 +6,6 @@ import allure
|
|||
import configs
|
||||
import constants.user
|
||||
import driver
|
||||
from driver import objects_access
|
||||
from driver.objects_access import walk_children
|
||||
from gui.components.base_popup import BasePopup
|
||||
from gui.components.context_menu import ContextMenu
|
||||
|
@ -190,33 +189,6 @@ class SavedAddressesView(QObject):
|
|||
return ContextMenu().wait_until_appears()
|
||||
|
||||
|
||||
class ManageTokensView(QObject):
|
||||
|
||||
def __init__(self):
|
||||
super(ManageTokensView, self).__init__(wallet_names.settingsContentBaseScrollView_manageTokensView_ManageTokensView)
|
||||
self._window_item = QObject(wallet_names.statusDesktop_mainWindow)
|
||||
self._token_item = QObject(wallet_names.settingsContentBaseScrollView_manageTokensDelegate_ManageTokensDelegate)
|
||||
|
||||
@property
|
||||
@allure.step('Get tokens')
|
||||
def tokens(self) -> typing.List[constants.token_list_item]:
|
||||
_tokens = []
|
||||
for token_item in driver.findAllObjects(self._token_item.real_name):
|
||||
element = QObject(real_name=driver.objectMap.realName(token_item))
|
||||
name = str(token_item.title)
|
||||
_tokens.append(constants.token_list_item(name, element))
|
||||
|
||||
return sorted(_tokens, key=lambda token: token.object.y)
|
||||
|
||||
@allure.step('Drag token to change the order')
|
||||
def drag_token(self, name: str, index: int):
|
||||
assert driver.waitFor(lambda: len([token for token in self.tokens if token.title == name]) == 1), \
|
||||
'Token not found or found more then one'
|
||||
bounds = [token for token in self.tokens if token.title == name][0].object.bounds
|
||||
d_bounds = self.tokens[index].object.bounds
|
||||
driver.mouse.press_and_move(self._window_item.object, bounds.x, bounds.y, d_bounds.x, d_bounds.y + 1)
|
||||
|
||||
|
||||
class WalletAccountView(QObject):
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
@ -3,9 +3,9 @@ import random
|
|||
import string
|
||||
|
||||
import allure
|
||||
import psutil
|
||||
import pytest
|
||||
from allure import step
|
||||
|
||||
from . import marks
|
||||
|
||||
import configs.timeouts
|
||||
|
|
|
@ -16,7 +16,7 @@ pytestmark = marks
|
|||
def test_back_up_seed_phrase(main_screen: MainWindow):
|
||||
with step('Check back up seed phrase option is visible for new account'):
|
||||
settings = main_screen.left_panel.open_settings()
|
||||
assert settings.left_panel.check_back_up_seed_option_present(), f"Back up seed option is not present"
|
||||
assert settings.left_panel.settings_section_back_up_seed_option.exists, f"Back up seed option is not present"
|
||||
if not configs.system.TEST_MODE:
|
||||
assert BackUpSeedPhraseBanner().does_back_up_seed_banner_exist(), "Back up seed banner is not present"
|
||||
assert BackUpSeedPhraseBanner().is_back_up_now_button_present(), 'Back up now button is not present'
|
||||
|
@ -26,7 +26,7 @@ def test_back_up_seed_phrase(main_screen: MainWindow):
|
|||
back_up.back_up_seed_phrase()
|
||||
|
||||
with step('Verify back up seed phrase banner disappeared'):
|
||||
assert not settings.left_panel.check_back_up_seed_option_present(), f"Back up seed option is present"
|
||||
assert not settings.left_panel.settings_section_back_up_seed_option.exists, f"Back up seed option is present"
|
||||
if not configs.system.TEST_MODE:
|
||||
BackUpSeedPhraseBanner().wait_to_hide_the_banner()
|
||||
assert not BackUpSeedPhraseBanner().does_back_up_seed_banner_exist(), "Back up seed banner is present"
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import time
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from allure_commons._allure import step
|
||||
|
||||
import configs.system
|
||||
import driver
|
||||
from gui.components.changes_detected_popup import CustomSortOrderChangesDetectedToastMessage
|
||||
from gui.screens.wallet import WalletAccountView, ManageTokensView
|
||||
from gui.screens.wallet import WalletAccountView
|
||||
from gui.screens.settings_wallet import ManageTokensSettingsView
|
||||
from tests.wallet_main_screen import marks
|
||||
|
||||
from gui.components.signing_phrase_popup import SigningPhrasePopup
|
||||
|
@ -164,8 +168,8 @@ def test_custom_ordering(main_screen: MainWindow, address, name, dai, wrappedeth
|
|||
wallet_account_view = WalletAccountView()
|
||||
sorting = wallet_account_view.open_assets_tab().click_filter_button()
|
||||
sorting.choose_sort_by_value('Create custom order →')
|
||||
manage_tokens = ManageTokensView()
|
||||
assert manage_tokens.exists
|
||||
manage_tokens = ManageTokensSettingsView()
|
||||
assert manage_tokens.exists, 'Manage tokens view was not opened'
|
||||
|
||||
with step('Drag first token to the end of the list and save changes'):
|
||||
manage_tokens.drag_token(dai, 3)
|
||||
|
@ -190,7 +194,7 @@ def test_custom_ordering(main_screen: MainWindow, address, name, dai, wrappedeth
|
|||
|
||||
with step('Choose Edit custom order in sorting dropdown and verify Manage tokens view appears'):
|
||||
sorting.choose_sort_by_value('Edit custom order →')
|
||||
manage_tokens = ManageTokensView()
|
||||
manage_tokens = ManageTokensSettingsView()
|
||||
assert manage_tokens.exists
|
||||
|
||||
with step('Drag first token to the end of the list and apply changes'):
|
||||
|
|
Loading…
Reference in New Issue