Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit 2d630d2

Browse files
committed
test: rename keypair test added
1 parent a688f63 commit 2d630d2

File tree

5 files changed

+144
-0
lines changed

5 files changed

+144
-0
lines changed

constants/wallet.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ class WalletTransactions(Enum):
6767
class WalletScreensHeaders(Enum):
6868
WALLET_ADD_ACCOUNT_POPUP_TITLE = 'Add a new account'
6969
WALLET_EDIT_ACCOUNT_POPUP_TITLE = 'Edit account'
70+
71+
72+
class WalletRenameKeypair(Enum):
73+
WALLET_SUCCESSFUL_RENAMING = 'You successfully renamed your keypair\n'
74+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import allure
2+
3+
import configs
4+
import driver
5+
from gui.components.base_popup import BasePopup
6+
from gui.elements.button import Button
7+
from gui.elements.text_edit import TextEdit
8+
from gui.objects_map import names
9+
10+
11+
class RenameKeypairPopup(BasePopup):
12+
13+
def __init__(self):
14+
super(RenameKeypairPopup, self).__init__()
15+
self._rename_text_edit = TextEdit(names.edit_TextEdit)
16+
self._save_changes_button = Button(names.save_changes_rename_StatusButton)
17+
18+
@allure.step('Wait until appears {0}')
19+
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
20+
driver.waitForObjectExists(self._save_changes_button.real_name, timeout_msec)
21+
return self
22+
23+
@allure.step('Rename keypair')
24+
def rename_keypair(self, name):
25+
self._rename_text_edit.text = name
26+
self._save_changes_button.click()
27+
self.wait_until_hidden()

gui/objects_map/names.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@
469469
activityCenterTopBar_ActivityCenterPopupTopBarPanel = {"container": statusDesktop_mainWindow_overlay, "id": "activityCenterTopBar", "type": "ActivityCenterPopupTopBarPanel", "unnamed": 1, "visible": True}
470470
statusListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "unnamed": 1, "visible": True}
471471

472+
# Rename keypair popup
473+
save_changes_rename_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "saveRenameKeypairChangesButton", "type": "StatusButton", "visible": True}
474+
472475
# OS NAMES
473476
# Open Files Dialog
474477
chooseAnImageALogo_QQuickWindow = {"title": RegularExpression("Choose.*"), "type": "QQuickWindow", "unnamed": 1, "visible": True}
@@ -566,6 +569,8 @@
566569
settingsWalletKeyPairDelegate = {"container": settingsContentBase_ScrollView, "objectName": "walletKeyPairDelegate", "type": "StatusListItem", "visible": True}
567570
settingsWalletAccountTotalBalance = {"container": settingsContentBase_ScrollView, "objectName": "includeTotalBalanceListItem", "type": "StatusListItem", "visible": True}
568571
settingsWalletAccountTotalBalanceToggle = {"checkable": True, "container": settingsWalletAccountTotalBalance, "type": "StatusSwitch", "visible": True}
572+
settingsContentBaseScrollView_StatusFlatRoundButton = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView, "type": "StatusFlatRoundButton", "unnamed": 1, "visible": True}
573+
rename_keypair_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "renameKeypairMenuItem", "type": "StatusMenuItem", "visible": True}
569574

570575
# Wallet Account Details view
571576
walletAccountViewEditAccountButton = {"container": statusDesktop_mainWindow, "objectName": "walletAccountViewEditAccountButton", "type": "StatusButton"}

gui/screens/settings_wallet.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from constants import wallet_account_list_item
1010
from constants.wallet import WalletNetworkSettings, WalletNetworkDefaultValues
1111
from driver import objects_access
12+
from driver.objects_access import walk_children
13+
from gui.components.settings.rename_keypair_popup import RenameKeypairPopup
1214
from gui.components.wallet.add_saved_address_popup import AddressPopup
1315
from gui.components.wallet.popup_delete_account_from_settings import RemoveAccountConfirmationSettings
1416
from gui.components.wallet.testnet_mode_popup import TestnetModePopup
@@ -27,6 +29,7 @@ class WalletSettingsView(QObject):
2729

2830
def __init__(self):
2931
super().__init__(names.mainWindow_WalletView)
32+
self._scroll = Scroll(names.settingsContentBaseScrollView_Flickable)
3033
self._wallet_settings_add_new_account_button = Button(names.settings_Wallet_MainView_AddNewAccountButton)
3134
self._wallet_network_button = Button(names.settings_Wallet_MainView_Networks)
3235
self._account_order_button = Button(names.settingsContentBaseScrollView_accountOrderItem_StatusListItem)
@@ -36,6 +39,7 @@ def __init__(self):
3639
self._wallet_settings_keypair_item = QObject(names.settingsWalletKeyPairDelegate)
3740
self._wallet_settings_total_balance_item = QObject(names.settingsWalletAccountTotalBalance)
3841
self._wallet_settings_total_balance_toggle = CheckBox(names.settingsWalletAccountTotalBalanceToggle)
42+
self._rename_keypair_menu_item = QObject(names.rename_keypair_StatusMenuItem)
3943

4044
@allure.step('Open add account pop up in wallet settings')
4145
def open_add_account_pop_up(self, attempts: int = 2) -> 'AccountPopup':
@@ -101,6 +105,26 @@ def is_include_in_total_balance_visible(self):
101105
def toggle_total_balance(self, value: bool):
102106
self._wallet_settings_total_balance_toggle.set(value)
103107

108+
@allure.step('Click open menu button')
109+
def click_open_menu_button(self, title: str):
110+
for item in driver.findAllObjects(self._wallet_settings_keypair_item.real_name):
111+
if str(getattr(item, 'title', '')) == title:
112+
for child in walk_children(item):
113+
if getattr(child, 'objectName', '') == 'more-icon':
114+
more_button = QObject(real_name=driver.objectMap.realName(child))
115+
self._scroll.vertical_down_to(more_button)
116+
more_button.click()
117+
break
118+
119+
@allure.step('Get visibility of rename keypair menu item')
120+
def is_rename_keypair_menu_item_visible(self):
121+
return self._rename_keypair_menu_item.is_visible
122+
123+
@allure.step('Choose rename keypair option')
124+
def click_rename_keypair(self):
125+
self._rename_keypair_menu_item.click()
126+
return RenameKeypairPopup().wait_until_appears()
127+
104128

105129
class AccountDetailsView(WalletSettingsView):
106130
def __init__(self):
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import allure
2+
import pytest
3+
from allure_commons._allure import step
4+
5+
from constants.wallet import WalletRenameKeypair
6+
from gui.components.wallet.authenticate_popup import AuthenticatePopup
7+
from tests.wallet_main_screen import marks
8+
9+
import constants
10+
from gui.components.signing_phrase_popup import SigningPhrasePopup
11+
from gui.main_window import MainWindow
12+
13+
pytestmark = marks
14+
15+
16+
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703420',
17+
'Wallet -> Settings -> Keypair interactions: Rename keypair')
18+
@pytest.mark.case(703420)
19+
@pytest.mark.parametrize('user_account', [constants.user.user_with_random_attributes_1])
20+
@pytest.mark.parametrize(
21+
'name, color, emoji, acc_emoji, second_name, third_name, new_name, new_name_1, seed_phrase',
22+
[pytest.param('Acc01', '#2a4af5', 'sunglasses', '😎 ',
23+
'SPAcc24', 'PrivAcc', 'New name', 'New name 1',
24+
'elite dinosaur flavor canoe garbage palace antique dolphin virtual mixed sand '
25+
'impact solution inmate hair pipe affair cage vote estate gloom lamp robust like')])
26+
@pytest.mark.parametrize('address_pair', [constants.user.private_key_address_pair_1])
27+
def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, color: str, emoji: str, acc_emoji: str,
28+
second_name: str, third_name: str, new_name, new_name_1, seed_phrase, address_pair):
29+
with step('Get display name'):
30+
profile_display_name = main_screen.left_panel.open_settings().left_panel.open_profile_settings().get_display_name
31+
32+
with step('Create generated wallet account'):
33+
wallet = main_screen.left_panel.open_wallet()
34+
SigningPhrasePopup().wait_until_appears().confirm_phrase()
35+
account_popup = wallet.left_panel.open_add_account_popup()
36+
account_popup.set_name(name).set_emoji(emoji).set_color(color).save()
37+
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
38+
account_popup.wait_until_hidden()
39+
40+
with step('Create imported seed phrase wallet account'):
41+
account_popup = wallet.left_panel.open_add_account_popup()
42+
account_popup.set_name(second_name).set_emoji(emoji).set_color(color).set_origin_seed_phrase(
43+
seed_phrase.split()).save()
44+
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
45+
account_popup.wait_until_hidden()
46+
47+
with step('Import an account within private key'):
48+
account_popup = wallet.left_panel.open_add_account_popup()
49+
account_popup.set_name(third_name).set_emoji(emoji).set_color(color).set_origin_private_key(
50+
address_pair.private_key).save()
51+
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
52+
account_popup.wait_until_hidden()
53+
54+
with step('Open wallet settings and verify Status keypair title'):
55+
settings = main_screen.left_panel.open_settings().left_panel.open_wallet_settings()
56+
status_keypair_title = settings.get_keypairs_names()[0]
57+
assert profile_display_name == status_keypair_title, \
58+
f"Status keypair name should be equal to display name but currently it is {status_keypair_title}, \
59+
when display name is {profile_display_name}"
60+
61+
with step('Click 3 dots menu on Status keypair and check that there is no option to rename keypair'):
62+
settings.click_open_menu_button(profile_display_name)
63+
assert not settings.is_rename_keypair_menu_item_visible()
64+
65+
with step('Click 3 dots menu on imported seed phrase account, open rename keypair popup and verify it was renamed'):
66+
settings.click_open_menu_button('2daa3')
67+
settings.click_rename_keypair().rename_keypair(new_name)
68+
assert settings.get_keypairs_names()[1] == new_name
69+
70+
with step('Verify toast message with successful renaming appears'):
71+
messages = main_screen.wait_for_notification()
72+
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "2daa3" ' + 'to "' + new_name + '"' in messages, \
73+
f"Toast message have not appeared"
74+
75+
with step('Click 3 dots menu on private key account, open rename keypair popup and verify it was renamed'):
76+
settings.click_open_menu_button('edfcgpadvm')
77+
settings.click_rename_keypair().rename_keypair(new_name_1)
78+
assert settings.get_keypairs_names()[2] == new_name_1
79+
80+
with (step('Verify toast message with successful renaming appears')):
81+
messages = main_screen.wait_for_notification()
82+
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "edfcgpadvm" ' + 'to "' + new_name_1 + '"' in messages, \
83+
f"Toast message have not appeared"

0 commit comments

Comments
 (0)