tests(@wallet_settings): edit network (#127)

This commit is contained in:
Anastasiya Semenkevich 2023-10-04 16:46:17 +06:00 committed by GitHub
parent 6de7449f6b
commit ac10eb185a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 198 additions and 24 deletions

View File

@ -14,3 +14,19 @@ class WalletNetworkSettings(Enum):
TESTNET_ENABLED_TOAST_MESSAGE = 'Testnet mode turned on'
TESTNET_DISABLED_TOAST_MESSAGE = 'Testnet mode turned off'
class WalletNetworkNaming(Enum):
LAYER1_ETHEREUM = 'Mainnet'
LAYER2_OPTIMISIM = 'Optimism'
LAYER2_ARBITRUM = 'Arbitrum'
ETHEREUM_MAINNET_NETWORK_ID = 1
ETHEREUM_GOERLI_NETWORK_ID = 5
OPTIMISM_MAINNET_NETWORK_ID = 10
OPTIMISM_GOERLI_NETWORK_ID = 420
ARBITRUM_MAINNET_NETWORK_ID = 42161
ARBITRUM_GOERLI_NETWORK_ID = 421613
class WalletNetworkDefaultValues(Enum):
ETHEREUM_LIVE_MAIN = 'https://eth-archival.gateway.pokt.network/v1/lb/********'
ETHEREUM_LIVE_FAILOVER = 'https://mainnet.infura.io/v3/********************************'

View File

@ -51,6 +51,10 @@ class QObject(BaseObject):
def width(self) -> int:
return int(self.bounds.width)
@allure.step('Get attribute {0}')
def get_object_attribute(self, attr: str):
return getattr(self.object, attr)
@property
@allure.step('Get height {0}')
def height(self) -> int:
@ -118,7 +122,6 @@ class QObject(BaseObject):
assert driver.waitFor(lambda: _hover(), timeout_msec)
return self
@allure.step('Open context menu')
def open_context_menu(
self,

View File

@ -30,5 +30,5 @@ class TextEdit(QObject):
self.object.clear()
if verify:
assert driver.waitFor(lambda: not self.text), \
f'Clear text field failed, value in field: "{self.text}"'
f'Clear text field failed, value in field: "{self.text}"'
return self

View File

@ -46,7 +46,6 @@ 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_WalletNetworkDelegate = {"container": settingsContentBase_ScrollView, "type": "WalletNetworkDelegate", "unnamed": 1, "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}
@ -57,6 +56,30 @@ settingsContentBaseScrollView_accountOrderView_AccountOrderView = {"container":
settingsContentBaseScrollView_StatusBaseText = {"container": settingsContentBase_ScrollView, "type": "StatusBaseText", "unnamed": 1, "visible": True}
mainWindow_StatusToolBar = {"container": statusDesktop_mainWindow, "objectName": "statusToolBar", "type": "StatusToolBar", "visible": True}
main_toolBar_back_button = {"container": mainWindow_StatusToolBar, "objectName": "toolBarBackButton", "type": "StatusFlatButton", "visible": True}
settingsContentBaseScrollView_WalletNetworkDelegate_template = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Mainnet_1", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Mainnet = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Mainnet_1", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Mainnet_Goerli = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Mainnet_5", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Optimism = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Optimism_10", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Optimism_Goerli = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Optimism_420", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Arbitrum = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Arbitrum_42161", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Arbitrum_Goerli = {"container": settingsContentBase_ScrollView, "objectName": "walletNetworkDelegate_Arbitrum_421613", "type": "WalletNetworkDelegate", "visible": True}
networkSettingsNetworks_Mainnet_Goerli_sensor = {"container": networkSettingsNetworks_Mainnet_Goerli, "objectName": "walletNetworkDelegate_Mainnet_5_sensor", "id": "sensor", "type": "MouseArea", "unnamed": 1, "visible": True}
networkSettingsNetowrks_Mainnet_Testlabel = {"container": networkSettingsNetworks_Mainnet_Goerli_sensor, "objectName": "testnetLabel_Mainnet", "type": "StatusBaseText", "visible": True}
# Wallet edit network view
settingsContentBaseScrollView_editPreviwTabBar_StatusTabBar = {"container": statusDesktop_mainWindow, "objectName": "editPreviwTabBar", "type": "StatusTabBar"}
editNetworkLiveButton = {"container": settingsContentBaseScrollView_editPreviwTabBar_StatusTabBar, "objectName": "editNetworkLiveButton", "type": "StatusTabButton"}
editNetworkTestButton = {"container": settingsContentBaseScrollView_editPreviwTabBar_StatusTabBar, "objectName": "editNetworkTestButton", "type": "StatusTabButton"}
editNetworkNameInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkNameInput", "type": "TextEdit"}
editNetworkShortNameInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkShortNameInput", "type": "TextEdit"}
editNetworkChainIdInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkChainIdInput", "type": "TextEdit"}
editNetworkSymbolInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkSymbolInput", "type": "TextEdit"}
editNetworkMainRpcInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkMainRpcInput", "type": "TextEdit", "visible": True}
editNetworkFailoverRpcUrlInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkFailoverRpcUrlInput", "type": "TextEdit", "visible": True}
editNetworkExplorerInput = {"container": statusDesktop_mainWindow, "objectName": "editNetworkExplorerInput", "type": "TextEdit"}
editNetworkAknowledgmentCheckbox = {"container": statusDesktop_mainWindow, "objectName": "editNetworkAknowledgmentCheckbox", "type": "StatusCheckBox", "visible": True}
editNetworkRevertButton = {"container": statusDesktop_mainWindow, "objectName": "editNetworkRevertButton", "type": "StatusButton", "visible": True}
editNetworkSaveButton = {"container": statusDesktop_mainWindow, "objectName": "editNetworkSaveButton", "type": "StatusButton"}
# Profile View
mainWindow_MyProfileView = {"container": statusDesktop_mainWindow, "type": "MyProfileView", "unnamed": 1, "visible": True}

View File

@ -1,3 +1,4 @@
from objectmaphelper import RegularExpression
import time
import typing
@ -5,6 +6,7 @@ import allure
import configs.timeouts
import driver
from constants import UserCommunityInfo, wallet_account_list_item
from constants.syncing import SyncingSettings
from driver import objects_access
@ -18,6 +20,7 @@ from gui.components.social_links_popup import SocialLinksPopup
from gui.components.wallet.testnet_mode_popup import TestnetModePopup
from gui.components.wallet.wallet_account_popups import AccountPopup
from gui.elements.qt.button import Button
from gui.elements.qt.check_box import CheckBox
from gui.elements.qt.list import List
from gui.elements.qt.object import QObject
from gui.elements.qt.scroll import Scroll
@ -367,16 +370,33 @@ class NetworkWalletSettings(WalletSettingsView):
def __init__(self):
super(NetworkWalletSettings, self).__init__()
self._wallet_networks_item = QObject('settingsContentBaseScrollView_WalletNetworkDelegate')
self._testnet_text_item = QObject('settingsContentBaseScrollView_Goerli_testnet_active_StatusBaseText')
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')
self._mainnet_network_item = QObject('networkSettingsNetworks_Mainnet')
self._mainnet_goerli_network_item = QObject('networkSettingsNetworks_Mainnet_Goerli')
self._mainnet_goerli_network_item_test_label = TextLabel('networkSettingsNetowrks_Mainnet_Testlabel')
self._optimism_network_item = QObject('networkSettingsNetworks_Optimism')
self._optimism_goerli_network_item = QObject('networkSettingsNetworks_Optimism_Goerli')
self._arbitrum_network_item = QObject('networkSettingsNetworks_Arbitrum')
self._arbitrum__goerli_network_item = QObject('networkSettingsNetworks_Arbitrum_Goerli')
self._wallet_network_item_template = QObject('settingsContentBaseScrollView_WalletNetworkDelegate_template')
self._wallet_network_item_goerli_sensor = QObject('networkSettingsNetworks_Mainnet_Goerli_sensor')
self._wallet_network_item_goerli_testlabel = TextLabel('networkSettingsNetowrks_Mainnet_Testlabel')
@property
@allure.step('Get wallet networks items')
def networks_names(self) -> typing.List[str]:
return [str(network.title) for network in driver.findAllObjects(self._wallet_networks_item.real_name)]
@allure.step('Check networks item title')
def get_network_item_attribute_by_id_and_attr_name(self, attribute_name, network_id):
self._wallet_network_item_template.real_name['objectName'] = RegularExpression(
f'walletNetworkDelegate_.*_{network_id}')
return self._wallet_network_item_template.get_object_attribute(attribute_name)
@allure.step('Open network to check the details')
def click_network_item_to_open_edit_view(self, network_id):
self._wallet_network_item_template.real_name['objectName'] \
= RegularExpression(f'walletNetworkDelegate_.*_{network_id}')
self._wallet_network_item_template.click()
return EditNetworkSettings().wait_until_appears()
@allure.step('Verify Testnet toggle subtitle')
def get_testnet_toggle_subtitle(self):
@ -405,6 +425,74 @@ class NetworkWalletSettings(WalletSettingsView):
return self._testnet_mode_toggle.is_checked
class EditNetworkSettings(WalletSettingsView):
def __init__(self):
super(EditNetworkSettings, self).__init__()
self._live_network_tab = Button('editNetworkLiveButton')
self._test_network_tab = Button('editNetworkTestButton')
self._network_name = TextEdit('editNetworkNameInput')
self._network_short_name = TextEdit('editNetworkShortNameInput')
self._network_chaid_id = TextEdit('editNetworkChainIdInput')
self._network_native_token_symbol = TextEdit('editNetworkSymbolInput')
self._network_main_json_rpc_url = TextEdit('editNetworkMainRpcInput')
self._network_failover_json_rpc_url = TextEdit('editNetworkFailoverRpcUrlInput')
self._network_block_explorer = TextEdit('editNetworkExplorerInput')
self._network_acknowledgment_checkbox = CheckBox('editNetworkAknowledgmentCheckbox')
self._network_revert_to_default = Button('editNetworkRevertButton')
self._network_save_changes = Button('editNetworkSaveButton')
self._network_edit_view_back_button = Button('main_toolBar_back_button')
self._network_edit_scroll = Scroll('settingsContentBaseScrollView_Flickable')
@allure.step('Verify elements for the edit network view')
def check_available_elements_on_edit_view(self):
assert self._network_edit_view_back_button.exists, f"Back button is not present"
assert self._live_network_tab.exists, f"Live tab is not present"
assert self._test_network_tab.exists, f"Test tab is not present"
assert self._network_name.exists, f"Network name input field is not present"
assert self._network_short_name.exists, f"Short name input field is not present"
assert self._network_chaid_id.exists, f"Chaid Id input field is not present"
assert self._network_native_token_symbol.exists, f"Native token symbol input field is not present"
assert self._network_main_json_rpc_url.exists, f"Main JSON RPC URL input field is not present"
assert self._network_failover_json_rpc_url.exists, f"Failover JSON RPC URL input field is not present"
assert self._network_block_explorer.exists, f"Block explorer input field is not present"
self._network_edit_scroll.vertical_down_to(self._network_acknowledgment_checkbox)
assert driver.waitFor(lambda: self._network_acknowledgment_checkbox.exists,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
self._network_edit_scroll.vertical_down_to(self._network_revert_to_default)
assert driver.waitFor(lambda: self._network_revert_to_default.exists,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
assert self._network_save_changes.exists
@allure.step('Edit the rpc input field')
def edit_network_main_json_rpc_url_input(self, test_value):
self._network_main_json_rpc_url.text = test_value
@allure.step('Edit the rpc input field')
def edit_network_failover_json_rpc_url_input(self, test_value):
self._network_failover_json_rpc_url.text = test_value
@allure.step('Check acknowledgment checkbox')
def check_acknowledgement_checkbox(self, value: bool):
self._network_acknowledgment_checkbox.set(value)
return self
@allure.step('Click Revert to default button')
def click_network_revert_to_default(self):
self._network_edit_scroll.vertical_down_to(self._network_revert_to_default)
self._network_revert_to_default.click()
@allure.step('Get value from Main json rpc input')
def get_edit_network_main_json_rpc_url_value(self):
return self._network_main_json_rpc_url.text
@allure.step('Get value from Failover json rpc input')
def get_edit_network_failover_json_rpc_url_value(self):
return self._network_failover_json_rpc_url.text
class EditAccountOrderSettings(WalletSettingsView):
def __init__(self):

View File

@ -7,7 +7,7 @@ from allure import step
import configs
import constants
import driver
from constants.wallet import WalletNetworkSettings
from constants.wallet import WalletNetworkSettings, WalletNetworkNaming, WalletNetworkDefaultValues
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.components.wallet.authenticate_popup import AuthenticatePopup
from gui.components.wallet.testnet_mode_banner import TestnetModeBanner
@ -20,10 +20,7 @@ pytestmark = allure.suite("Wallet")
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703505', 'Network: Testnet switching')
@pytest.mark.case(703505)
@pytest.mark.parametrize('first_network, second_network, third_network', [
pytest.param('Mainnet', 'Optimism', 'Arbitrum')
])
def test_switch_testnet_mode(main_screen: MainWindow, first_network: str, second_network: str, third_network: str):
def test_switch_testnet_mode(main_screen: MainWindow):
with step('Verify that Testnet toggle has subtitle'):
networks = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_networks()
subtitle = networks.get_testnet_toggle_subtitle()
@ -45,17 +42,14 @@ def test_switch_testnet_mode(main_screen: MainWindow, first_network: str, second
TestnetModeBanner().wait_until_appears()
assert networks.is_testnet_mode_toggle_checked(), f"Testnet toggle if off when it should not"
with step('Verify that all networks are in the list and text for testnet active is shown on each'):
assert networks.testnet_items_amount == 3
assert driver.waitFor(
lambda: first_network in networks.networks_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Network: {first_network} not found'
assert driver.waitFor(
lambda: second_network in networks.networks_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Network: {second_network} not found'
assert driver.waitFor(
lambda: third_network in networks.networks_names,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Network: {third_network} not found'
with step('Verify networks are switched to testnets'):
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.ETHEREUM_GOERLI_NETWORK_ID.value) == WalletNetworkNaming.LAYER1_ETHEREUM.value
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.OPTIMISM_GOERLI_NETWORK_ID.value) == WalletNetworkNaming.LAYER2_OPTIMISIM.value
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.ARBITRUM_GOERLI_NETWORK_ID.value) == WalletNetworkNaming.LAYER2_ARBITRUM.value
# TODO: add verificatin for test net label
with step('Turn off Testnet mode in wallet settings'):
networks.switch_testnet_mode_toggle().turn_off_testnet_mode_in_testnet_modal()
@ -75,6 +69,10 @@ def test_toggle_testnet_toggle_on_and_close_the_confirmation(main_screen: MainWi
with step('Verify that Testnet mode toggle is turned off'):
assert not networks.is_testnet_mode_toggle_checked(), f"Testnet toggle is enabled when it should not"
with step('Check Mainnet network item title'):
networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.ETHEREUM_MAINNET_NETWORK_ID.value)
with step('Toggle the Testnet mode toggle ON'):
testnet_modal = networks.switch_testnet_mode_toggle()
@ -121,6 +119,52 @@ def test_switch_testnet_off_by_toggle_and_cancel_in_confirmation(main_screen: Ma
assert TestnetModeBanner().is_visible, f"Testnet banner is not present when it should"
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703515',
'Network: Network: Editing network -> Restore defaults')
@pytest.mark.case(703515)
def test_settings_networks_edit_restore_defaults(main_screen: MainWindow):
networks = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_networks()
with step('Check network items titles'):
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.ETHEREUM_MAINNET_NETWORK_ID.value) == WalletNetworkNaming.LAYER1_ETHEREUM.value
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.OPTIMISM_MAINNET_NETWORK_ID.value) == WalletNetworkNaming.LAYER2_OPTIMISIM.value
assert networks.get_network_item_attribute_by_id_and_attr_name('title',
WalletNetworkNaming.ARBITRUM_MAINNET_NETWORK_ID.value) == WalletNetworkNaming.LAYER2_ARBITRUM.value
with step('Open Ethereum Mainnet network item to edit'):
edit_network_form = networks.click_network_item_to_open_edit_view(
WalletNetworkNaming.ETHEREUM_MAINNET_NETWORK_ID.value)
with step('Check the elements on the form'):
edit_network_form.wait_until_appears().check_available_elements_on_edit_view()
with step('Click in Main JSON RPC URL and paste incorrect URL'):
edit_network_form.edit_network_main_json_rpc_url_input("https://eth-archival.gateway.pokt.network/v1/lb/")
with step('Check error message'):
assert edit_network_form.self._network_edit_error_message() == 'test'
with step('Click in Failover JSON RPC URL and paste incorrect URL'):
edit_network_form.edit_network_failover_json_rpc_url_input("https://eth-archival.gateway.pokt.network/v1/lb/")
with step('Check the acknowledgment checkbox'):
edit_network_form.check_acknowledgement_checkbox(True)
with step('Click Revert to default button and restore values'):
edit_network_form.click_network_revert_to_default()
with step('Check value in Main JSON RPC URL input'):
assert edit_network_form.get_edit_network_main_json_rpc_url_value() == WalletNetworkDefaultValues.ETHEREUM_LIVE_MAIN.value
with (step('Check value in Failover JSON RPC URL input')):
assert edit_network_form.get_edit_network_failover_json_rpc_url_value() == WalletNetworkDefaultValues.ETHEREUM_LIVE_FAILOVER.value
with step('Verify the acknowledgment checkbox is unchecked'):
assert edit_network_form.check_acknowledgement_checkbox(False)
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703415',
'Account order: account order could be changed with drag&drop')
@pytest.mark.case(703415)