Skip to content

Commit

Permalink
chore(@e2e): switch to wallet account data class instance
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiyaig committed Jan 18, 2025
1 parent dcd7dec commit f8736e9
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 151 deletions.
3 changes: 0 additions & 3 deletions test/e2e/constants/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ def __init__(self):
)


account_list_item = namedtuple('AccountListItem', ['name', 'color', 'emoji'])
wallet_account_list_item = namedtuple('WalletAccountListItem', ['name', 'icon_color', 'icon_emoji', 'object'])

account_list_item_2 = namedtuple('AccountListItem', ['name2', 'color2', 'emoji2'])
wallet_account_list_item_2 = namedtuple('WalletAccountListItem', ['name', 'icon', 'object'])

wallet_account = namedtuple('PrivateKeyAddressPair', ['private_key', 'wallet_address'])
private_key_address_pair_1 = wallet_account('2daa36a3abe381a9c01610bf10fda272fbc1b8a22179a39f782c512346e3e470',
Expand Down
30 changes: 15 additions & 15 deletions test/e2e/gui/screens/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pyperclip

import configs
import constants.user
import constants
import driver
from driver.objects_access import walk_children
from gui.components.context_menu import ContextMenu
Expand Down Expand Up @@ -47,26 +47,26 @@ def is_total_balance_visible(self) -> bool:

@property
@allure.step('Get all accounts from list')
def accounts(self) -> typing.List[constants.user.account_list_item]:
def accounts(self) -> typing.List[constants.WalletAccount]:
if 'title' in self._wallet_account_item.real_name.keys():
del self._wallet_account_item.real_name['title']
time.sleep(1) # to give a chance for the left panel to refresh
raw_data = driver.findAllObjects(self._wallet_account_item.real_name)
accounts = []
if len(raw_data) > 0:
for account_item in raw_data:
# TODO: to fix properly with account data class implementation
name = str(account_item.title)
color = str(account_item.asset.color.name).lower()
emoji = ''
for child in walk_children(account_item):
if hasattr(child, 'emojiId'):
emoji = str(child.emojiId)
break
accounts.append(constants.user.account_list_item(name, color, emoji.split('-')[0]))
else:
raise LookupError("Account items were not found")
return accounts
try:
for account_item in raw_data:
name = str(account_item.title)
color = str(account_item.asset.color.name).lower()
emoji = ''
for child in walk_children(account_item):
if hasattr(child, 'emojiId'):
emoji = str(child.emojiId)
break
accounts.append(constants.WalletAccount(name, color, emoji.split('-')[0]))
return accounts
except LookupError as err:
raise err

@allure.step('Get total balance value from All accounts')
def get_total_balance_value(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_add_edit_delete_generated_account(main_screen: MainWindow, user_account

with step('Verify that the account is correctly displayed in accounts list'):
assert driver.waitFor(lambda: name in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {name} is not displayed even it should be'
f'Account with {name} is not found in {wallet.left_panel.accounts}'

with step('Edit wallet account'):
new_name = random_wallet_acc_keypair_name()
Expand All @@ -39,7 +39,7 @@ def test_add_edit_delete_generated_account(main_screen: MainWindow, user_account

with step('Verify that the account is correctly displayed in accounts list'):
assert driver.waitFor(lambda: new_name in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {new_name} is not displayed even it should be'
f'Account with {new_name} is not found in {wallet.left_panel.accounts}'

with step('Delete wallet account with agreement'):
wallet.left_panel.delete_account_from_context_menu(new_name).agree_and_confirm()
Expand All @@ -51,4 +51,4 @@ def test_add_edit_delete_generated_account(main_screen: MainWindow, user_account

with step('Verify that the account is not displayed in accounts list'):
assert driver.waitFor(lambda: new_name not in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {new_name} is still displayed even it should not be'
f'Account with {new_name} is found in {wallet.left_panel.accounts} after removal'
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pytest
from allure_commons._allure import step

import driver
from constants import RandomWalletAccount
from helpers.WalletHelper import authenticate_with_password
from constants.wallet import WalletAccountPopup

Expand All @@ -24,6 +26,9 @@
])
def test_add_new_account_from_wallet_settings(
main_screen: MainWindow, user_account, account_name: str, color: str, emoji: str, emoji_unicode: str):

wallet_account = RandomWalletAccount()

with step('Open add account pop up from wallet settings'):
add_account_popup = \
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_add_account_pop_up()
Expand All @@ -35,22 +40,17 @@ def test_add_new_account_from_wallet_settings(
string.digits, k=4)))
assert add_account_popup.get_error_message() == WalletAccountPopup.WALLET_ACCOUNT_NAME_MIN.value

add_account_popup.set_name(account_name).save_changes()
add_account_popup.set_name(wallet_account.name).save_changes()
authenticate_with_password(user_account)
add_account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == f'"{account_name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list on main wallet screen'):
assert message == f'"{wallet_account.name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
wallet = main_screen.left_panel.open_wallet()
expected_account = constants.user.account_list_item(account_name, None, None)
started_at = time.monotonic()
while expected_account not in wallet.left_panel.accounts:
time.sleep(1)
if time.monotonic() - started_at > 15:
raise LookupError(f'Account {account_name} not found in {wallet.left_panel.accounts}')
assert driver.waitFor(lambda: wallet_account.name in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {wallet_account.name} is not found in {wallet.left_panel.accounts}'
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import time

import allure
import pytest
from allure_commons._allure import step

import driver
from scripts.utils.generators import random_emoji_with_unicode, random_wallet_acc_keypair_name, \
random_wallet_account_color
from constants import RandomWalletAccount
from tests.wallet_main_screen import marks

import constants
from gui.components.authenticate_popup import AuthenticatePopup
from gui.main_window import MainWindow

Expand All @@ -25,15 +21,15 @@
])
def test_plus_button_add_watched_address(main_screen: MainWindow, address: str):

emoji_data = random_emoji_with_unicode()
name = random_wallet_acc_keypair_name()
color = random_wallet_account_color()
wallet_account = RandomWalletAccount()

with step('Add watched address with plus action button'):
wallet = main_screen.left_panel.open_wallet()
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(name).set_emoji(
emoji_data[0]).set_color(color).set_origin_watched_address(address).save_changes()
account_popup\
.set_name(wallet_account.name)\
.set_emoji(wallet_account.emoji[0])\
.set_color(wallet_account.color).set_origin_watched_address(address).save_changes()
account_popup.wait_until_hidden()

with step('Check authentication popup does not appear'):
Expand All @@ -44,8 +40,8 @@ def test_plus_button_add_watched_address(main_screen: MainWindow, address: str):
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'
assert message == f'"{wallet_account.name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
assert driver.waitFor(lambda: name in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {name} is not displayed even it should be'
assert driver.waitFor(lambda: wallet_account.name in [account.name for account in wallet.left_panel.accounts], 10000), \
f'Account with {wallet_account.name} is not displayed even it should be'
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import time

import allure
import pytest
from allure import step

import driver
from constants import RandomWalletAccount
from helpers.WalletHelper import authenticate_with_password
from scripts.utils.generators import random_wallet_acc_keypair_name
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
Expand All @@ -19,13 +17,13 @@
'Manage an account created from the generated seed phrase')
@pytest.mark.case(703036)
def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow, user_account):
name = random_wallet_acc_keypair_name()
wallet_account = RandomWalletAccount()
keypair_name = random_wallet_acc_keypair_name()

with step('Create generated seed phrase wallet account'):
wallet = main_screen.left_panel.open_wallet()
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(name).set_origin_new_seed_phrase(
account_popup.set_name(wallet_account.name).set_origin_new_seed_phrase(
keypair_name).save_changes()
authenticate_with_password(user_account)
account_popup.wait_until_hidden()
Expand All @@ -34,13 +32,10 @@ def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow,
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'
assert message == f'"{wallet_account.name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
expected_account = constants.user.account_list_item(name, None, None)
started_at = time.monotonic()
while expected_account not in wallet.left_panel.accounts:
time.sleep(1)
if time.monotonic() - started_at > 15:
raise LookupError(f'Account {expected_account} not found in {wallet.left_panel.accounts}')
assert driver.waitFor(lambda: wallet_account.name in [account.name for account in wallet.left_panel.accounts],
10000), \
f'Account with {wallet_account.name} is not displayed even it should be'

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import pytest
from allure_commons._allure import step

from constants import RandomWalletAccount
from helpers.WalletHelper import authenticate_with_password
from scripts.utils.generators import random_wallet_acc_keypair_name
from tests.wallet_main_screen import marks

import constants
import driver
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.main_window import MainWindow

pytestmark = marks
Expand All @@ -21,13 +21,13 @@
@pytest.mark.parametrize('address_pair', [constants.user.private_key_address_pair_1])
def test_plus_button_manage_account_from_private_key(main_screen: MainWindow, user_account, address_pair):

name = random_wallet_acc_keypair_name()
wallet_account = RandomWalletAccount()
new_name = random_wallet_acc_keypair_name()

with step('Import an account within private key'):
wallet = main_screen.left_panel.open_wallet()
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(name).set_origin_private_key(
account_popup.set_name(wallet_account.name).set_origin_private_key(
address_pair.private_key, address_pair.private_key[:5]).save_changes()
authenticate_with_password(user_account)
account_popup.wait_until_hidden()
Expand All @@ -36,37 +36,31 @@ def test_plus_button_manage_account_from_private_key(main_screen: MainWindow, us
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'
assert message == f'"{wallet_account.name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
expected_account = constants.user.account_list_item(name, None, None)
started_at = time.monotonic()
while expected_account not in wallet.left_panel.accounts:
time.sleep(1)
if time.monotonic() - started_at > 15:
raise LookupError(f'Account {expected_account} not found in {wallet.left_panel.accounts}')
assert driver.waitFor(lambda: wallet_account.name in [account.name for account in wallet.left_panel.accounts],
10000), \
f'Account with {wallet_account.name} is not displayed even it should be'

with step('Verify that importing private key reveals correct wallet address'):
account_index = 0
settings_acc_view = (
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_in_settings(name,
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_in_settings(wallet_account.name,
account_index))
address = settings_acc_view.get_account_address_value()
assert address == address_pair.wallet_address, \
f"Recovered account should have address {address_pair.wallet_address}, but has {address}"

with step('Edit wallet account'):
main_screen.left_panel.open_wallet()
account_popup = wallet.left_panel.open_edit_account_popup_from_context_menu(name)
account_popup = wallet.left_panel.open_edit_account_popup_from_context_menu(wallet_account.name)
account_popup.set_name(new_name).save_changes()

with step('Verify that the account is correctly displayed in accounts list'):
expected_account = constants.user.account_list_item(new_name, None, None)
started_at = time.monotonic()
while expected_account not in wallet.left_panel.accounts:
time.sleep(1)
if time.monotonic() - started_at > 15:
raise LookupError(f'Account {expected_account} not found in {wallet.left_panel.accounts}')
assert driver.waitFor(lambda: new_name in [account.name for account in wallet.left_panel.accounts],
10000), \
f'Account with {new_name} is not displayed even it should be'

with step('Delete wallet account'):
wallet.left_panel.delete_account_from_context_menu(new_name).agree_and_confirm()
Expand Down
Loading

0 comments on commit f8736e9

Please sign in to comment.