From 2d630d245c2ec84f59f6d0707d8afc02bf552fa3 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Wed, 8 May 2024 13:27:30 +0700 Subject: [PATCH] test: rename keypair test added --- constants/wallet.py | 5 ++ .../settings/rename_keypair_popup.py | 27 ++++++ gui/objects_map/names.py | 5 ++ gui/screens/settings_wallet.py | 24 ++++++ .../test_wallet_rename_keypair_test.py | 83 +++++++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 gui/components/settings/rename_keypair_popup.py create mode 100644 tests/settings/settings_wallet/test_wallet_rename_keypair_test.py diff --git a/constants/wallet.py b/constants/wallet.py index f00b338..9a7005a 100644 --- a/constants/wallet.py +++ b/constants/wallet.py @@ -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' + diff --git a/gui/components/settings/rename_keypair_popup.py b/gui/components/settings/rename_keypair_popup.py new file mode 100644 index 0000000..7bab879 --- /dev/null +++ b/gui/components/settings/rename_keypair_popup.py @@ -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() diff --git a/gui/objects_map/names.py b/gui/objects_map/names.py index 3a24ab2..0bb6f81 100644 --- a/gui/objects_map/names.py +++ b/gui/objects_map/names.py @@ -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"} diff --git a/gui/screens/settings_wallet.py b/gui/screens/settings_wallet.py index b2f3f9b..0f31537 100644 --- a/gui/screens/settings_wallet.py +++ b/gui/screens/settings_wallet.py @@ -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): diff --git a/tests/settings/settings_wallet/test_wallet_rename_keypair_test.py b/tests/settings/settings_wallet/test_wallet_rename_keypair_test.py new file mode 100644 index 0000000..f0e0439 --- /dev/null +++ b/tests/settings/settings_wallet/test_wallet_rename_keypair_test.py @@ -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"