test: rename keypair test added

This commit is contained in:
Valentina Novgorodtceva 2024-05-08 13:27:30 +07:00 committed by Valentina1133
parent 35d79a7771
commit c24bb794e4
5 changed files with 144 additions and 0 deletions

View File

@ -67,3 +67,8 @@ class WalletTransactions(Enum):
class WalletScreensHeaders(Enum):
WALLET_ADD_ACCOUNT_POPUP_TITLE = 'Add a new account'
WALLET_EDIT_ACCOUNT_POPUP_TITLE = 'Edit account'
class WalletRenameKeypair(Enum):
WALLET_SUCCESSFUL_RENAMING = 'You successfully renamed your keypair\n'

View File

@ -0,0 +1,27 @@
import allure
import configs
import driver
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.text_edit import TextEdit
from gui.objects_map import names
class RenameKeypairPopup(BasePopup):
def __init__(self):
super(RenameKeypairPopup, self).__init__()
self._rename_text_edit = TextEdit(names.edit_TextEdit)
self._save_changes_button = Button(names.save_changes_rename_StatusButton)
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
driver.waitForObjectExists(self._save_changes_button.real_name, timeout_msec)
return self
@allure.step('Rename keypair')
def rename_keypair(self, name):
self._rename_text_edit.text = name
self._save_changes_button.click()
self.wait_until_hidden()

View File

@ -469,6 +469,9 @@ o_ActivityNotificationContactRequest = {"container": statusDesktop_mainWindow_ov
activityCenterTopBar_ActivityCenterPopupTopBarPanel = {"container": statusDesktop_mainWindow_overlay, "id": "activityCenterTopBar", "type": "ActivityCenterPopupTopBarPanel", "unnamed": 1, "visible": True}
statusListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "unnamed": 1, "visible": True}
# Rename keypair popup
save_changes_rename_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "saveRenameKeypairChangesButton", "type": "StatusButton", "visible": True}
# OS NAMES
# Open Files Dialog
chooseAnImageALogo_QQuickWindow = {"title": RegularExpression("Choose.*"), "type": "QQuickWindow", "unnamed": 1, "visible": True}
@ -566,6 +569,8 @@ settingsWalletAccountDelegate = {"container": settingsContentBase_ScrollView, "i
settingsWalletKeyPairDelegate = {"container": settingsContentBase_ScrollView, "objectName": "walletKeyPairDelegate", "type": "StatusListItem", "visible": True}
settingsWalletAccountTotalBalance = {"container": settingsContentBase_ScrollView, "objectName": "includeTotalBalanceListItem", "type": "StatusListItem", "visible": True}
settingsWalletAccountTotalBalanceToggle = {"checkable": True, "container": settingsWalletAccountTotalBalance, "type": "StatusSwitch", "visible": True}
settingsContentBaseScrollView_StatusFlatRoundButton = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView, "type": "StatusFlatRoundButton", "unnamed": 1, "visible": True}
rename_keypair_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "renameKeypairMenuItem", "type": "StatusMenuItem", "visible": True}
# Wallet Account Details view
walletAccountViewEditAccountButton = {"container": statusDesktop_mainWindow, "objectName": "walletAccountViewEditAccountButton", "type": "StatusButton"}

View File

@ -9,6 +9,8 @@ import driver
from constants import wallet_account_list_item
from constants.wallet import WalletNetworkSettings, WalletNetworkDefaultValues
from driver import objects_access
from driver.objects_access import walk_children
from gui.components.settings.rename_keypair_popup import RenameKeypairPopup
from gui.components.wallet.add_saved_address_popup import AddressPopup
from gui.components.wallet.popup_delete_account_from_settings import RemoveAccountConfirmationSettings
from gui.components.wallet.testnet_mode_popup import TestnetModePopup
@ -27,6 +29,7 @@ class WalletSettingsView(QObject):
def __init__(self):
super().__init__(names.mainWindow_WalletView)
self._scroll = Scroll(names.settingsContentBaseScrollView_Flickable)
self._wallet_settings_add_new_account_button = Button(names.settings_Wallet_MainView_AddNewAccountButton)
self._wallet_network_button = Button(names.settings_Wallet_MainView_Networks)
self._account_order_button = Button(names.settingsContentBaseScrollView_accountOrderItem_StatusListItem)
@ -36,6 +39,7 @@ class WalletSettingsView(QObject):
self._wallet_settings_keypair_item = QObject(names.settingsWalletKeyPairDelegate)
self._wallet_settings_total_balance_item = QObject(names.settingsWalletAccountTotalBalance)
self._wallet_settings_total_balance_toggle = CheckBox(names.settingsWalletAccountTotalBalanceToggle)
self._rename_keypair_menu_item = QObject(names.rename_keypair_StatusMenuItem)
@allure.step('Open add account pop up in wallet settings')
def open_add_account_pop_up(self, attempts: int = 2) -> 'AccountPopup':
@ -101,6 +105,26 @@ class WalletSettingsView(QObject):
def toggle_total_balance(self, value: bool):
self._wallet_settings_total_balance_toggle.set(value)
@allure.step('Click open menu button')
def click_open_menu_button(self, title: str):
for item in driver.findAllObjects(self._wallet_settings_keypair_item.real_name):
if str(getattr(item, 'title', '')) == title:
for child in walk_children(item):
if getattr(child, 'objectName', '') == 'more-icon':
more_button = QObject(real_name=driver.objectMap.realName(child))
self._scroll.vertical_down_to(more_button)
more_button.click()
break
@allure.step('Get visibility of rename keypair menu item')
def is_rename_keypair_menu_item_visible(self):
return self._rename_keypair_menu_item.is_visible
@allure.step('Choose rename keypair option')
def click_rename_keypair(self):
self._rename_keypair_menu_item.click()
return RenameKeypairPopup().wait_until_appears()
class AccountDetailsView(WalletSettingsView):
def __init__(self):

View File

@ -0,0 +1,83 @@
import allure
import pytest
from allure_commons._allure import step
from constants.wallet import WalletRenameKeypair
from gui.components.wallet.authenticate_popup import AuthenticatePopup
from tests.wallet_main_screen import marks
import constants
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.main_window import MainWindow
pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703420',
'Wallet -> Settings -> Keypair interactions: Rename keypair')
@pytest.mark.case(703420)
@pytest.mark.parametrize('user_account', [constants.user.user_with_random_attributes_1])
@pytest.mark.parametrize(
'name, color, emoji, acc_emoji, second_name, third_name, new_name, new_name_1, seed_phrase',
[pytest.param('Acc01', '#2a4af5', 'sunglasses', '😎 ',
'SPAcc24', 'PrivAcc', 'New name', 'New name 1',
'elite dinosaur flavor canoe garbage palace antique dolphin virtual mixed sand '
'impact solution inmate hair pipe affair cage vote estate gloom lamp robust like')])
@pytest.mark.parametrize('address_pair', [constants.user.private_key_address_pair_1])
def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, color: str, emoji: str, acc_emoji: str,
second_name: str, third_name: str, new_name, new_name_1, seed_phrase, address_pair):
with step('Get display name'):
profile_display_name = main_screen.left_panel.open_settings().left_panel.open_profile_settings().get_display_name
with step('Create generated 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).save()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Create imported seed phrase wallet account'):
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(second_name).set_emoji(emoji).set_color(color).set_origin_seed_phrase(
seed_phrase.split()).save()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Import an account within private key'):
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(third_name).set_emoji(emoji).set_color(color).set_origin_private_key(
address_pair.private_key).save()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Open wallet settings and verify Status keypair title'):
settings = main_screen.left_panel.open_settings().left_panel.open_wallet_settings()
status_keypair_title = settings.get_keypairs_names()[0]
assert profile_display_name == status_keypair_title, \
f"Status keypair name should be equal to display name but currently it is {status_keypair_title}, \
when display name is {profile_display_name}"
with step('Click 3 dots menu on Status keypair and check that there is no option to rename keypair'):
settings.click_open_menu_button(profile_display_name)
assert not settings.is_rename_keypair_menu_item_visible()
with step('Click 3 dots menu on imported seed phrase account, open rename keypair popup and verify it was renamed'):
settings.click_open_menu_button('2daa3')
settings.click_rename_keypair().rename_keypair(new_name)
assert settings.get_keypairs_names()[1] == new_name
with step('Verify toast message with successful renaming appears'):
messages = main_screen.wait_for_notification()
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "2daa3" ' + 'to "' + new_name + '"' in messages, \
f"Toast message have not appeared"
with step('Click 3 dots menu on private key account, open rename keypair popup and verify it was renamed'):
settings.click_open_menu_button('edfcgpadvm')
settings.click_rename_keypair().rename_keypair(new_name_1)
assert settings.get_keypairs_names()[2] == new_name_1
with (step('Verify toast message with successful renaming appears')):
messages = main_screen.wait_for_notification()
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "edfcgpadvm" ' + 'to "' + new_name_1 + '"' in messages, \
f"Toast message have not appeared"