tests: add account with derivation path test randomised

This commit is contained in:
Anastasiya Semenkevich 2024-08-28 15:54:29 +03:00 committed by Anastasiya
parent 4257294c60
commit 69cdd30c11
7 changed files with 48 additions and 70 deletions

View File

@ -2,12 +2,19 @@ import random
from enum import Enum
class DerivationPath(Enum):
class DerivationPathName(Enum):
CUSTOM = 'Custom'
ETHEREUM = 'Ethereum'
ETHEREUM_ROPSTEN = 'Ethereum Testnet (Ropsten)'
ETHEREUM_LEDGER = 'Ethereum (Ledger)'
ETHEREUM_LEDGER_LIVE = 'Ethereum (Ledger Live/KeepKey)'
@classmethod
def select_random_path_name(cls):
return random.choice(list(DerivationPathName))
class DerivationPathValue(Enum):
STATUS_ACCOUNT_DERIVATION_PATH = "m / 44' / 60' / 0' / 0 / 0"
GENERATED_ACCOUNT_DERIVATION_PATH_1 = "m / 44' / 60' / 0' / 0 / 1"

View File

@ -83,7 +83,7 @@ class AccountPopup(BasePopup):
self._color_radiobutton.click()
return self
def set_random_color(self: str):
def set_random_color(self):
if 'radioButtonColor' in self._color_radiobutton.real_name.keys():
del self._color_radiobutton.real_name['radioButtonColor']
colors = [str(item.radioButtonColor) for item in driver.findAllObjects(self._color_radiobutton.real_name)]
@ -147,14 +147,14 @@ class AccountPopup(BasePopup):
def set_derivation_path(self, value: str, index: int, password: str):
self._edit_derivation_path_button.hover().click()
AuthenticatePopup().wait_until_appears().authenticate(password)
if value in [_.value for _ in DerivationPath]:
if value in [_.value for _ in DerivationPathName]:
self._derivation_path_combobox_button.click()
self._derivation_path_list_item.real_name['title'] = value
self._derivation_path_list_item.click()
del self._derivation_path_list_item.real_name['title']
self._address_combobox_button.click()
GeneratedAddressesList().wait_until_appears().select(index)
if value != DerivationPath.ETHEREUM.value:
if value != DerivationPathName.ETHEREUM.value:
self._scroll.vertical_scroll_down(self._non_eth_checkbox)
self._non_eth_checkbox.set(True)
else:

View File

@ -30,6 +30,12 @@ def random_mnemonic():
return words
def random_wallet_account_name():
return ''.join((random.choice(
string.ascii_letters + string.digits)
for _ in range(5, 21)))
def get_wallet_address_from_mnemonic(mnemonic_data) -> str:
w = HDWallet.from_mnemonic(mnemonic=mnemonic_data, passphrase='', network=EthereumMainNet)
child_w = w.get_child_for_path("m/44'/60'/0'/0/0")

View File

@ -10,7 +10,7 @@ from tests.settings.settings_wallet import marks
import constants
import driver
from constants.wallet import WalletAccountSettings, DerivationPath
from constants.wallet import WalletAccountSettings, DerivationPathValue
from gui.components.signing_phrase_popup import SigningPhrasePopup
from gui.components.authenticate_popup import AuthenticatePopup
from gui.main_window import MainWindow
@ -56,8 +56,8 @@ def test_delete_generated_account_from_wallet_settings(
assert acc_view.get_account_origin_value() == WalletAccountSettings.STATUS_ACCOUNT_ORIGIN.value, \
f"Status account origin label is incorrect"
assert acc_view.get_account_derivation_path_value() == DerivationPath.GENERATED_ACCOUNT_DERIVATION_PATH_1.value, \
f"Status account derivation path must be {DerivationPath.GENERATED_ACCOUNT_DERIVATION_PATH_1.value}"
assert acc_view.get_account_derivation_path_value() == DerivationPathValue.GENERATED_ACCOUNT_DERIVATION_PATH_1.value, \
f"Status account derivation path must be {DerivationPathValue.GENERATED_ACCOUNT_DERIVATION_PATH_1.value}"
assert acc_view.get_account_storage_value() == WalletAccountSettings.STORED_ON_DEVICE.value, \
f"Status account storage should be {WalletAccountSettings.STORED_ON_DEVICE.value}"

View File

@ -2,7 +2,6 @@ import allure
import pytest
from allure_commons._allure import step
from constants import EmojiCodes
from . import marks
import configs
@ -34,16 +33,14 @@ def _verify_account_order(account_order, main_screen, default_name, order):
assert driver.waitFor(lambda: wallet.left_panel.accounts[2].name == order[2],
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703415',
'Account order: account order could be changed with drag&drop')
@pytest.mark.case(703415)
@pytest.mark.takoe2
def test_change_account_order_by_drag_and_drop(main_screen: MainWindow, user_account):
default_name = 'Account 1'
name_1, emoji_1, acc_emoji_1 = 'WatchOnly', 'sunglasses', '😎 '
name_2, emoji_2, acc_emoji_2 = 'Generated', 'thumbsup', '👍 '
name_1, emoji_1, acc_emoji_1 = 'Generated 1', 'sunglasses', '😎 '
name_2, emoji_2, acc_emoji_2 = 'Generated 2', 'thumbsup', '👍 '
wallet = main_screen.left_panel.open_wallet()
SigningPhrasePopup().wait_until_appears().confirm_phrase()
@ -54,7 +51,6 @@ def test_change_account_order_by_drag_and_drop(main_screen: MainWindow, user_acc
(name_1, emoji_1, acc_emoji_1),
(name_2, emoji_2, acc_emoji_2)
):
with step('Create generated wallet account'):
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(account[0]).set_emoji(account[1])

View File

@ -6,7 +6,7 @@ import pytest
from allure_commons._allure import step
from . import marks
from constants.wallet import WalletNetworkSettings, DerivationPath, WalletAccountSettings
from constants.wallet import WalletNetworkSettings, WalletAccountSettings, DerivationPathValue
from gui.main_window import MainWindow
from gui.screens.settings import SettingsScreen
@ -44,8 +44,8 @@ def test_settings_edit_status_account(main_screen: MainWindow, new_name):
f"Status main account color must be {WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_COLOR.value}"
assert status_acc_view.get_account_origin_value() == WalletAccountSettings.STATUS_ACCOUNT_ORIGIN.value, \
f"Status account origin label is incorrect"
assert status_acc_view.get_account_derivation_path_value() == DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value, \
f"Status account derivation path must be {DerivationPath.STATUS_ACCOUNT_DERIVATION_PATH.value}"
assert status_acc_view.get_account_derivation_path_value() == DerivationPathValue.STATUS_ACCOUNT_DERIVATION_PATH.value, \
f"Status account derivation path must be {DerivationPathValue.STATUS_ACCOUNT_DERIVATION_PATH.value}"
assert status_acc_view.get_account_storage_value() == WalletAccountSettings.STORED_ON_DEVICE.value, \
f"Status account storage should be {WalletAccountSettings.STORED_ON_DEVICE.value}"

View File

@ -1,3 +1,4 @@
import random
import time
import allure
@ -5,6 +6,8 @@ import pytest
from allure_commons._allure import step
from constants import RandomUser
from constants.wallet import DerivationPathName
from scripts.utils.generators import random_wallet_account_name
from tests.wallet_main_screen import marks
import constants
@ -19,32 +22,21 @@ pytestmark = marks
@pytest.mark.case(703028)
@pytest.mark.parametrize('user_account', [RandomUser()])
@pytest.mark.parametrize(
'derivation_path, generated_address_index, name, color, emoji, emoji_unicode, new_name, new_color, new_emoji, '
'new_emoji_unicode',
'color, emoji, emoji_unicode',
[
pytest.param('Ethereum', '5', 'Ethereum', '#216266', 'sunglasses', '1f60e', 'EthEdited', '#216266', 'thumbsup',
'1f44d'),
pytest.param('Ethereum Testnet (Ropsten)', '10', 'Ethereum Testnet ', '#7140fd', 'sunglasses', '1f60e',
'RopstenEdited', '#216266', 'thumbsup', '1f44d'),
pytest.param('Ethereum (Ledger)', '15', 'Ethereum Ledger', '#2a799b', 'sunglasses', '1f60e', 'LedgerEdited',
'#216266', 'thumbsup', '1f44d'),
pytest.param('Ethereum (Ledger Live/KeepKey)', '20', 'Ethereum Ledger Live', '#7140fd', 'sunglasses', '1f60e',
'LiveEdited', '#216266', 'thumbsup', '1f44d'),
pytest.param('N/A', '95', 'Custom path', '#216266', 'sunglasses', '1f60e', 'CustomEdited', '#216266',
'thumbsup', '1f44d')
pytest.param('#216266', 'sunglasses', '1f60e')
])
def test_plus_button_manage_generated_account_custom_derivation_path(main_screen: MainWindow, user_account,
derivation_path: str, generated_address_index: int,
name: str, color: str, emoji: str,
emoji_unicode: str,
new_name: str, new_color: str, new_emoji: str,
new_emoji_unicode: str):
color: str, emoji: str,
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()
account_popup.set_name(name).set_emoji(emoji).set_color(color).set_derivation_path(derivation_path,
generated_address_index,
account_popup.set_name(name).set_emoji(emoji).set_color(color).set_derivation_path(
DerivationPathName.select_random_path_name().value,
random.randrange(2, 100),
user_account.password).save_changes()
with step('Verify that the account is correctly displayed in accounts list'):
@ -61,26 +53,3 @@ def test_plus_button_manage_generated_account_custom_derivation_path(main_screen
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'
with step('Edit wallet account'):
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()
with step('Verify that the account is correctly displayed in accounts list'):
expected_account = constants.user.account_list_item(new_name, new_color.lower(), new_emoji_unicode)
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}')
with step('Delete wallet account with agreement'):
wallet.left_panel.delete_account_from_context_menu(new_name).agree_and_confirm()
with step('Verify toast message notification when removing account'):
messages = main_screen.wait_for_notification()
assert f'"{new_name}" successfully removed' in messages, \
f"Toast message about account removal is not correct or not present. Current list of messages: {messages}"
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'