From 5fa33249c734a4274fd3e84cb6f8a6b7b6f1f322 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Thu, 29 Aug 2024 16:25:59 +0300 Subject: [PATCH] tests: fix editing with right click --- test/e2e/gui/components/context_menu.py | 70 ++++--------------- test/e2e/gui/screens/wallet.py | 34 +++++---- .../communities/test_communities_channels.py | 8 +-- ...test_add_edit_delete_generated_account.py} | 22 +++--- .../test_context_menu_edit_default_account.py | 2 +- ...test_right_click_manage_watched_address.py | 2 +- 6 files changed, 52 insertions(+), 86 deletions(-) rename test/e2e/tests/wallet_main_screen/wallet - plus button/{test_plus_button_manage_generated_account.py => test_add_edit_delete_generated_account.py} (80%) diff --git a/test/e2e/gui/components/context_menu.py b/test/e2e/gui/components/context_menu.py index 754a32f4e1..90c014ecef 100644 --- a/test/e2e/gui/components/context_menu.py +++ b/test/e2e/gui/components/context_menu.py @@ -9,65 +9,25 @@ class ContextMenu(QObject): def __init__(self): super(ContextMenu, self).__init__(names.contextMenu_PopupItem) - self._menu_item = QObject(names.contextMenuItem) - self._context_add_watched_address_option = QObject(names.contextMenuItem_AddWatchOnly) - self._context_delete_account_option = QObject(names.contextMenuItem_Delete) - self._context_edit_account_option = QObject(names.contextMenuItem_Edit) - self._context_copy_address_option = QObject(names.contextMenuItem_Copy_Address) - self._context_hide_include_in_total_balance = QObject(names.contextMenuItem_HideInclude) - self._context_edit_saved_address_option = QObject(names.contextSavedAddressEdit) - self._context_delete_saved_address_option = QObject(names.contextSavedAddressDelete) - self._edit_channel_context_item = QObject(communities_names.edit_Channel_StatusMenuItem) - self._delete_channel_context_item = QObject(communities_names.delete_Channel_StatusMenuItem) - self._invite_people_item = QObject(communities_names.invite_People_StatusMenuItem) - self._mute_community_item = QObject(communities_names.mute_Community_StatusMenuItem) - - @allure.step('Is edit channel option present in context menu') - def is_edit_channel_option_present(self): - return self._edit_channel_context_item.exists - - @allure.step('Is delete channel option present in context menu') - def is_delete_channel_option_present(self): - return self._delete_channel_context_item.exists + self.menu_item = QObject(names.contextMenuItem) + self.add_watched_address_from_context = QObject(names.contextMenuItem_AddWatchOnly) + self.delete_from_context = QObject(names.contextMenuItem_Delete) + self.edit_from_context = QObject(names.contextMenuItem_Edit) + self.copy_address_from_context = QObject(names.contextMenuItem_Copy_Address) + self.hide_include_in_total_balance = QObject(names.contextMenuItem_HideInclude) + self.edit_saved_address_from_context = QObject(names.contextSavedAddressEdit) + self.delete_saved_address_from_context = QObject(names.contextSavedAddressDelete) + self.edit_channel_from_context = QObject(communities_names.edit_Channel_StatusMenuItem) + self.delete_channel_from_context = QObject(communities_names.delete_Channel_StatusMenuItem) + self.invite_from_context = QObject(communities_names.invite_People_StatusMenuItem) + self.mute_from_context = QObject(communities_names.mute_Community_StatusMenuItem) @allure.step('Select in context menu') def select(self, value: str): - self._menu_item.real_name['text'] = value - self._menu_item.click() - - @allure.step('Click Edit saved address option') - def select_edit_saved_address(self): - self._context_edit_saved_address_option.click() - - @allure.step('Click Delete saved address option') - def select_delete_saved_address(self): - self._context_delete_saved_address_option.click() - - @allure.step('Select add watched address option from context menu') - def select_add_watched_address_from_context_menu(self): - self._context_add_watched_address_option.click() - - @allure.step('Select delete account option from context menu') - def select_delete_account_from_context_menu(self): - self._context_delete_account_option.click() - - @allure.step('Select Hide/Include in total balance option from context menu') - def select_hide_include_total_balance_from_context_menu(self): - self._context_hide_include_in_total_balance.click() - - @allure.step('Select edit account option from context menu') - def select_edit_account_from_context_menu(self): - self._context_edit_account_option.click() - - @allure.step('Select copy address from context menu') - def select_copy_address_from_context_menu(self): - self._context_copy_address_option.click() - - @allure.step('Check delete option visibility in context menu') - def is_delete_account_option_present(self): - return self._context_delete_account_option.is_visible + self.menu_item.real_name['text'] = value + self.menu_item.click() @allure.step('Select invite people to community') def select_invite_people(self): - self._invite_people_item.click() + self.invite_from_context.click() return InviteContactsPopup() diff --git a/test/e2e/gui/screens/wallet.py b/test/e2e/gui/screens/wallet.py index 9456951f4a..f7718893da 100644 --- a/test/e2e/gui/screens/wallet.py +++ b/test/e2e/gui/screens/wallet.py @@ -74,38 +74,42 @@ class LeftPanel(QObject): return self._all_accounts_balance.text @allure.step('Choose saved addresses on left wallet panel') - @close_exists(BasePopup()) def open_saved_addresses(self) -> 'SavedAddressesView': self._saved_addresses_button.click() return SavedAddressesView().wait_until_appears() @allure.step('Select account from list') - @close_exists(BasePopup()) def select_account(self, account_name: str) -> 'WalletAccountView': self._wallet_account_item.real_name['title'] = account_name self._wallet_account_item.click() return WalletAccountView().wait_until_appears() @allure.step('Open context menu from left wallet panel') - @close_exists(BasePopup()) def _open_context_menu(self) -> ContextMenu: super(LeftPanel, self).right_click() return ContextMenu().wait_until_appears() - @allure.step('Open context menu for account') - @close_exists(BasePopup()) + @allure.step('Open context menu for specific account') def _open_context_menu_for_account(self, account_name: str) -> ContextMenu: - self._wallet_account_item.real_name['title'] = account_name - self._wallet_account_item.wait_until_appears().right_click() - return ContextMenu().wait_until_appears() + account_items = self.accounts + existing_accounts_names = [account.name for account in account_items] + if account_name in existing_accounts_names: + self._wallet_account_item.real_name['title'] = account_name + self._wallet_account_item.click() + time.sleep(0.5) + self._wallet_account_item.right_click() + return ContextMenu() + else: + raise LookupError(f'{account_name} is not present in {account_items}') @allure.step("Select Hide/Include in total balance from context menu for account") def hide_include_in_total_balance_from_context_menu(self, account_name: str): - self._open_context_menu_for_account(account_name).select_hide_include_total_balance_from_context_menu() + self._open_context_menu_for_account(account_name).hide_include_in_total_balance.click() @allure.step('Open account popup for editing from context menu') def open_edit_account_popup_from_context_menu(self, account_name: str) -> AccountPopup: - self._open_context_menu_for_account(account_name).select_edit_account_from_context_menu() + context_menu = self._open_context_menu_for_account(account_name) + context_menu.edit_from_context.click() return AccountPopup().verify_edit_account_popup_present() @allure.step('Open account popup') @@ -121,13 +125,13 @@ class LeftPanel(QObject): @allure.step('Select add watched address from context menu') def select_add_watched_address_from_context_menu(self) -> AccountPopup: - self._open_context_menu().select_add_watched_address_from_context_menu() + self._open_context_menu().add_watched_address_from_context.click() return AccountPopup().wait_until_appears() @allure.step('Delete account from the list from context menu') def delete_account_from_context_menu(self, account_name: str, attempt: int = 2) -> RemoveWalletAccountPopup: try: - self._open_context_menu_for_account(account_name).select_delete_account_from_context_menu() + self._open_context_menu_for_account(account_name).delete_from_context.click() return RemoveWalletAccountPopup().wait_until_appears() except Exception as ex: if attempt: @@ -137,7 +141,7 @@ class LeftPanel(QObject): @allure.step('Copy address for the account in the context menu') def copy_account_address_in_context_menu(self, account_name: str): - self._open_context_menu_for_account(account_name).select_copy_address_from_context_menu() + self._open_context_menu_for_account(account_name).copy_address_from_context.click() return str(pyperclip.paste()) @@ -180,12 +184,12 @@ class SavedAddressesView(QObject): @allure.step('Open edit address popup for saved address') def open_edit_address_popup(self, name: str) -> 'EditSavedAddressPopup': - self.right_click(name).select_edit_saved_address() + self.right_click(name).edit_saved_address_from_context.click() return EditSavedAddressPopup() @allure.step('Delete saved address from the list') def delete_saved_address(self, address_name): - self.right_click(address_name).select_delete_saved_address() + self.right_click(address_name).delete_saved_address_from_context.click() assert ConfirmationPopup().get_confirmation_text().startswith('Are you sure you want to remove') ConfirmationPopup().confirm() diff --git a/test/e2e/tests/communities/test_communities_channels.py b/test/e2e/tests/communities/test_communities_channels.py index cf41b2ced2..00ab326873 100644 --- a/test/e2e/tests/communities/test_communities_channels.py +++ b/test/e2e/tests/communities/test_communities_channels.py @@ -105,19 +105,19 @@ def test_member_role_cannot_add_edit_and_delete_channels(main_screen: MainWindow with step('Right-click on general channel in the left navigation bar'): general_channel_context_menu = community_screen.left_panel.open_general_channel_context_menu() with step('Verify that edit item is not present in channel context menu'): - assert general_channel_context_menu.is_edit_channel_option_present() is False, \ + assert general_channel_context_menu.edit_channel_from_context.exists is False, \ f'Edit channel option is present when it should not' with step('Verify that delete item is not present in channel context menu'): - assert general_channel_context_menu.is_delete_channel_option_present() is False, \ + assert general_channel_context_menu.delete_channel_from_context.exists is False, \ f'Delete channel option is present when it should not' with step('Open context menu from the tool bar'): more_options = community_screen.tool_bar.open_more_options_dropdown() with step('Verify that edit item is not present in context menu'): - assert more_options.is_edit_channel_option_present() is False, \ + assert more_options.iedit_channel_from_context.exists is False, \ f'Edit channel option is present when it should not' with step('Verify that delete item is not present in context menu'): - assert more_options.is_delete_channel_option_present() is False, \ + assert more_options.delete_channel_from_context.exists is False, \ f'Delete channel option is present when it should not' diff --git a/test/e2e/tests/wallet_main_screen/wallet - plus button/test_plus_button_manage_generated_account.py b/test/e2e/tests/wallet_main_screen/wallet - plus button/test_add_edit_delete_generated_account.py similarity index 80% rename from test/e2e/tests/wallet_main_screen/wallet - plus button/test_plus_button_manage_generated_account.py rename to test/e2e/tests/wallet_main_screen/wallet - plus button/test_add_edit_delete_generated_account.py index 21c911be6f..cef112622d 100644 --- a/test/e2e/tests/wallet_main_screen/wallet - plus button/test_plus_button_manage_generated_account.py +++ b/test/e2e/tests/wallet_main_screen/wallet - plus button/test_add_edit_delete_generated_account.py @@ -4,8 +4,8 @@ import allure import pytest from allure_commons._allure import step -from constants import UserAccount, RandomUser -from scripts.utils.generators import random_password_string +from constants import RandomUser +from scripts.utils.generators import random_wallet_account_name from tests.wallet_main_screen import marks import constants @@ -20,16 +20,17 @@ pytestmark = marks @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703033', 'Manage a generated account') @pytest.mark.case(703033) @pytest.mark.parametrize('user_account', [RandomUser()]) -@pytest.mark.parametrize('name, color, emoji, emoji_unicode, ' - 'new_name, new_color, new_emoji, new_emoji_unicode', [ - pytest.param('GenAcc1', '#2a4af5', 'sunglasses', '1f60e', - 'GenAcc1edited', '#216266', 'thumbsup', '1f44d') +@pytest.mark.parametrize('color, emoji, emoji_unicode, ' + 'new_color, new_emoji, new_emoji_unicode', [ + pytest.param('#2a4af5', 'sunglasses', '1f60e', + '#216266', 'thumbsup', '1f44d') ]) -def test_plus_button_manage_generated_account(main_screen: MainWindow, user_account, - color: str, emoji: str, emoji_unicode: str, - name: str, new_name: str, new_color: str, new_emoji: str, - new_emoji_unicode: str): +def test_add_edit_delete_generated_account(main_screen: MainWindow, user_account, + color: str, emoji: str, emoji_unicode: str, + new_color: str, new_emoji: str, + new_emoji_unicode: str): with step('Create generated wallet account'): + name = random_wallet_account_name() wallet = main_screen.left_panel.open_wallet() SigningPhrasePopup().wait_until_appears().confirm_phrase() account_popup = wallet.left_panel.open_add_account_popup() @@ -52,6 +53,7 @@ def test_plus_button_manage_generated_account(main_screen: MainWindow, user_acco raise LookupError(f'Account {expected_account} not found in {wallet.left_panel.accounts}') with step('Edit wallet account'): + new_name = random_wallet_account_name() account_popup = wallet.left_panel.open_edit_account_popup_from_context_menu(name) account_popup.set_name(new_name).set_emoji(new_emoji).set_color(new_color).save_changes() diff --git a/test/e2e/tests/wallet_main_screen/wallet - right click on account/test_context_menu_edit_default_account.py b/test/e2e/tests/wallet_main_screen/wallet - right click on account/test_context_menu_edit_default_account.py index a7c36d3eec..5af4f5cac3 100644 --- a/test/e2e/tests/wallet_main_screen/wallet - right click on account/test_context_menu_edit_default_account.py +++ b/test/e2e/tests/wallet_main_screen/wallet - right click on account/test_context_menu_edit_default_account.py @@ -24,7 +24,7 @@ def test_context_menu_edit_default_account(main_screen: MainWindow, name: str, n with step("Verify default status account can't be deleted"): context_menu = wallet.left_panel._open_context_menu_for_account(name) - assert not context_menu.is_delete_account_option_present(), \ + assert not context_menu.delete_from_context.is_visible, \ f"Delete option should not be present for Status account" with step('Edit wallet account'): diff --git a/test/e2e/tests/wallet_main_screen/wallet - right click out of account area/test_right_click_manage_watched_address.py b/test/e2e/tests/wallet_main_screen/wallet - right click out of account area/test_right_click_manage_watched_address.py index 1d5feac2f7..445f899aca 100644 --- a/test/e2e/tests/wallet_main_screen/wallet - right click out of account area/test_right_click_manage_watched_address.py +++ b/test/e2e/tests/wallet_main_screen/wallet - right click out of account area/test_right_click_manage_watched_address.py @@ -33,7 +33,7 @@ def test_right_click_manage_watch_only_account_context_menu(main_screen: MainWin SigningPhrasePopup().wait_until_appears().confirm_phrase() with step('Create watched address from context menu'): - account_popup = wallet.left_panel.select_add_watched_address_from_context_menu() + account_popup = wallet.left_panel.add_watched_address_from_context.click() account_popup.set_name(name).set_emoji(emoji).set_color(color).set_eth_address(address).save_changes() account_popup.wait_until_hidden()