test: 5 characters minimum length for account name and keypair name

This commit is contained in:
Valentina Novgorodtceva 2024-06-06 14:17:16 +07:00 committed by Anastasiya
parent 97291731ac
commit 3d34b30390
9 changed files with 138 additions and 35 deletions

View File

@ -75,3 +75,9 @@ class WalletRenameKeypair(Enum):
class WalletSeedPhrase(Enum):
WALLET_SEED_PHRASE_ALREADY_ADDED = 'The entered seed phrase is already added'
class WalletAccountPopup(Enum):
WALLET_ACCOUNT_NAME_MIN = 'Account name must be at least 5 characters'
WALLET_KEYPAIR_NAME_MIN = 'Key pair name must be at least 5 characters'
WALLET_KEYPAIR_MIN = 'Key pair must be at least 5 characters'

View File

@ -5,6 +5,7 @@ import driver
from driver.objects_access import walk_children
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.object import QObject
from gui.elements.text_edit import TextEdit
from gui.objects_map import names
@ -15,6 +16,7 @@ class RenameKeypairPopup(BasePopup):
super(RenameKeypairPopup, self).__init__()
self._rename_text_edit = TextEdit(names.edit_TextEdit)
self._save_changes_button = Button(names.save_changes_rename_StatusButton)
self._name_input = QObject(names.nameInput_StatusInput)
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
@ -27,5 +29,13 @@ class RenameKeypairPopup(BasePopup):
if getattr(child, 'id', '') == 'edit':
text_edit = TextEdit(real_name=driver.objectMap.realName(child))
text_edit.text = name
break
@allure.step('Save changes')
def save_changes(self):
self._save_changes_button.click()
self.wait_until_hidden()
@allure.step('Get error message')
def get_error_message(self) -> str:
return str(self._name_input.object.errorMessageCmp.text)

View File

@ -23,6 +23,7 @@ class AccountPopup(BasePopup):
super(AccountPopup, self).__init__()
self._scroll = Scroll(names.o_Flickable)
self._name_text_edit = TextEdit(names.mainWallet_AddEditAccountPopup_AccountName)
self._name_text_input = QObject(names.mainWallet_AddEditAccountPopup_AccountNameComponent)
self._emoji_button = Button(names.mainWallet_AddEditAccountPopup_AccountEmojiPopupButton)
self._color_radiobutton = QObject(names.color_StatusColorRadioButton)
self._popup_header_title = TextLabel(names.mainWallet_AddEditAccountPopup_HeaderTitle)
@ -66,6 +67,10 @@ class AccountPopup(BasePopup):
self._name_text_edit.text = value
return self
@allure.step('Get error message')
def get_error_message(self):
return self._name_text_input.object.errorMessageCmp.text
@allure.step('Set color for account')
def set_color(self, value: str):
if 'radioButtonColor' in self._color_radiobutton.real_name.keys():
@ -100,9 +105,8 @@ class AccountPopup(BasePopup):
return self
@allure.step('Set private key for account')
def set_origin_private_key(self, value: str):
self._origin_combobox.click()
self.click_new_master_key().import_private_key(value)
def set_origin_private_key(self, value: str, private_key_name: str):
self.open_add_new_account_popup().import_private_key(value, private_key_name)
return self
@allure.step('Click new master key item')
@ -122,11 +126,6 @@ class AccountPopup(BasePopup):
self.open_add_new_account_popup().generate_new_master_key(value)
return self
@allure.step('Set seed phrase')
def set_origin_seed_phrase(self, value: typing.List[str]):
self.open_add_new_account_popup().import_new_seed_phrase(value)
return self
@allure.step('Open add new account popup')
def open_add_new_account_popup(self):
self._origin_combobox.click()
@ -226,6 +225,8 @@ class AddNewAccountPopup(BasePopup):
self._seed_phrase_word_text_edit = TextEdit(names.mainWindow_statusSeedPhraseInputField_TextEdit)
self._seed_phrase_phrase_key_name_text_edit = TextEdit(
names.mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyName)
self._seed_phrase_status_input = QObject(names.addAccountPopup_ImportedSeedPhraseKeyName_StatusInput)
self._private_key_status_input = QObject(names.addAccountPopup_PrivateKeyName_StatusInput)
self._already_added_error = QObject(names.enterSeedPhraseInvalidSeedText_StatusBaseText)
@allure.step('Wait until appears {0}')
@ -233,24 +234,47 @@ class AddNewAccountPopup(BasePopup):
self._generate_master_key_button.wait_until_appears(timeout_msec)
return self
@allure.step('Get error message')
def get_error_message(self) -> str:
return str(self._seed_phrase_status_input.object.errorMessageCmp.text)
@allure.step('Get private key error message')
def get_private_key_error_message(self) -> str:
return str(self._private_key_status_input.object.errorMessageCmp.text)
@allure.step('Import private key')
def import_private_key(self, private_key: str) -> str:
def import_private_key(self, private_key: str, private_key_name: str) -> str:
self.import_and_enter_private_key(private_key)
self.enter_private_key_name(private_key_name)
self.click_continue()
return private_key_name
@allure.step('Click import private key and enter private key')
def import_and_enter_private_key(self, private_key: str):
self._import_private_key_button.click()
self._private_key_text_edit.text = private_key
self._private_key_name_text_edit.text = private_key[:5]
return self
@allure.step('Enter private key name')
def enter_private_key_name(self, private_key_name: str):
self._private_key_name_text_edit.text = private_key_name
return self
@allure.step('Click continue')
def click_continue(self):
self._continue_button.click()
return private_key[:5]
return self
@allure.step('Import new seed phrase and continue')
def import_new_seed_phrase(self, seed_phrase_words: list):
self.enter_new_seed_phrase(seed_phrase_words)
seed_phrase_name = ''.join([word[0] for word in seed_phrase_words[:10]])
self._seed_phrase_phrase_key_name_text_edit.text = seed_phrase_name
self._continue_button.click()
self.enter_seed_phrase_name(seed_phrase_name)
self.click_continue()
return seed_phrase_name
@allure.step('Enter new seed phrase')
def enter_new_seed_phrase(self, seed_phrase_words: list) -> str:
def enter_new_seed_phrase(self, seed_phrase_words: list):
self._import_seed_phrase_button.click()
if len(seed_phrase_words) == 12:
self._seed_phrase_12_words_button.click()
@ -263,6 +287,12 @@ class AddNewAccountPopup(BasePopup):
for count, word in enumerate(seed_phrase_words, start=1):
self._seed_phrase_word_text_edit.real_name['objectName'] = f'enterSeedPhraseInputField{count}'
self._seed_phrase_word_text_edit.text = word
return self
@allure.step('Enter seed phrase name')
def enter_seed_phrase_name(self, seed_phrase_name: str):
self._seed_phrase_phrase_key_name_text_edit.text = seed_phrase_name
return self
@allure.step('Generate new seed phrase')
def generate_new_master_key(self, name: str):

View File

@ -340,6 +340,8 @@ mainWallet_AddEditAccountPopup_12WordsButton = {"container": mainWallet_AddEditA
mainWallet_AddEditAccountPopup_18WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "18SeedButton", "type": "StatusSwitchTabButton"}
mainWallet_AddEditAccountPopup_24WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "24SeedButton", "type": "StatusSwitchTabButton"}
enterSeedPhraseInvalidSeedText_StatusBaseText = {"container": statusDesktop_mainWindow_overlay, "objectName": "enterSeedPhraseInvalidSeedText", "type": "StatusBaseText", "visible": True}
addAccountPopup_ImportedSeedPhraseKeyName_StatusInput = {"container": statusDesktop_mainWindow_overlay, "objectName": "AddAccountPopup-ImportedSeedPhraseKeyName", "type": "StatusInput", "visible": True}
addAccountPopup_PrivateKeyName_StatusInput = {"container": statusDesktop_mainWindow_overlay, "objectName": "AddAccountPopup-PrivateKeyName", "type": "StatusInput", "visible": True}
# Edit Account from settings popup
editWalletSettings_renameButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "renameAccountModalSaveBtn", "type": "StatusButton"}
@ -484,6 +486,7 @@ statusListView = {"container": statusDesktop_mainWindow_overlay, "type": "Status
# Rename keypair popup
save_changes_rename_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "saveRenameKeypairChangesButton", "type": "StatusButton", "visible": True}
nameInput_StatusInput = {"container": statusDesktop_mainWindow_overlay, "id": "nameInput", "type": "StatusInput", "unnamed": 1, "visible": True}
# Link preview options popup
show_for_this_message_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Show for this message", "type": "StatusMenuItem", "unnamed": 1, "visible": True}

View File

@ -1,8 +1,12 @@
import random
import string
import time
import allure
import pytest
from allure_commons._allure import step
from constants.wallet import WalletRenameKeypair
from constants.wallet import WalletRenameKeypair, WalletAccountPopup
from gui.components.authenticate_popup import AuthenticatePopup
from tests.wallet_main_screen import marks
@ -26,6 +30,7 @@ pytestmark = marks
@pytest.mark.parametrize('address_pair', [constants.user.private_key_address_pair_1])
def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, color: str, emoji: str, acc_emoji: str,
second_name: str, third_name: str, new_name, new_name_1, seed_phrase, address_pair):
seed_phrase_name = ''.join([word[0] for word in seed_phrase[:10]])
with step('Get display name'):
profile_display_name = main_screen.left_panel.open_settings().left_panel.open_profile_settings().get_display_name
@ -33,21 +38,39 @@ def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, c
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).save_changes()
account_popup.set_name(name).set_emoji(emoji).save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Create imported seed phrase wallet account'):
with step('To create imported seed phrase account open add account popup and set name, emoji and color'):
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(second_name).set_emoji(emoji).set_color(color).set_origin_seed_phrase(
seed_phrase.split()).save_changes()
account_popup.set_name(second_name).set_emoji(emoji)
with step('Enter seed phrase and name with less then 5 characters and verify correct error appears'):
new_account_popup = account_popup.open_add_new_account_popup()
new_account_popup.enter_new_seed_phrase(seed_phrase.split()).enter_seed_phrase_name(
''.join(random.choices(string.ascii_letters + string.digits, k=4)))
assert new_account_popup.get_error_message() == WalletAccountPopup.WALLET_KEYPAIR_NAME_MIN.value
with step('Enter seed phrase name with more than 5 characters and continue creating of seed phrase account'):
new_account_popup.enter_seed_phrase_name(seed_phrase_name).click_continue()
account_popup.save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Import an account within private key'):
with step('To import an account within private key open add account popup and set name, emoji and color'):
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(third_name).set_emoji(emoji).set_color(color).set_origin_private_key(
address_pair.private_key).save_changes()
account_popup.set_name(third_name).set_emoji(emoji)
with step('Enter private key name less than 5 characters and verify that error appears'):
new_account_popup = account_popup.open_add_new_account_popup()
new_account_popup.import_and_enter_private_key(address_pair.private_key).enter_private_key_name(
''.join(random.choices(string.ascii_letters + string.digits, k=4)))
assert new_account_popup.get_private_key_error_message() == WalletAccountPopup.WALLET_KEYPAIR_NAME_MIN.value
with step('Enter private key name more than 5 characters and continue creating of import private key account'):
new_account_popup.enter_private_key_name(address_pair.private_key[:5]).click_continue()
account_popup.save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
@ -62,9 +85,17 @@ def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, c
settings.click_open_menu_button(profile_display_name)
assert not settings.is_rename_keypair_menu_item_visible()
with step('Click 3 dots menu on imported seed phrase account, open rename keypair popup and verify it was renamed'):
with step('Click 3 dots menu on imported seed phrase account, open rename keypair popup'):
settings.click_open_menu_button('2daa3')
settings.click_rename_keypair().rename_keypair(new_name)
rename_keypair_popup = settings.click_rename_keypair()
with step('Verify that error appears when name of keypair consists of less then 5 characters'):
rename_keypair_popup.rename_keypair('abc')
assert rename_keypair_popup.get_error_message() == WalletAccountPopup.WALLET_KEYPAIR_MIN.value
with step('Enter correct new name and verify that it was changed correctly'):
rename_keypair_popup.rename_keypair(new_name)
rename_keypair_popup.save_changes()
assert settings.get_keypairs_names()[1] == new_name
with step('Verify toast message with successful renaming appears'):
@ -73,11 +104,13 @@ def test_rename_keypair_test(main_screen: MainWindow, user_account, name: str, c
f"Toast message have not appeared"
with step('Click 3 dots menu on private key account, open rename keypair popup and verify it was renamed'):
settings.click_open_menu_button('edfcgpadvm')
settings.click_rename_keypair().rename_keypair(new_name_1)
settings.click_open_menu_button('elite dino')
rename_keypair_popup = settings.click_rename_keypair()
rename_keypair_popup.rename_keypair(new_name_1)
rename_keypair_popup.save_changes()
assert settings.get_keypairs_names()[2] == new_name_1
with (step('Verify toast message with successful renaming appears')):
with step('Verify toast message with successful renaming appears'):
messages = main_screen.wait_for_notification()
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "edfcgpadvm" ' + 'to "' + new_name_1 + '"' in messages, \
assert WalletRenameKeypair.WALLET_SUCCESSFUL_RENAMING.value + 'from "elite dino" ' + 'to "' + new_name_1 + '"' in messages, \
f"Toast message have not appeared"

View File

@ -5,6 +5,8 @@ import time
import allure
import pytest
from allure_commons._allure import step
from constants.wallet import WalletAccountPopup
from . import marks
import constants
@ -32,6 +34,12 @@ def test_add_new_account_from_wallet_settings(
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_add_account_pop_up()
with step('Add a new generated account from wallet settings screen'):
with step('Verify that error appears when name consists of less then 5 characters'):
add_account_popup.set_name(''.join(random.choices(string.ascii_letters +
string.digits, k=4)))
assert add_account_popup.get_error_message() == WalletAccountPopup.WALLET_ACCOUNT_NAME_MIN.value
add_account_popup.set_name(account_name).set_emoji(emoji).set_color(color).save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
add_account_popup.wait_until_hidden()

View File

@ -1,8 +1,12 @@
import random
import string
import time
import allure
import pytest
from allure import step
from constants.wallet import WalletAccountPopup
from tests.wallet_main_screen import marks
import constants
@ -32,7 +36,8 @@ def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow,
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_origin_new_seed_phrase(keypair_name).save_changes()
account_popup.set_name(name).set_emoji(emoji).set_color(color).set_origin_new_seed_phrase(
keypair_name).save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
@ -52,6 +57,12 @@ def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow,
with step('Edit wallet account'):
account_popup = wallet.left_panel.open_edit_account_popup_from_context_menu(name)
with step('Verify that error appears when name consists of less then 5 characters'):
account_popup.set_name(''.join(random.choices(string.ascii_letters +
string.digits, k=4)))
assert account_popup.get_error_message() == WalletAccountPopup.WALLET_ACCOUNT_NAME_MIN.value
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'):

View File

@ -32,7 +32,7 @@ def test_plus_button_manage_account_from_private_key(main_screen: MainWindow, us
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_origin_private_key(
address_pair.private_key).save_changes()
address_pair.private_key, address_pair.private_key[:5]).save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()

View File

@ -42,8 +42,9 @@ def test_plus_button_manage_account_from_seed_phrase(main_screen: MainWindow, us
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_origin_seed_phrase(
seed_phrase.split()).save_changes()
account_popup.set_name(name).set_emoji(emoji).set_color(
color).open_add_new_account_popup().import_new_seed_phrase(seed_phrase.split())
account_popup.save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
@ -102,12 +103,13 @@ def test_plus_button_re_importing_seed_phrase(main_screen: MainWindow, user_acco
new_name: str, new_color: str, new_emoji: str,
new_emoji_unicode: str,
seed_phrase: str):
with step('Create imported seed phrase wallet account'):
with (step('Create imported seed phrase wallet account')):
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_origin_seed_phrase(
seed_phrase.split()).save_changes()
account_popup.set_name(name).set_emoji(emoji).set_color(
color).open_add_new_account_popup().import_new_seed_phrase(seed_phrase.split())
account_popup.save_changes()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()