Testnet mode and account order (#105)
Co-authored-by: Valentina Novgorodtceva <valentina@status.im>
This commit is contained in:
parent
66b260fb48
commit
e0b5b88199
|
@ -24,3 +24,4 @@ UserCommunityInfo = namedtuple('CommunityInfo', ['name', 'description', 'members
|
|||
UserChannel = namedtuple('Channel', ['name', 'image', 'selected'])
|
||||
|
||||
account_list_item = namedtuple('AccountListItem', ['name', 'color', 'emoji'])
|
||||
wallet_account_list_item = namedtuple('WalletAccountListItem', ['name', 'icon', 'object'])
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,8 @@
|
|||
from gui.elements.qt.object import QObject
|
||||
from gui.elements.qt.button import Button
|
||||
|
||||
|
||||
class TestnetModeBanner(QObject):
|
||||
def __init__(self):
|
||||
super(TestnetModeBanner, self).__init__('mainWindow_testnetBanner_ModuleWarning')
|
||||
self._turn_off_button = Button('mainWindow_Turn_off_Button')
|
|
@ -0,0 +1,26 @@
|
|||
import allure
|
||||
|
||||
from gui.components.base_popup import BasePopup
|
||||
from gui.elements.qt.button import Button
|
||||
|
||||
|
||||
class TestnetModePopup(BasePopup):
|
||||
def __init__(self):
|
||||
super(TestnetModePopup, self).__init__()
|
||||
self._cancel_button = Button('add_StatusButton')
|
||||
self._turn_on_button = Button('turn_on_testnet_mode_StatusButton')
|
||||
self._turn_off_button = Button('turn_off_testnet_mode_StatusButton')
|
||||
|
||||
@allure.step('Choose turn on option')
|
||||
def turn_on_testnet_mode(self):
|
||||
self._turn_on_button.click()
|
||||
self.wait_until_hidden()
|
||||
|
||||
@allure.step('Choose turn off option')
|
||||
def turn_off_testnet_mode(self):
|
||||
self._turn_off_button.click()
|
||||
self.wait_until_hidden()
|
||||
|
||||
def cancel(self):
|
||||
self._cancel_button.click()
|
||||
self.wait_until_hidden()
|
|
@ -0,0 +1,18 @@
|
|||
import allure
|
||||
|
||||
from driver import objects_access
|
||||
from gui.elements.qt.object import QObject
|
||||
|
||||
|
||||
class WalletToastMessage(QObject):
|
||||
|
||||
def __init__(self):
|
||||
super(WalletToastMessage, self).__init__('ephemeralNotificationList_StatusToastMessage')
|
||||
self._wallet_toast_messages_list = QObject('mainWallet_Ephemeral_Notification_List')
|
||||
|
||||
@allure.step('Check message at the bottom')
|
||||
def get_toast_message(self, name: str):
|
||||
for item in objects_access.walk_children(self._wallet_toast_messages_list.object):
|
||||
if getattr(item, 'text', '') == name:
|
||||
return item
|
||||
raise LookupError(f'Wallet toast message: {name} not found')
|
|
@ -250,3 +250,16 @@ mainWallet_AddEditAccountPopup_SPWord = {"container": mainWallet_AddEditAccountP
|
|||
mainWallet_AddEditAccountPopup_12WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "12SeedButton", "type": "StatusSwitchTabButton"}
|
||||
mainWallet_AddEditAccountPopup_18WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "18SeedButton", "type": "StatusSwitchTabButton"}
|
||||
mainWallet_AddEditAccountPopup_24WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "24SeedButton", "type": "StatusSwitchTabButton"}
|
||||
|
||||
# Testnet mode popup
|
||||
turn_on_testnet_mode_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "acceptBtn", "text": "Turn on testnet mode", "type": "StatusButton", "unnamed": 1, "visible": True}
|
||||
turn_off_testnet_mode_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "acceptBtn", "text": "Turn off testnet mode", "type": "StatusButton", "unnamed": 1, "visible": True}
|
||||
add_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "type": "StatusButton", "unnamed": 1, "visible": True}
|
||||
|
||||
# Testnet mode banner
|
||||
mainWindow_testnetBanner_ModuleWarning = {"container": statusDesktop_mainWindow, "objectName": "testnetBanner", "type": "ModuleWarning", "visible": True}
|
||||
mainWindow_Turn_off_Button = {"checkable": False, "container": statusDesktop_mainWindow, "id": "button", "text": "Turn off", "type": "Button", "unnamed": 1, "visible": True}
|
||||
|
||||
# Wallet toast message
|
||||
mainWallet_Ephemeral_Notification_List = {"container": statusDesktop_mainWindow, "objectName": "ephemeralNotificationList", "type": "StatusListView"}
|
||||
ephemeralNotificationList_StatusToastMessage = {"container": mainWallet_Ephemeral_Notification_List, "type": "StatusToastMessage", "unnamed": 1, "visible": True}
|
||||
|
|
|
@ -40,3 +40,15 @@ importRestoreKeycard_StatusListItem = {"container": settingsContentBase_ScrollVi
|
|||
importFromKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "importFromKeycard", "type": "StatusListItem", "visible": True}
|
||||
checkWhatsNewKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "checkWhatsNewKeycard", "type": "StatusListItem", "visible": True}
|
||||
factoryResetKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "factoryResetKeycard", "type": "StatusListItem", "visible": True}
|
||||
|
||||
# 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"}
|
||||
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"}
|
||||
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}
|
||||
settingsContentBaseScrollView_accountOrderView_AccountOrderView = {"container": settingsContentBase_ScrollView, "id": "accountOrderView", "type": "AccountOrderView", "unnamed": 1, "visible": True}
|
||||
|
|
|
@ -5,10 +5,11 @@ import allure
|
|||
|
||||
import configs.timeouts
|
||||
import driver
|
||||
from constants import UserCommunityInfo
|
||||
from constants import UserCommunityInfo, wallet_account_list_item
|
||||
from driver import objects_access
|
||||
from driver.objects_access import walk_children
|
||||
from gui.components.settings.send_contact_request_popup import SendContactRequest
|
||||
from gui.components.wallet.testnet_mode_popup import TestnetModePopup
|
||||
from gui.elements.qt.button import Button
|
||||
from gui.elements.qt.list import List
|
||||
from gui.elements.qt.object import QObject
|
||||
|
@ -39,6 +40,11 @@ class LeftPanel(QObject):
|
|||
self._open_settings(12)
|
||||
return CommunitiesSettingsView()
|
||||
|
||||
@allure.step('Open wallet settings')
|
||||
def open_wallet_settings(self):
|
||||
self._open_settings(4)
|
||||
return WalletSettingsView()
|
||||
|
||||
|
||||
class SettingsScreen(QObject):
|
||||
|
||||
|
@ -204,3 +210,99 @@ class KeycardSettingsView(QObject):
|
|||
configs.timeouts.UI_LOAD_TIMEOUT_MSEC ), f'Check whats new keycard button not visible'
|
||||
assert driver.waitFor(lambda: self._factory_reset_keycard_button.is_visible,
|
||||
configs.timeouts.UI_LOAD_TIMEOUT_MSEC ), f'Factory reset keycard button not visible'
|
||||
|
||||
|
||||
class WalletSettingsView(QObject):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('mainWindow_WalletView')
|
||||
self._wallet_network_button = Button('settings_Wallet_MainView_Networks')
|
||||
self._account_order_button = Button('settingsContentBaseScrollView_accountOrderItem_StatusListItem')
|
||||
|
||||
@allure.step('Open networks in wallet settings')
|
||||
def open_networks(self):
|
||||
self._wallet_network_button.click()
|
||||
return NetworkWalletSettings().wait_until_appears()
|
||||
|
||||
@allure.step('Open account order in wallet settings')
|
||||
def open_account_order(self):
|
||||
self._account_order_button.click()
|
||||
return EditAccountOrderSettings().wait_until_appears()
|
||||
|
||||
|
||||
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_button = Button('settings_Wallet_NetworksView_TestNet_Toggle')
|
||||
|
||||
@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)]
|
||||
|
||||
@property
|
||||
@allure.step('Get amount of testnet active items')
|
||||
def testnet_items_amount(self) -> int:
|
||||
items_amount = 0
|
||||
for item in driver.findAllObjects(self._testnet_text_item.real_name):
|
||||
if item.text == 'Goerli testnet active':
|
||||
items_amount += 1
|
||||
return items_amount
|
||||
|
||||
@allure.step('Switch testnet mode')
|
||||
def switch_testnet_mode(self):
|
||||
self._testnet_mode_button.click()
|
||||
return TestnetModePopup().wait_until_appears()
|
||||
|
||||
@allure.step('Check state of testnet mode switch')
|
||||
def get_testnet_mode_button_checked_state(self):
|
||||
return self._testnet_mode_button.is_checked
|
||||
|
||||
|
||||
class EditAccountOrderSettings(WalletSettingsView):
|
||||
|
||||
def __init__(self):
|
||||
super(EditAccountOrderSettings, self).__init__()
|
||||
self._account_item = QObject('settingsContentBaseScrollView_draggableDelegate_StatusDraggableListItem')
|
||||
self._accounts_list = QObject('statusDesktop_mainWindow')
|
||||
|
||||
@property
|
||||
@allure.step('Get accounts')
|
||||
def accounts(self) -> typing.List[wallet_account_list_item]:
|
||||
_accounts = []
|
||||
for account_item in driver.findAllObjects(self._account_item.real_name):
|
||||
element = QObject(name='', real_name=driver.objectMap.realName(account_item))
|
||||
name = str(account_item.title)
|
||||
icon = None
|
||||
for child in objects_access.walk_children(account_item):
|
||||
if getattr(child, 'objectName', '') == 'identicon':
|
||||
icon = Image(driver.objectMap.realName(child))
|
||||
break
|
||||
_accounts.append(wallet_account_list_item(name, icon, element))
|
||||
|
||||
return sorted(_accounts, key=lambda account: account.object.y)
|
||||
|
||||
@allure.step('Get account in accounts list')
|
||||
def _get_account_item(self, name: str):
|
||||
for obj in driver.findAllObjects(self._account_item.real_name):
|
||||
if getattr(obj, 'title', '') == name:
|
||||
return obj
|
||||
raise LookupError(f'Account item: {name} not found')
|
||||
|
||||
@allure.step('Get eye icon on watch-only account')
|
||||
def get_eye_icon(self, name: str):
|
||||
for child in objects_access.walk_children(self._get_account_item(name)):
|
||||
if getattr(child, 'objectName', '') == 'show-icon':
|
||||
return child
|
||||
raise LookupError(f'Eye icon not found on {name} account item')
|
||||
|
||||
@allure.step('Drag account to change the order')
|
||||
def drag_account(self, name: str, index: int):
|
||||
assert driver.waitFor(lambda: len([account for account in self.accounts if account.name == name]) == 1), \
|
||||
'Account not found or found more then one'
|
||||
bounds = [account for account in self.accounts if account.name == name][0].object.bounds
|
||||
d_bounds = self.accounts[index].object.bounds
|
||||
driver.mouse.press_and_move(self._accounts_list.object, bounds.x, bounds.y, d_bounds.x, d_bounds.y)
|
||||
|
|
|
@ -3,13 +3,17 @@ import time
|
|||
import allure
|
||||
import pytest
|
||||
from allure import step
|
||||
from gui.components.wallet.authenticate_popup import AuthenticatePopup
|
||||
|
||||
import constants
|
||||
import driver
|
||||
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
|
||||
from gui.components.wallet.wallet_toast_message import WalletToastMessage
|
||||
from gui.main_window import MainWindow
|
||||
from gui.screens.settings import KeycardSettingsView
|
||||
from scripts.tools import image
|
||||
|
||||
|
||||
pytestmark = allure.suite("Wallet")
|
||||
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
import allure
|
||||
import pytest
|
||||
from allure import step
|
||||
|
||||
import configs
|
||||
import driver
|
||||
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
|
||||
from gui.components.wallet.wallet_toast_message import WalletToastMessage
|
||||
from gui.main_window import MainWindow
|
||||
from scripts.tools import image
|
||||
|
||||
|
||||
@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, message_turned_on, message_turned_off', [
|
||||
pytest.param('Mainnet', 'Optimism', 'Arbitrum', 'Testnet mode turned on', 'Testnet mode turned off')
|
||||
])
|
||||
def test_switch_testnet_mode(main_screen: MainWindow, first_network: str, second_network: str, third_network: str,
|
||||
message_turned_on: str, message_turned_off: str):
|
||||
with step('Started to turn on Testnet mode but cancel it'):
|
||||
networks = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_networks()
|
||||
assert networks.get_testnet_mode_button_checked_state() is False
|
||||
networks.switch_testnet_mode().cancel()
|
||||
|
||||
with step('Verify that Testnet mode not turned on'):
|
||||
assert networks.get_testnet_mode_button_checked_state() is False
|
||||
|
||||
with step('Turn on Testnet mode'):
|
||||
networks.switch_testnet_mode().turn_on_testnet_mode()
|
||||
|
||||
with step('Verify that Testnet mode turned on'):
|
||||
WalletToastMessage().get_toast_message(message_turned_on)
|
||||
TestnetModeBanner().wait_until_appears()
|
||||
assert networks.get_testnet_mode_button_checked_state() is True
|
||||
|
||||
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('Turn off Testnet mode in wallet settings'):
|
||||
networks.switch_testnet_mode().turn_off_testnet_mode()
|
||||
|
||||
with step('Verify that Testnet mode turned off'):
|
||||
WalletToastMessage().get_toast_message(message_turned_off)
|
||||
TestnetModeBanner().wait_until_hidden()
|
||||
assert networks.get_testnet_mode_button_checked_state() is 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)
|
||||
@pytest.mark.parametrize('address, default_name, name, color, emoji, second_name, second_color, second_emoji', [
|
||||
pytest.param('0xea123F7beFF45E3C9fdF54B324c29DBdA14a639A', 'Status account',
|
||||
'WatchOnly', '#2a4af5', 'sunglasses', 'Generated', '#216266', 'thumbsup')
|
||||
])
|
||||
def test_change_account_order_by_drag_and_drop(main_screen: MainWindow, user_account, address: str, default_name,
|
||||
name: str, color: str, emoji: str, second_name: str , second_color: str,
|
||||
second_emoji: str):
|
||||
with step('Create watch-only wallet account'):
|
||||
wallet = main_screen.left_panel.open_wallet()
|
||||
SigningPhrasePopup().wait_until_appears().confirm_phrase()
|
||||
account_popup = wallet.left_panel.open_add_account_popup()
|
||||
account_popup.set_name(name).set_emoji(emoji).set_color(color).set_origin_eth_address(address).save()
|
||||
account_popup.wait_until_hidden()
|
||||
|
||||
with step('Create generated wallet account'):
|
||||
account_popup = wallet.left_panel.open_add_account_popup()
|
||||
account_popup.set_name(second_name).set_emoji(second_emoji).set_color(second_color).save()
|
||||
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
|
||||
account_popup.wait_until_hidden()
|
||||
|
||||
with step('Verify accounts in wallet settings'):
|
||||
account_order = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_order()
|
||||
with step('Account order is correct'):
|
||||
assert account_order.accounts[0].name == default_name
|
||||
assert account_order.accounts[1].name == name
|
||||
assert account_order.accounts[2].name == second_name
|
||||
with step('Eye icon is displayed on watch-only account'):
|
||||
account_order.get_eye_icon(name)
|
||||
with step('Icons on accounts are correct'):
|
||||
image.compare(account_order.accounts[1].icon, 'watch_only_account_icon.png')
|
||||
image.compare(account_order.accounts[2].icon, 'generated_account_icon.png')
|
||||
|
||||
with step('Drag first account to the end of the list'):
|
||||
account_order.drag_account(default_name, 2)
|
||||
|
||||
with step('Verify the account order'):
|
||||
with step('Account order is correct in wallet settings'):
|
||||
assert driver.waitFor(lambda: account_order.accounts[0].name == name)
|
||||
assert driver.waitFor(lambda: account_order.accounts[1].name == second_name)
|
||||
assert driver.waitFor(lambda: account_order.accounts[2].name == default_name)
|
||||
with step('Account order is correct in wallet'):
|
||||
wallet = main_screen.left_panel.open_wallet()
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[0].name == name)
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[1].name == second_name)
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[2].name == default_name)
|
||||
|
||||
with step('Drag second account to the top of the list'):
|
||||
account_order = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_order()
|
||||
account_order.drag_account(second_name, 0)
|
||||
|
||||
with step('Verify the account order'):
|
||||
with step('Account order is correct in wallet settings'):
|
||||
assert driver.waitFor(lambda: account_order.accounts[0].name == second_name)
|
||||
assert driver.waitFor(lambda: account_order.accounts[1].name == name)
|
||||
assert driver.waitFor(lambda: account_order.accounts[2].name == default_name)
|
||||
with step('Account order is correct in wallet'):
|
||||
wallet = main_screen.left_panel.open_wallet()
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[0].name == second_name)
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[1].name == name)
|
||||
assert driver.waitFor(lambda: wallet.left_panel.accounts[2].name == default_name)
|
Loading…
Reference in New Issue