tests: fix editing with right click

This commit is contained in:
Anastasiya Semenkevich 2024-08-29 16:25:59 +03:00 committed by Anastasiya
parent cc1e185080
commit 5fa33249c7
6 changed files with 52 additions and 86 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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'

View File

@ -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()

View File

@ -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'):

View File

@ -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()