From 748b9b94fcf528f0a72773eebaf80c5eb850e559 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Sat, 12 Oct 2024 16:26:01 +0300 Subject: [PATCH] chore(@e2e): update test for sharing wallet address --- test/e2e/constants/user.py | 215 +++++++++--------- .../gui/components/wallet/receive_popup.py | 35 +-- test/e2e/gui/objects_map/names.py | 9 - test/e2e/gui/screens/wallet.py | 2 - .../test_wallet_share_address_popup.py | 35 +-- 5 files changed, 123 insertions(+), 173 deletions(-) diff --git a/test/e2e/constants/user.py b/test/e2e/constants/user.py index f1868bdc46..6031031b64 100644 --- a/test/e2e/constants/user.py +++ b/test/e2e/constants/user.py @@ -1,8 +1,7 @@ import random import string from collections import namedtuple -from dataclasses import dataclass -from enum import Enum +from dataclasses import dataclass, field from typing import Optional import configs @@ -13,22 +12,26 @@ from scripts.utils.generators import random_name_string, random_password_string class UserAccount: name: str = None password: str = None - seed_phrase: Optional[list] = None + seed_phrase: Optional[list] = field(default_factory=list) status_address: Optional[str] = None class RandomUser(UserAccount): def __init__(self): - self.name = random_name_string() - self.password = random_password_string() + super().__init__( + name=random_name_string(), + password=random_password_string() + ) class ReturningUser(UserAccount): def __init__(self, seed_phrase, status_address): - self.name = random_name_string() - self.password = random_password_string() - self.seed_phrase = seed_phrase - self.status_address = status_address + super().__init__( + name=random_name_string(), + password=random_password_string(), + seed_phrase=seed_phrase, + status_address=status_address + ) user_account_one = UserAccount('squisher', '0000000000', [ @@ -74,102 +77,102 @@ community_tags = ['Activism', 'Art', 'Blockchain', 'Books & blogs', 'Career', 'C 'Software dev', 'Sports', 'Tech', 'Travel', 'Vehicles', 'Web3'] permission_data = [ - { - 'checkbox_state': True, - 'first_asset': 'Dai Stablecoin', - 'second_asset': False, - 'amount': '10', - 'allowed_to': 'becomeMember', - 'in_channel': False, - 'asset_title': '10 DAI', - 'second_asset_title': False, - 'allowed_to_title': 'Become member' - }, - { - 'checkbox_state': True, - 'first_asset': 'Ether', - 'second_asset': False, - 'amount': '1', - 'allowed_to': 'becomeAdmin', - 'in_channel': False, - 'asset_title': '1 ETH', - 'second_asset_title': False, - 'allowed_to_title': 'Become an admin' - }, - { - 'checkbox_state': True, - 'first_asset': 'Ether', - 'second_asset': 'Dai Stablecoin', - 'amount': '10', - 'allowed_to': 'viewAndPost', - 'in_channel': '#general', - 'asset_title': '10 ETH', - 'second_asset_title': '10 DAI', - 'allowed_to_title': 'View and post' - }, - { - 'checkbox_state': True, - 'first_asset': 'Ether', - 'second_asset': 'Dai Stablecoin', - 'amount': '10', - 'allowed_to': 'viewOnly', - 'in_channel': '#general', - 'asset_title': '10 ETH', - 'second_asset_title': '10 DAI', - 'allowed_to_title': 'View only' - }, - { - 'checkbox_state': False, - 'first_asset': False, - 'second_asset': False, - 'amount': False, - 'allowed_to': 'becomeAdmin', - 'in_channel': False, - 'asset_title': False, - 'second_asset_title': False, - 'allowed_to_title': 'Become an admin' - } - ] + { + 'checkbox_state': True, + 'first_asset': 'Dai Stablecoin', + 'second_asset': False, + 'amount': '10', + 'allowed_to': 'becomeMember', + 'in_channel': False, + 'asset_title': '10 DAI', + 'second_asset_title': False, + 'allowed_to_title': 'Become member' + }, + { + 'checkbox_state': True, + 'first_asset': 'Ether', + 'second_asset': False, + 'amount': '1', + 'allowed_to': 'becomeAdmin', + 'in_channel': False, + 'asset_title': '1 ETH', + 'second_asset_title': False, + 'allowed_to_title': 'Become an admin' + }, + { + 'checkbox_state': True, + 'first_asset': 'Ether', + 'second_asset': 'Dai Stablecoin', + 'amount': '10', + 'allowed_to': 'viewAndPost', + 'in_channel': '#general', + 'asset_title': '10 ETH', + 'second_asset_title': '10 DAI', + 'allowed_to_title': 'View and post' + }, + { + 'checkbox_state': True, + 'first_asset': 'Ether', + 'second_asset': 'Dai Stablecoin', + 'amount': '10', + 'allowed_to': 'viewOnly', + 'in_channel': '#general', + 'asset_title': '10 ETH', + 'second_asset_title': '10 DAI', + 'allowed_to_title': 'View only' + }, + { + 'checkbox_state': False, + 'first_asset': False, + 'second_asset': False, + 'amount': False, + 'allowed_to': 'becomeAdmin', + 'in_channel': False, + 'asset_title': False, + 'second_asset_title': False, + 'allowed_to_title': 'Become an admin' + } +] permission_data_member = [ - { - 'checkbox_state': True, - 'first_asset': 'Dai Stablecoin', - 'amount': '1', - 'allowed_to': 'becomeMember', - 'asset_title': '1 DAI', - 'allowed_to_title': 'Become member' - }, - { - 'checkbox_state': True, - 'first_asset': 'Aragon', - 'amount': '2', - 'allowed_to': 'becomeMember', - 'asset_title': '2 ANT', - 'allowed_to_title': 'Become member' - }, - { - 'checkbox_state': True, - 'first_asset': '1inch', - 'amount': '3', - 'allowed_to': 'becomeMember', - 'asset_title': '3 1INCH', - 'allowed_to_title': 'Become member' - }, - { - 'checkbox_state': True, - 'first_asset': 'ABYSS', - 'amount': '4', - 'allowed_to': 'becomeMember', - 'asset_title': '4 ABYSS', - 'allowed_to_title': 'Become member' - }, - { - 'checkbox_state': True, - 'first_asset': 'Bytom', - 'amount': '5', - 'allowed_to': 'becomeMember', - 'asset_title': '5 BTM', - 'allowed_to_title': 'Become member' - } - ] + { + 'checkbox_state': True, + 'first_asset': 'Dai Stablecoin', + 'amount': '1', + 'allowed_to': 'becomeMember', + 'asset_title': '1 DAI', + 'allowed_to_title': 'Become member' + }, + { + 'checkbox_state': True, + 'first_asset': 'Aragon', + 'amount': '2', + 'allowed_to': 'becomeMember', + 'asset_title': '2 ANT', + 'allowed_to_title': 'Become member' + }, + { + 'checkbox_state': True, + 'first_asset': '1inch', + 'amount': '3', + 'allowed_to': 'becomeMember', + 'asset_title': '3 1INCH', + 'allowed_to_title': 'Become member' + }, + { + 'checkbox_state': True, + 'first_asset': 'ABYSS', + 'amount': '4', + 'allowed_to': 'becomeMember', + 'asset_title': '4 ABYSS', + 'allowed_to_title': 'Become member' + }, + { + 'checkbox_state': True, + 'first_asset': 'Bytom', + 'amount': '5', + 'allowed_to': 'becomeMember', + 'asset_title': '5 BTM', + 'allowed_to_title': 'Become member' + } +] diff --git a/test/e2e/gui/components/wallet/receive_popup.py b/test/e2e/gui/components/wallet/receive_popup.py index 1e60fa88ea..ace7baadde 100644 --- a/test/e2e/gui/components/wallet/receive_popup.py +++ b/test/e2e/gui/components/wallet/receive_popup.py @@ -1,10 +1,8 @@ import allure import pyperclip -import configs.timeouts from gui.components.base_popup import BasePopup from gui.elements.button import Button -from gui.elements.check_box import CheckBox from gui.elements.object import QObject from gui.objects_map import names @@ -13,41 +11,16 @@ class ReceivePopup(BasePopup): def __init__(self): super().__init__() - self.eth_icon = QObject(names.networkTagRectangle_eth_Rectangle) - self.oeth_icon = QObject(names.networkTagRectangle_oeth_Rectangle) - self.arb_icon = QObject(names.networkTagRectangle_arb1_Rectangle) - self.multichain_tab_button = Button(names.tabBar_Multichain_StatusSwitchTabButton) - self.legacy_tab_button = Button(names.tabBar_Legacy_StatusSwitchTabButton) - self._account_selector = QObject(names.accountSelector_AccountSelectorHeader) - self._account_selector_text = QObject(names.textContent_StatusBaseText) - self._copy_button = Button(names.greenCircleAroundIcon_Rectangle) - self._edit_button = Button(names.edit_pencil_icon_StatusIcon) + self.account_selector_text = QObject(names.textContent_StatusBaseText) + self.copy_button = Button(names.greenCircleAroundIcon_Rectangle) self.qr_code = QObject(names.qrCodeImage_Image) - self.mainnet_network_checkbox = CheckBox(names.networkSelectorDelegate_Mainnet_NetworkSelectItemDelegate) - self.optimism_network_checkbox = CheckBox(names.networkSelectorDelegate_Optimism_NetworkSelectItemDelegate) - self.arbitrum_network_checkbox = CheckBox(names.networkSelectorDelegate_Arbitrum_NetworkSelectItemDelegate) - - @allure.step('Wait until appears {0}') - def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): - self.multichain_tab_button.wait_until_appears(timeout_msec) - return self - - @allure.step('Click account selector combobox') - def click_account_selector(self): - self._account_selector.click() - return self @allure.step('Get current text in account selector') def get_text_from_account_selector(self) -> str: - return str(self._account_selector_text.object.text) + return str(self.account_selector_text.object.text) @allure.step('Copy address') def copy_address(self) -> str: - self._copy_button.click() + self.copy_button.click() return str(pyperclip.paste()) - @allure.step('Click edit button') - def edit_networks(self): - self._edit_button.click() - self.mainnet_network_checkbox.wait_until_appears() - return self diff --git a/test/e2e/gui/objects_map/names.py b/test/e2e/gui/objects_map/names.py index 097f1d1a78..79b4fe6d68 100644 --- a/test/e2e/gui/objects_map/names.py +++ b/test/e2e/gui/objects_map/names.py @@ -517,20 +517,11 @@ send_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow receive_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "receiveMenuItem", "type": "StatusMenuItem", "visible": True} # Receive popup -networkTagRectangle_eth_Rectangle = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_eth", "type": "Rectangle", "visible": True} -networkTagRectangle_oeth_Rectangle = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_oeth", "type": "Rectangle", "visible": True} -networkTagRectangle_arb1_Rectangle = {"container": statusDesktop_mainWindow_overlay, "objectName": "networkTagRectangle_arb1", "type": "Rectangle", "visible": True} tabBar_StatusSwitchTabBar = {"container": statusDesktop_mainWindow_overlay, "id": "tabBar", "type": "StatusSwitchTabBar", "unnamed": 1, "visible": True} -tabBar_Multichain_StatusSwitchTabButton = {"checkable": True, "container": tabBar_StatusSwitchTabBar, "objectName": "multichainButton", "type": "StatusSwitchTabButton", "visible": True} -tabBar_Legacy_StatusSwitchTabButton = {"checkable": True, "container": tabBar_StatusSwitchTabBar, "objectName": "legacyButton", "type": "StatusSwitchTabButton", "visible": True} accountSelector_AccountSelectorHeader = {"container": statusDesktop_mainWindow_overlay, "objectName": "accountSelector", "type": "AccountSelectorHeader", "visible": True} textContent_StatusBaseText = {"container": statusDesktop_mainWindow_overlay, "objectName": "textContent", "type": "StatusBaseText", "visible": True} -edit_pencil_icon_StatusIcon = {"container": statusDesktop_mainWindow_overlay, "objectName": "edit_pencil-icon", "type": "StatusIcon", "visible": True} greenCircleAroundIcon_Rectangle = {"container": statusDesktop_mainWindow_overlay, "id": "greenCircleAroundIcon", "type": "Rectangle", "unnamed": 1, "visible": True} qrCodeImage_Image = {"container": statusDesktop_mainWindow_overlay, "objectName": "qrCodeImage", "type": "Image", "visible": True} -networkSelectorDelegate_Mainnet_NetworkSelectItemDelegate = {"container": statusDesktop_mainWindow_overlay, "index": 0, "objectName": "networkSelectorDelegate_Mainnet", "type": "NetworkSelectItemDelegate", "visible": True} -networkSelectorDelegate_Optimism_NetworkSelectItemDelegate = {"container": statusDesktop_mainWindow_overlay, "index": 1, "objectName": "networkSelectorDelegate_Optimism", "type": "NetworkSelectItemDelegate", "visible": True} -networkSelectorDelegate_Arbitrum_NetworkSelectItemDelegate = {"container": statusDesktop_mainWindow_overlay, "index": 2, "objectName": "networkSelectorDelegate_Arbitrum", "type": "NetworkSelectItemDelegate", "visible": True} # Bridge popup holdingSelector_TokenSelectorNew = {"container": statusDesktop_mainWindow_overlay, "objectName": "holdingSelector", "type": "TokenSelectorNew", "visible": True} diff --git a/test/e2e/gui/screens/wallet.py b/test/e2e/gui/screens/wallet.py index d52661ca1e..fcfd3e76ec 100644 --- a/test/e2e/gui/screens/wallet.py +++ b/test/e2e/gui/screens/wallet.py @@ -8,7 +8,6 @@ import configs import constants.user import driver from driver.objects_access import walk_children -from gui.components.base_popup import BasePopup from gui.components.context_menu import ContextMenu from gui.components.wallet.add_saved_address_popup import AddressPopup, EditSavedAddressPopup from gui.components.wallet.asset_context_menu_popup import AssetContextMenuPopup @@ -23,7 +22,6 @@ from gui.elements.list import List from gui.elements.object import QObject from gui.elements.text_label import TextLabel from gui.objects_map import wallet_names, settings_names, names -from scripts.utils.decorators import close_exists class WalletScreen(QObject): diff --git a/test/e2e/tests/wallet_main_screen/test_wallet_share_address_popup.py b/test/e2e/tests/wallet_main_screen/test_wallet_share_address_popup.py index 3febdef50f..b2e1e9db42 100644 --- a/test/e2e/tests/wallet_main_screen/test_wallet_share_address_popup.py +++ b/test/e2e/tests/wallet_main_screen/test_wallet_share_address_popup.py @@ -1,6 +1,9 @@ import allure +import pyperclip import pytest from allure_commons._allure import step + +from constants.wallet import WalletNetworkSettings from tests.settings.settings_keycard import marks from gui.components.signing_phrase_popup import SigningPhrasePopup @@ -13,32 +16,14 @@ pytestmark = marks @pytest.mark.case(738783) def test_share_wallet_address(main_screen: MainWindow): with step('Open wallet and choose default account'): - default_name = 'Account 1' + default_name = WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME.value wallet = main_screen.left_panel.open_wallet() SigningPhrasePopup().wait_until_appears().confirm_phrase() wallet_account = wallet.left_panel.select_account(default_name) + wallet.left_panel.copy_account_address_in_context_menu(default_name) + wallet_address = pyperclip.paste() - with step('Open receive popup from footer and verify all network icons and qr code are visible'): - receive_popup = wallet_account.open_receive_popup().wait_until_appears() - assert receive_popup.eth_icon.exists - assert receive_popup.oeth_icon.exists - assert receive_popup.arb_icon.exists - assert receive_popup.qr_code.is_visible - - with step('Copy address and verify it has correct format'): - assert receive_popup.copy_address().startswith('eth:oeth:arb1:') - - with step('Uncheck Mainnet network and verify it has correct format'): - receive_popup.edit_networks().mainnet_network_checkbox.set(False) - receive_popup.qr_code.click() - assert receive_popup.copy_address().startswith('oeth:arb1:') - - with step('Uncheck Optimism network and verify it has correct format'): - receive_popup.edit_networks().optimism_network_checkbox.set(False) - receive_popup.qr_code.click() - assert receive_popup.copy_address().startswith('arb1:') - - with step('Open Legacy tab, copy address and verify it has correct format and qr code is visible'): - receive_popup.legacy_tab_button.click() - assert receive_popup.copy_address().startswith('0x') - assert receive_popup.qr_code.is_visible + with step('Check QR code and address in Receive modal from footer'): + receive_popup = wallet_account.open_receive_popup() + assert receive_popup.qr_code.is_visible, f'QR code is not present in Receive modal' + assert wallet_address == receive_popup.copy_address(), f'Addresses do not match'