2024-04-24 13:29:14 +00:00
|
|
|
import time
|
|
|
|
|
2023-09-01 11:18:04 +00:00
|
|
|
import allure
|
|
|
|
|
2024-04-24 13:29:14 +00:00
|
|
|
import configs
|
|
|
|
import driver
|
2023-09-01 11:18:04 +00:00
|
|
|
from gui.components.base_popup import BasePopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.check_box import CheckBox
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_edit import TextEdit
|
|
|
|
from gui.elements.text_label import TextLabel
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-09-01 11:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AddSavedAddressPopup(BasePopup):
|
|
|
|
def __init__(self):
|
2024-10-10 10:26:23 +00:00
|
|
|
super().__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._name_text_edit = TextEdit(names.mainWallet_Saved_Addreses_Popup_Name_Input)
|
|
|
|
self._save_add_address_button = Button(names.mainWallet_Saved_Addreses_Popup_Address_Add_Button)
|
|
|
|
self._add_networks_selector = QObject(names.mainWallet_Saved_Addreses_Popup_Add_Network_Selector_Tag)
|
|
|
|
self._add_networks_button = Button(names.mainWallet_Saved_Addreses_Popup_Add_Network_Button)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._ethereum_mainnet_checkbox = CheckBox(
|
2024-04-24 13:29:14 +00:00
|
|
|
names.networkSelectionCheckbox_Ethereum_Mainnet_StatusCheckBox)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._optimism_mainnet_checkbox = CheckBox(
|
2024-04-24 13:29:14 +00:00
|
|
|
names.networkSelectionCheckbox_Optimism_StatusCheckBox)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._arbitrum_mainnet_checkbox = CheckBox(
|
2024-04-24 13:29:14 +00:00
|
|
|
names.networkSelectionCheckbox_Arbitrum_StatusCheckBox)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._ethereum_mainnet_network_tag = QObject(
|
2024-02-13 09:04:24 +00:00
|
|
|
names.mainWallet_Saved_Addresses_Popup_Network_Selector_Mainnet_network_tag)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._optimism_mainnet_network_tag = QObject(
|
2024-02-13 09:04:24 +00:00
|
|
|
names.mainWallet_Saved_Addresses_Popup_Network_Selector_Optimism_network_tag)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._arbitrum_mainnet_network_tag = QObject(
|
2024-02-13 09:04:24 +00:00
|
|
|
names.mainWallet_Saved_Addresses_Popup_Network_Selector_Arbitrum_network_tag)
|
2023-09-01 11:18:04 +00:00
|
|
|
|
|
|
|
@allure.step('Set ethereum mainnet network checkbox')
|
|
|
|
def set_ethereum_mainnet_network(self, value: bool):
|
2024-04-24 13:29:14 +00:00
|
|
|
assert driver.waitFor(lambda: self._ethereum_mainnet_checkbox.exists, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
2023-09-01 11:18:04 +00:00
|
|
|
self._ethereum_mainnet_checkbox.set(value)
|
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Set optimism mainnet network checkbox')
|
|
|
|
def set_optimism_mainnet_network(self, value: bool):
|
2024-03-29 09:02:00 +00:00
|
|
|
assert self._optimism_mainnet_checkbox.exists
|
2023-09-01 11:18:04 +00:00
|
|
|
self._optimism_mainnet_checkbox.set(value)
|
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Set arbitrum mainnet network checkbox')
|
|
|
|
def set_arbitrum_mainnet_network(self, value: bool):
|
2024-03-29 09:02:00 +00:00
|
|
|
assert self._arbitrum_mainnet_checkbox.exists
|
2023-09-01 11:18:04 +00:00
|
|
|
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__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._address_text_edit = TextEdit(names.mainWallet_Saved_Addreses_Popup_Address_Input_Edit)
|
2023-09-01 11:18:04 +00:00
|
|
|
|
|
|
|
@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()
|
2024-03-13 15:28:09 +00:00
|
|
|
self._add_networks_selector.click()
|
2024-04-24 13:29:14 +00:00
|
|
|
time.sleep(0.1)
|
2023-09-01 11:18:04 +00:00
|
|
|
self.set_ethereum_mainnet_network(True)
|
|
|
|
self.set_optimism_mainnet_network(True)
|
|
|
|
self.set_arbitrum_mainnet_network(True)
|
2024-03-13 15:28:09 +00:00
|
|
|
self._name_text_edit.click() # click the text field to close the network selector pop up
|
2023-09-01 11:18:04 +00:00
|
|
|
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()
|
2024-10-10 10:26:23 +00:00
|
|
|
self.wait_until_hidden()
|
2023-09-01 11:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EditSavedAddressPopup(AddSavedAddressPopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(EditSavedAddressPopup, self).__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._address_text_label = TextLabel(names.mainWallet_Saved_Addreses_Popup_Address_Input_Edit)
|
2023-09-01 11:18:04 +00:00
|
|
|
|
|
|
|
@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()
|
2023-10-09 17:04:29 +00:00
|
|
|
self.wait_until_hidden()
|