test: try re-importing seed phrase in wallet

This commit is contained in:
Valentina Novgorodtceva 2024-05-28 12:32:01 +07:00 committed by Valentina1133
parent f9d3e11e07
commit 70c2a33e5c
4 changed files with 61 additions and 11 deletions

View File

@ -72,3 +72,6 @@ class WalletScreensHeaders(Enum):
class WalletRenameKeypair(Enum): class WalletRenameKeypair(Enum):
WALLET_SUCCESSFUL_RENAMING = 'You successfully renamed your keypair\n' WALLET_SUCCESSFUL_RENAMING = 'You successfully renamed your keypair\n'
class WalletSeedPhrase(Enum):
WALLET_SEED_PHRASE_ALREADY_ADDED = 'The entered seed phrase is already added'

View File

@ -123,17 +123,19 @@ class AccountPopup(BasePopup):
@allure.step('Set new seed phrase for account') @allure.step('Set new seed phrase for account')
def set_origin_new_seed_phrase(self, value: str): def set_origin_new_seed_phrase(self, value: str):
self._origin_combobox.click() self.open_add_new_account_popup().generate_new_master_key(value)
self._new_master_key_origin_item.click()
AddNewAccountPopup().wait_until_appears().generate_new_master_key(value)
return self return self
@allure.step('Set seed phrase') @allure.step('Set seed phrase')
def set_origin_seed_phrase(self, value: typing.List[str]): 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() self._origin_combobox.click()
self._new_master_key_origin_item.click() self._new_master_key_origin_item.click()
AddNewAccountPopup().wait_until_appears().import_new_seed_phrase(value) return AddNewAccountPopup().wait_until_appears()
return self
@allure.step('Set derivation path for account') @allure.step('Set derivation path for account')
def set_derivation_path(self, value: str, index: int, password: str): def set_derivation_path(self, value: str, index: int, password: str):
@ -221,6 +223,7 @@ class AddNewAccountPopup(BasePopup):
self._seed_phrase_word_text_edit = TextEdit(names.mainWindow_statusSeedPhraseInputField_TextEdit) self._seed_phrase_word_text_edit = TextEdit(names.mainWindow_statusSeedPhraseInputField_TextEdit)
self._seed_phrase_phrase_key_name_text_edit = TextEdit( self._seed_phrase_phrase_key_name_text_edit = TextEdit(
names.mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyName) names.mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyName)
self._already_added_error = QObject(names.enterSeedPhraseInvalidSeedText_StatusBaseText)
@allure.step('Wait until appears {0}') @allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
@ -235,8 +238,16 @@ class AddNewAccountPopup(BasePopup):
self._continue_button.click() self._continue_button.click()
return private_key[:5] return private_key[:5]
@allure.step('Import new seed phrase') @allure.step('Import new seed phrase and continue')
def import_new_seed_phrase(self, seed_phrase_words: list) -> str: 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()
return seed_phrase_name
@allure.step('Enter new seed phrase')
def enter_new_seed_phrase(self, seed_phrase_words: list) -> str:
self._import_seed_phrase_button.click() self._import_seed_phrase_button.click()
if len(seed_phrase_words) == 12: if len(seed_phrase_words) == 12:
self._seed_phrase_12_words_button.click() self._seed_phrase_12_words_button.click()
@ -249,16 +260,17 @@ class AddNewAccountPopup(BasePopup):
for count, word in enumerate(seed_phrase_words, start=1): 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.real_name['objectName'] = f'enterSeedPhraseInputField{count}'
self._seed_phrase_word_text_edit.text = word self._seed_phrase_word_text_edit.text = word
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()
return seed_phrase_name
@allure.step('Generate new seed phrase') @allure.step('Generate new seed phrase')
def generate_new_master_key(self, name: str): def generate_new_master_key(self, name: str):
self._generate_master_key_button.click() self._generate_master_key_button.click()
BackUpYourSeedPhrasePopUp().wait_until_appears().generate_seed_phrase(name) BackUpYourSeedPhrasePopUp().wait_until_appears().generate_seed_phrase(name)
@allure.step('Get text of error')
def get_already_added_error(self):
assert self._already_added_error.is_visible
return self._already_added_error.object.text
class GeneratedAddressesList(QObject): class GeneratedAddressesList(QObject):

View File

@ -337,6 +337,7 @@ mainWallet_AddEditAccountPopup_EnterSeedPhraseWord = {"container": mainWallet_Ad
mainWallet_AddEditAccountPopup_12WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "12SeedButton", "type": "StatusSwitchTabButton"} mainWallet_AddEditAccountPopup_12WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "12SeedButton", "type": "StatusSwitchTabButton"}
mainWallet_AddEditAccountPopup_18WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "18SeedButton", "type": "StatusSwitchTabButton"} mainWallet_AddEditAccountPopup_18WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "18SeedButton", "type": "StatusSwitchTabButton"}
mainWallet_AddEditAccountPopup_24WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "24SeedButton", "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}
# Edit Account from settings popup # Edit Account from settings popup
editWalletSettings_renameButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "renameAccountModalSaveBtn", "type": "StatusButton"} editWalletSettings_renameButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "renameAccountModalSaveBtn", "type": "StatusButton"}

View File

@ -3,6 +3,8 @@ import time
import allure import allure
import pytest import pytest
from allure_commons._allure import step from allure_commons._allure import step
from constants.wallet import WalletSeedPhrase
from tests.wallet_main_screen import marks from tests.wallet_main_screen import marks
import constants import constants
@ -83,3 +85,35 @@ def test_plus_button_manage_account_from_seed_phrase(main_screen: MainWindow, us
with step('Verify that the account is not displayed in accounts list'): 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), \ 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 still displayed even it should not be'
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/736371',
"Can't import the same seed phrase when adding account")
@pytest.mark.case(736371)
@pytest.mark.parametrize('user_account', [constants.user.user_with_random_attributes_1])
@pytest.mark.parametrize('name, color, emoji, emoji_unicode, '
'new_name, new_color, new_emoji, new_emoji_unicode, seed_phrase', [
pytest.param('SPAcc24', '#2a4af5', 'sunglasses', '1f60e',
'SPAcc24edited', '#216266', 'thumbsup', '1f44d',
'elite dinosaur flavor canoe garbage palace antique dolphin virtual mixed sand '
'impact solution inmate hair pipe affair cage vote estate gloom lamp robust like'),
])
def test_plus_button_re_importing_seed_phrase(main_screen: MainWindow, user_account,
name: str, color: str, emoji: str, emoji_unicode: str,
new_name: str, new_color: str, new_emoji: str,
new_emoji_unicode: str,
seed_phrase: str):
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()
AuthenticatePopup().wait_until_appears().authenticate(user_account.password)
account_popup.wait_until_hidden()
with step('Try to re-import seed phrase and verify that correct error appears'):
account_popup = wallet.left_panel.open_add_account_popup()
add_new_account = account_popup.set_name(name).set_emoji(emoji).set_color(color).open_add_new_account_popup()
add_new_account.enter_new_seed_phrase(seed_phrase.split())
assert add_new_account.get_already_added_error() == WalletSeedPhrase.WALLET_SEED_PHRASE_ALREADY_ADDED.value