From ccb2f3f50ce94ecf9012666b772a16253a8b1a85 Mon Sep 17 00:00:00 2001 From: Valentina1133 <141633821+Valentina1133@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:52:27 +0700 Subject: [PATCH] =?UTF-8?q?test(Wallet)=20Manage=20seed=20phrase=20account?= =?UTF-8?q?(imported=20and=20generated)=20and=20k=E2=80=A6=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(Wallet) Manage seed phrase account(imported and generated) and keycard settings * test(Wallet) Manage seed phrase account(imported and generated) and keycard settings --------- Co-authored-by: Vladimir Druzhinin --- .../back_up_your_seed_phrase_popup.py | 94 ++++++++++ .../wallet/wallet_account_popups.py | 66 ++++++- test/e2e/gui/main_window.py | 2 +- test/e2e/gui/objects_map/component_names.py | 19 ++ test/e2e/gui/objects_map/settings_names.py | 11 ++ test/e2e/gui/screens/settings.py | 31 ++++ .../test_wallet_manage_accounts.py} | 175 +++++++++++++----- .../test_wallet_saved_addresses.py | 44 +++++ 8 files changed, 395 insertions(+), 47 deletions(-) create mode 100644 test/e2e/gui/components/back_up_your_seed_phrase_popup.py rename test/e2e/tests/{test_wallet.py => test_wallet/test_wallet_manage_accounts.py} (61%) create mode 100644 test/e2e/tests/test_wallet/test_wallet_saved_addresses.py diff --git a/test/e2e/gui/components/back_up_your_seed_phrase_popup.py b/test/e2e/gui/components/back_up_your_seed_phrase_popup.py new file mode 100644 index 0000000000..a3991af099 --- /dev/null +++ b/test/e2e/gui/components/back_up_your_seed_phrase_popup.py @@ -0,0 +1,94 @@ +import typing + +import allure + +import configs +from gui.components.base_popup import BasePopup +from gui.elements.qt.button import Button +from gui.elements.qt.check_box import CheckBox +from gui.elements.qt.object import QObject +from gui.elements.qt.text_edit import TextEdit + + +class BackUpYourSeedPhrasePopUp(BasePopup): + + def __init__(self): + super(BackUpYourSeedPhrasePopUp, self).__init__() + self._i_have_a_pen_and_paper_check_box = CheckBox('mainWallet_AddEditAccountPopup_HavePenAndPaperCheckBox') + self._i_know_where_i_ll_store_it_check_box = CheckBox( + 'mainWallet_AddEditAccountPopup_StoringSeedPhraseConfirmedCheckBox') + self._i_am_ready_to_write_down_seed_phrase_check_box = CheckBox( + 'mainWallet_AddEditAccountPopup_SeedPhraseWrittenCheckBox') + self._primary_button = Button('mainWallet_AddEditAccountPopup_PrimaryButton') + self._reveal_seed_phrase_button = Button('mainWallet_AddEditAccountPopup_RevealSeedPhraseButton') + self._seed_phrase_panel = QObject('confirmSeedPhrasePanel_StatusSeedPhraseInput') + self._seed_phrase_word_component = QObject('mainWallet_AddEditAccountPopup_EnterSeedPhraseWordComponent') + self._prove_word_seed_phrase_text_edit = TextEdit('mainWallet_AddEditAccountPopup_EnterSeedPhraseWord') + self._acknowledge_check_box = CheckBox('mainWallet_AddEditAccountPopup_SeedBackupAknowledgeCheckBox') + self._seed_phrase_name_text_edit = TextEdit('mainWallet_AddEditAccountPopup_GeneratedSeedPhraseKeyName') + + @allure.step('Set have pen and paper checkbox') + def set_have_pen_and_paper(self, value: bool): + self._i_have_a_pen_and_paper_check_box.set(value) + return self + + @allure.step('Set ready to write checkbox') + def set_ready_to_write_seed_phrase(self, value: bool): + self._i_am_ready_to_write_down_seed_phrase_check_box.set(value) + return self + + @allure.step('Set know where will store it checkbox') + def set_know_where_store_it(self, value: bool): + self._i_know_where_i_ll_store_it_check_box.set(value) + return self + + @allure.step('Click next button') + def next(self): + self._primary_button.click() + return self + + @allure.step('Click reveal seed phrase button') + def reveal_seed_phrase(self): + self._reveal_seed_phrase_button.click() + return self + + @allure.step('Get seed phrases list') + def get_seed_phrases(self): + phrases = [] + for phrase_n in range(1, 13): + object_name = f'SeedPhraseWordAtIndex-{phrase_n}' + self._seed_phrase_panel.real_name['objectName'] = object_name + phrases.append(str(self._seed_phrase_panel.object.textEdit.input.edit.text)) + return phrases + + @allure.step('Confirm word in seed phrase') + def confirm_word(self, seed_phrase: typing.List[str]): + word_index = int(str(self._seed_phrase_word_component.object.label).split('Word #')[1]) + seed_word = seed_phrase[word_index - 1] + self._prove_word_seed_phrase_text_edit.text = seed_word + return self + + @allure.step('Set aknowledge checkbox') + def set_acknowledge(self, value: bool): + self._acknowledge_check_box.set(value) + return self + + @allure.step('Set seed phrase name') + def set_seed_phrase_name(self, value: str): + self._seed_phrase_name_text_edit.text = value + return self + + @allure.step('Wait until hidden {0}') + def wait_until_hidden(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + self._seed_phrase_name_text_edit.wait_until_hidden() + + @allure.step('Generate seed phrase') + def generate_seed_phrase(self, name: str): + self.set_have_pen_and_paper(True).set_ready_to_write_seed_phrase(True).set_know_where_store_it(True) + self.next().reveal_seed_phrase() + seed_phrases = self.get_seed_phrases() + self.next().confirm_word(seed_phrases) + self.next().confirm_word(seed_phrases) + self.next().set_acknowledge(True) + self.next().set_seed_phrase_name(name) + self.next().wait_until_hidden() diff --git a/test/e2e/gui/components/wallet/wallet_account_popups.py b/test/e2e/gui/components/wallet/wallet_account_popups.py index e09b645c05..6f7e9dc4c9 100644 --- a/test/e2e/gui/components/wallet/wallet_account_popups.py +++ b/test/e2e/gui/components/wallet/wallet_account_popups.py @@ -1,19 +1,23 @@ +import typing + import allure +from gui.components.wallet.authenticate_popup import AuthenticatePopup import configs import constants.wallet import driver -from gui.components.wallet.authenticate_popup import AuthenticatePopup +from gui.components.back_up_your_seed_phrase_popup import BackUpYourSeedPhrasePopUp from gui.components.base_popup import BasePopup from gui.components.emoji_popup import EmojiPopup from gui.elements.qt.button import Button from gui.elements.qt.check_box import CheckBox -from gui.elements.qt.text_edit import TextEdit -from gui.elements.qt.scroll import Scroll from gui.elements.qt.object import QObject +from gui.elements.qt.scroll import Scroll +from gui.elements.qt.text_edit import TextEdit GENERATED_PAGES_LIMIT = 20 + class AccountPopup(BasePopup): def __init__(self): super(AccountPopup, self).__init__() @@ -26,6 +30,7 @@ class AccountPopup(BasePopup): self._watch_only_account_origin_item = QObject("mainWallet_AddEditAccountPopup_OriginOptionWatchOnlyAcc") self._new_master_key_origin_item = QObject('mainWallet_AddEditAccountPopup_OriginOptionNewMasterKey') self._existing_origin_item = QObject('addAccountPopup_OriginOption_StatusListItem') + self._use_keycard_button = QObject('mainWallet_AddEditAccountPopup_MasterKey_GoToKeycardSettingsOption') # derivation self._address_text_edit = TextEdit('mainWallet_AddEditAccountPopup_AccountWatchOnlyAddress') self._add_account_button = Button('mainWallet_AddEditAccountPopup_PrimaryButton') @@ -77,6 +82,20 @@ class AccountPopup(BasePopup): AddNewAccountPopup().wait_until_appears().import_private_key(value) return self + @allure.step('Set new seed phrase for account') + def set_origin_new_seed_phrase(self, value: str): + self._origin_combobox.click() + self._new_master_key_origin_item.click() + AddNewAccountPopup().wait_until_appears().generate_new_master_key(value) + return self + + @allure.step('Set seed phrase') + def set_origin_seed_phrase(self, value: typing.List[str]): + self._origin_combobox.click() + self._new_master_key_origin_item.click() + AddNewAccountPopup().wait_until_appears().import_new_seed_phrase(value) + return self + @allure.step('Set derivation path for account') def set_derivation_path(self, value: str, index: int, password: str): self._edit_derivation_path_button.hover().click() @@ -95,6 +114,13 @@ class AccountPopup(BasePopup): self._derivation_path_text_edit.type_text(str(index)) return self + @allure.step('Click continue in keycard settings') + def continue_in_keycard_settings(self): + self._origin_combobox.click() + self._new_master_key_origin_item.click() + self._use_keycard_button.click() + return self + @allure.step('Save added account') def save(self): self._add_account_button.wait_until_appears().click() @@ -109,6 +135,14 @@ class AddNewAccountPopup(BasePopup): self._private_key_text_edit = TextEdit('mainWallet_AddEditAccountPopup_PrivateKey') self._private_key_name_text_edit = TextEdit('mainWallet_AddEditAccountPopup_PrivateKeyName') self._continue_button = Button('mainWallet_AddEditAccountPopup_PrimaryButton') + self._import_seed_phrase_button = Button('mainWallet_AddEditAccountPopup_MasterKey_ImportSeedPhraseOption') + self._generate_master_key_button = Button('mainWallet_AddEditAccountPopup_MasterKey_GenerateSeedPhraseOption') + self._seed_phrase_12_words_button = Button("mainWallet_AddEditAccountPopup_12WordsButton") + self._seed_phrase_18_words_button = Button("mainWallet_AddEditAccountPopup_18WordsButton") + self._seed_phrase_24_words_button = Button("mainWallet_AddEditAccountPopup_24WordsButton") + self._seed_phrase_word_text_edit = TextEdit('mainWallet_AddEditAccountPopup_SPWord') + self._seed_phrase_phrase_key_name_text_edit = TextEdit( + 'mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyName') @allure.step('Import private key') def import_private_key(self, private_key: str) -> str: @@ -118,6 +152,30 @@ class AddNewAccountPopup(BasePopup): self._continue_button.click() return private_key[:5] + @allure.step('Import new seed phrase') + def import_new_seed_phrase(self, seed_phrase_words: list) -> str: + self._import_seed_phrase_button.click() + if len(seed_phrase_words) == 12: + self._seed_phrase_12_words_button.click() + elif len(seed_phrase_words) == 18: + self._seed_phrase_18_words_button.click() + elif len(seed_phrase_words) == 24: + self._seed_phrase_24_words_button.click() + else: + raise RuntimeError("Wrong amount of seed words", len(seed_phrase_words)) + for count, word in enumerate(seed_phrase_words, start=1): + self._seed_phrase_word_text_edit.real_name['objectName'] = f'statusSeedPhraseInputField{count}' + 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') + def generate_new_master_key(self, name: str): + self._generate_master_key_button.click() + BackUpYourSeedPhrasePopUp().wait_until_appears().generate_seed_phrase(name) + class GeneratedAddressesList(QObject): @@ -154,4 +212,4 @@ class GeneratedAddressesList(QObject): else: selected_page_number += 1 self._paginator_page.real_name['text'] = selected_page_number - self._paginator_page.click() \ No newline at end of file + self._paginator_page.click() diff --git a/test/e2e/gui/main_window.py b/test/e2e/gui/main_window.py index d08946fab4..4bc8bbf59c 100644 --- a/test/e2e/gui/main_window.py +++ b/test/e2e/gui/main_window.py @@ -119,7 +119,7 @@ class MainWindow(Window): self.left_panel = LeftPanel() @allure.step('Sign Up user') - def sign_up(self, user_account: UserAccount = constants.user.community_params): + def sign_up(self, user_account: UserAccount = constants.user.user_account_one): if configs.system.IS_MAC: AllowNotificationsView().wait_until_appears().allow() BeforeStartedPopUp().get_started() diff --git a/test/e2e/gui/objects_map/component_names.py b/test/e2e/gui/objects_map/component_names.py index d509e72d3a..d03f8c5363 100644 --- a/test/e2e/gui/objects_map/component_names.py +++ b/test/e2e/gui/objects_map/component_names.py @@ -231,3 +231,22 @@ mainWallet_AddEditAccountPopup_MasterKey_ImportPrivateKeyOption = {"container": mainWallet_AddEditAccountPopup_PrivateKey = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-PrivateKeyInput", "type": "StatusPasswordInput", "visible": True} mainWallet_AddEditAccountPopup_PrivateKeyNameComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-PrivateKeyName", "type": "StatusInput", "visible": True} mainWallet_AddEditAccountPopup_PrivateKeyName = {"container": mainWallet_AddEditAccountPopup_PrivateKeyNameComponent, "type": "TextEdit", "unnamed": 1, "visible": True} +mainWallet_AddEditAccountPopup_MasterKey_GoToKeycardSettingsOption = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-GoToKeycardSettings", "type": "StatusButton", "visible": True} +mainWallet_AddEditAccountPopup_MasterKey_ImportSeedPhraseOption = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-ImportUsingSeedPhrase", "type": "StatusListItem", "visible": True} +mainWallet_AddEditAccountPopup_MasterKey_GenerateSeedPhraseOption = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-GenerateNewMasterKey", "type": "StatusListItem", "visible": True} +mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyNameComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-ImportedSeedPhraseKeyName", "type": "StatusInput", "visible": True} +mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyName = {"container": mainWallet_AddEditAccountPopup_ImportedSeedPhraseKeyNameComponent, "type": "TextEdit", "unnamed": 1, "visible": True} +mainWallet_AddEditAccountPopup_GeneratedSeedPhraseKeyNameComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-GeneratedSeedPhraseKeyName", "type": "StatusInput", "visible": True} +mainWallet_AddEditAccountPopup_GeneratedSeedPhraseKeyName = {"container": mainWallet_AddEditAccountPopup_GeneratedSeedPhraseKeyNameComponent, "type": "TextEdit", "unnamed": 1, "visible": True} +mainWallet_AddEditAccountPopup_HavePenAndPaperCheckBox = {"checkable": True, "container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-HavePenAndPaper", "type": "StatusCheckBox", "visible": True} +mainWallet_AddEditAccountPopup_SeedPhraseWrittenCheckBox = {"checkable": True, "container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-SeedPhraseWritten", "type": "StatusCheckBox", "visible": True} +mainWallet_AddEditAccountPopup_StoringSeedPhraseConfirmedCheckBox = {"checkable": True, "container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-StoringSeedPhraseConfirmed", "type": "StatusCheckBox", "visible": True} +mainWallet_AddEditAccountPopup_SeedBackupAknowledgeCheckBox = {"checkable": True, "container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-SeedBackupAknowledge", "type": "StatusCheckBox", "visible": True} +mainWallet_AddEditAccountPopup_RevealSeedPhraseButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-RevealSeedPhrase", "type": "StatusButton", "visible": True} +mainWallet_AddEditAccountPopup_SeedPhraseWordAtIndex_Placeholder = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "SeedPhraseWordAtIndex-%WORD-INDEX%", "type": "StatusSeedPhraseInput", "visible": True} +mainWallet_AddEditAccountPopup_EnterSeedPhraseWordComponent = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "AddAccountPopup-EnterSeedPhraseWord", "type": "StatusInput", "visible": True} +mainWallet_AddEditAccountPopup_EnterSeedPhraseWord = {"container": mainWallet_AddEditAccountPopup_EnterSeedPhraseWordComponent, "type": "TextEdit", "unnamed": 1, "visible": True} +mainWallet_AddEditAccountPopup_SPWord = {"container": mainWallet_AddEditAccountPopup_Content, "type": "TextEdit", "objectName": RegularExpression("statusSeedPhraseInputField*")} +mainWallet_AddEditAccountPopup_12WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "12SeedButton", "type": "StatusSwitchTabButton"} +mainWallet_AddEditAccountPopup_18WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "18SeedButton", "type": "StatusSwitchTabButton"} +mainWallet_AddEditAccountPopup_24WordsButton = {"container": mainWallet_AddEditAccountPopup_Content, "objectName": "24SeedButton", "type": "StatusSwitchTabButton"} diff --git a/test/e2e/gui/objects_map/settings_names.py b/test/e2e/gui/objects_map/settings_names.py index 2f17449299..f7b2b3676f 100644 --- a/test/e2e/gui/objects_map/settings_names.py +++ b/test/e2e/gui/objects_map/settings_names.py @@ -2,6 +2,8 @@ from gui.objects_map.main_names import statusDesktop_mainWindow mainWindow_ProfileLayout = {"container": statusDesktop_mainWindow, "type": "ProfileLayout", "unnamed": 1, "visible": True} mainWindow_StatusSectionLayout_ContentItem = {"container": mainWindow_ProfileLayout, "objectName": "StatusSectionLayout", "type": "ContentItem", "visible": True} +settingsContentBase_ScrollView = {"container": statusDesktop_mainWindow, "objectName": "settingsContentBaseScrollView", "type": "StatusScrollView", "visible": True} +settingsContentBaseScrollView_Flickable = {"container": settingsContentBase_ScrollView, "type": "Flickable", "unnamed": 1, "visible": True} # Left Panel mainWindow_LeftTabView = {"container": mainWindow_StatusSectionLayout_ContentItem, "type": "LeftTabView", "unnamed": 1, "visible": True} @@ -29,3 +31,12 @@ mainWindow_ContactsView = {"container": statusDesktop_mainWindow, "type": "Conta mainWindow_Send_contact_request_to_chat_key_StatusButton = {"checkable": False, "container": mainWindow_ContactsView, "objectName": "ContactsView_ContactRequest_Button", "type": "StatusButton", "visible": True} contactsTabBar_Pending_Requests_StatusTabButton = {"checkable": True, "container": mainWindow_ContactsView, "objectName": "ContactsView_PendingRequest_Button", "type": "StatusTabButton", "visible": True} settingsContentBaseScrollView_ContactListPanel = {"container": mainWindow_ContactsView, "objectName": "ContactListPanel_ListView", "type": "StatusListView", "visible": True} + +# Keycard Settings View +mainWindow_KeycardView = {"container": statusDesktop_mainWindow, "type": "KeycardView", "unnamed": 1, "visible": True} +setupFromExistingKeycardAccount_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "setupFromExistingKeycardAccount", "type": "StatusListItem", "visible": True} +createNewKeycardAccount_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "createNewKeycardAccount", "type": "StatusListItem", "visible": True} +importRestoreKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "importRestoreKeycard", "type": "StatusListItem", "visible": True} +importFromKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "importFromKeycard", "type": "StatusListItem", "visible": True} +checkWhatsNewKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "checkWhatsNewKeycard", "type": "StatusListItem", "visible": True} +factoryResetKeycard_StatusListItem = {"container": settingsContentBase_ScrollView, "objectName": "factoryResetKeycard", "type": "StatusListItem", "visible": True} diff --git a/test/e2e/gui/screens/settings.py b/test/e2e/gui/screens/settings.py index 046765b3c3..a62184c732 100644 --- a/test/e2e/gui/screens/settings.py +++ b/test/e2e/gui/screens/settings.py @@ -12,6 +12,7 @@ from gui.components.settings.send_contact_request_popup import SendContactReques from gui.elements.qt.button import Button from gui.elements.qt.list import List from gui.elements.qt.object import QObject +from gui.elements.qt.scroll import Scroll from gui.elements.qt.text_label import TextLabel from gui.screens.community_settings import CommunitySettingsScreen from gui.screens.messages import MessagesScreen @@ -173,3 +174,33 @@ class CommunitiesSettingsView(QObject): def open_community_overview_settings(self, name: str): driver.mouseClick(self._get_community_item(name)) return CommunitySettingsScreen().wait_until_appears() + + +class KeycardSettingsView(QObject): + + def __init__(self): + super(KeycardSettingsView, self).__init__('mainWindow_KeycardView') + self._scroll = Scroll('settingsContentBaseScrollView_Flickable') + self._setup_keycard_with_existing_account_button = Button('setupFromExistingKeycardAccount_StatusListItem') + self._create_new_keycard_account_button = Button('createNewKeycardAccount_StatusListItem') + self._import_restore_via_seed_phrase_button = Button('importRestoreKeycard_StatusListItem') + self._import_from_keycard_button = Button('importFromKeycard_StatusListItem') + self._check_whats_on_keycard_button = Button('checkWhatsNewKeycard_StatusListItem') + self._factory_reset_keycard_button = Button('factoryResetKeycard_StatusListItem') + + @allure.step('Check that keycard screen displayed') + def check_keycard_screen_loaded(self): + assert KeycardSettingsView().is_visible + + @allure.step('Check that all keycard options displayed') + def all_keycard_options_available(self): + assert self._setup_keycard_with_existing_account_button.is_visible, f'Setup keycard with existing account not visible' + assert self._create_new_keycard_account_button.is_visible, f'Create new keycard button not visible' + assert self._import_restore_via_seed_phrase_button.is_visible, f'Import and restore via seed phrase button not visible' + self._scroll.vertical_scroll_to(self._import_from_keycard_button) + assert driver.waitFor(lambda: self._import_from_keycard_button.is_visible, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Import keycard button not visible' + assert driver.waitFor(lambda: self._check_whats_on_keycard_button.is_visible, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC ), f'Check whats new keycard button not visible' + assert driver.waitFor(lambda: self._factory_reset_keycard_button.is_visible, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC ), f'Factory reset keycard button not visible' diff --git a/test/e2e/tests/test_wallet.py b/test/e2e/tests/test_wallet/test_wallet_manage_accounts.py similarity index 61% rename from test/e2e/tests/test_wallet.py rename to test/e2e/tests/test_wallet/test_wallet_manage_accounts.py index 53b92c09ec..b616523b4b 100644 --- a/test/e2e/tests/test_wallet.py +++ b/test/e2e/tests/test_wallet/test_wallet_manage_accounts.py @@ -3,51 +3,17 @@ import time import allure import pytest from allure import step +from gui.components.wallet.authenticate_popup import AuthenticatePopup -import configs.timeouts import constants import driver -from gui.components.wallet.authenticate_popup import AuthenticatePopup from gui.components.signing_phrase_popup import SigningPhrasePopup from gui.main_window import MainWindow +from gui.screens.settings import KeycardSettingsView pytestmark = allure.suite("Wallet") -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703021', 'Manage a saved address') -@pytest.mark.case(703021) -@pytest.mark.parametrize('name, address, new_name', [ - pytest.param('Saved address name before', '0x8397bc3c5a60a1883174f722403d63a8833312b7', 'Saved address name after'), - pytest.param('Ens name before', 'nastya.stateofus.eth', 'Ens name after') -]) -def test_manage_saved_address(main_screen: MainWindow, name: str, address: str, new_name: str): - with step('Add new address'): - wallet = main_screen.left_panel.open_wallet() - SigningPhrasePopup().wait_until_appears().confirm_phrase() - wallet.left_panel.open_saved_addresses().open_add_address_popup().add_saved_address(name, address) - - with step('Verify that saved address is in the list of saved addresses'): - assert driver.waitFor( - lambda: name in wallet.left_panel.open_saved_addresses().address_names, - configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found' - - with step('Edit saved address to new name'): - wallet.left_panel.open_saved_addresses().open_edit_address_popup(name).edit_saved_address(new_name, address) - - with step('Verify that saved address with new name is in the list of saved addresses'): - assert driver.waitFor( - lambda: new_name in wallet.left_panel.open_saved_addresses().address_names, - configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found' - - with step('Delete address with new name'): - wallet.left_panel.open_saved_addresses().delete_saved_address(new_name) - - with step('Verify that saved address with new name is not in the list of saved addresses'): - assert driver.waitFor( - lambda: new_name not in wallet.left_panel.open_saved_addresses().address_names, - configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found' - - @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703022', 'Edit default wallet account') @pytest.mark.case(703022) @pytest.mark.parametrize('name, new_name, new_color, new_emoji, new_emoji_unicode', [ @@ -77,7 +43,7 @@ def test_edit_default_wallet_account(main_screen: MainWindow, name: str, new_nam @pytest.mark.case(703026) @pytest.mark.parametrize('address, name, color, emoji, emoji_unicode, new_name, new_color,' 'new_emoji, new_emoji_unicode', [ - pytest.param('0xea123F7beFF45E3C9fdF54B324c29DBdA14a639A', 'AccWatch1', '#2a4af5', + pytest.param('0xea123F7beFF45E3C9fdF54B324c29DBdA14a639A', 'AccWatch1', '#2a4af5', 'sunglasses', '1f60e', 'AccWatch1edited', '#216266', 'thumbsup', '1f44d') ]) def test_manage_watch_only_account(main_screen: MainWindow, address: str, color: str, emoji: str, emoji_unicode: str, @@ -124,7 +90,7 @@ def test_manage_watch_only_account(main_screen: MainWindow, address: str, color: @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703033', 'Manage a generated account') @pytest.mark.case(703033) -@pytest.mark.parametrize('user_account', [constants.user.user_account_default]) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) @pytest.mark.parametrize('name, color, emoji, emoji_unicode, ' 'new_name, new_color, new_emoji, new_emoji_unicode', [ pytest.param('GenAcc1', '#2a4af5', 'sunglasses', '1f60e', @@ -171,7 +137,7 @@ def test_manage_generated_account(main_screen: MainWindow, user_account, @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703028', 'Manage a custom generated account') @pytest.mark.case(703028) -@pytest.mark.parametrize('user_account', [constants.user.user_account_default]) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) @pytest.mark.parametrize('derivation_path, generated_address_index, name, color, emoji, emoji_unicode', [ pytest.param('Ethereum', '5', 'Ethereum', '#216266', 'sunglasses', '1f60e'), pytest.param('Ethereum Testnet (Ropsten)', '10', 'Ethereum Testnet ', '#7140fd', 'sunglasses', '1f60e'), @@ -186,7 +152,9 @@ def test_manage_custom_generated_account(main_screen: MainWindow, user_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_derivation_path(derivation_path, generated_address_index, user_account.password).save() + account_popup.set_name(name).set_emoji(emoji).set_color(color).set_derivation_path(derivation_path, + generated_address_index, + user_account.password).save() with step('Verify that the account is correctly displayed in accounts list'): expected_account = constants.user.account_list_item(name, color.lower(), emoji_unicode) @@ -206,7 +174,7 @@ def test_manage_custom_generated_account(main_screen: MainWindow, user_account, @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703029', 'Manage a private key imported account') @pytest.mark.case(703029) -@pytest.mark.parametrize('user_account', [constants.user.user_account_default]) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) @pytest.mark.parametrize('name, color, emoji, emoji_unicode, ' 'new_name, new_color, new_emoji, new_emoji_unicode, private_key', [ pytest.param('PrivKeyAcc1', '#2a4af5', 'sunglasses', '1f60e', @@ -245,9 +213,132 @@ def test_private_key_imported_account(main_screen: MainWindow, user_account, 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'): + with step('Delete wallet account'): wallet.left_panel.delete_account(new_name).confirm() 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' + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703030', 'Manage a seed phrase imported account') +@pytest.mark.case(703030) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) +@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'), + pytest.param('SPAcc18', '#2a4af5', 'sunglasses', '1f60e', + 'SPAcc18edited', '#216266', 'thumbsup', '1f44d', + 'kitten tiny cup admit cactus shrug shuffle accident century faith roof plastic ' + 'beach police barely vacant sign blossom'), + pytest.param('SPAcc12', '#2a4af5', 'sunglasses', '1f60e', + 'SPAcc12edited', '#216266', 'thumbsup', '1f44d', + 'pelican chief sudden oval media rare swamp elephant lawsuit wheat knife initial') + ]) +def test_seed_phrase_imported_account(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('Verify that the account is correctly displayed in accounts list'): + expected_account = constants.user.account_list_item(name, color.lower(), 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('Edit wallet account'): + account_popup = wallet.left_panel.open_edit_account_popup(name) + account_popup.set_name(new_name).set_emoji(new_emoji).set_color(new_color).save() + + 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(new_name).agree_and_confirm() + + 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' + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703036', + 'Manage an account created from the generated seed phrase') +@pytest.mark.case(703036) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) +@pytest.mark.parametrize('name, color, emoji, emoji_unicode, ' + 'new_name, new_color, new_emoji, new_emoji_unicode, keypair_name', [ + pytest.param('SPAcc', '#2a4af5', 'sunglasses', '1f60e', + 'SPAccedited', '#216266', 'thumbsup', '1f44d', 'SPKeyPair')]) +def test_seed_phrase_generated_account(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, + keypair_name: str): + with step('Create generated 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_new_seed_phrase(keypair_name).save() + AuthenticatePopup().wait_until_appears().authenticate(user_account.password) + account_popup.wait_until_hidden() + + with step('Verify that the account is correctly displayed in accounts list'): + expected_account = constants.user.account_list_item(name, color.lower(), 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('Edit wallet account'): + account_popup = wallet.left_panel.open_edit_account_popup(name) + account_popup.set_name(new_name).set_emoji(new_emoji).set_color(new_color).save() + + 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(new_name).agree_and_confirm() + + 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' + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703514', + 'Choosing Use Keycard when adding account') +@pytest.mark.case(703514) +def test_use_keycard_when_adding_account(main_screen: MainWindow): + with step('Choose continue in keycard settings'): + wallet = main_screen.left_panel.open_wallet() + SigningPhrasePopup().wait_until_appears().confirm_phrase() + account_popup = wallet.left_panel.open_add_account_popup() + account_popup.continue_in_keycard_settings() + account_popup.wait_until_hidden() + + with (step('Verify that keycard settings view opened and all keycard settings available')): + keycard_view = KeycardSettingsView() + keycard_view.check_keycard_screen_loaded() + keycard_view.all_keycard_options_available() diff --git a/test/e2e/tests/test_wallet/test_wallet_saved_addresses.py b/test/e2e/tests/test_wallet/test_wallet_saved_addresses.py new file mode 100644 index 0000000000..52dcfd82a0 --- /dev/null +++ b/test/e2e/tests/test_wallet/test_wallet_saved_addresses.py @@ -0,0 +1,44 @@ +import allure +import pytest +from allure import step + +import configs +import driver +from gui.components.signing_phrase_popup import SigningPhrasePopup +from gui.main_window import MainWindow + +pytestmark = allure.suite("Wallet") + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703021', 'Manage a saved address') +@pytest.mark.case(703021) +@pytest.mark.parametrize('name, address, new_name', [ + pytest.param('Saved address name before', '0x8397bc3c5a60a1883174f722403d63a8833312b7', 'Saved address name after'), + pytest.param('Ens name before', 'nastya.stateofus.eth', 'Ens name after') +]) +def test_manage_saved_address(main_screen: MainWindow, name: str, address: str, new_name: str): + with step('Add new address'): + wallet = main_screen.left_panel.open_wallet() + SigningPhrasePopup().wait_until_appears().confirm_phrase() + wallet.left_panel.open_saved_addresses().open_add_address_popup().add_saved_address(name, address) + + with step('Verify that saved address is in the list of saved addresses'): + assert driver.waitFor( + lambda: name in wallet.left_panel.open_saved_addresses().address_names, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found' + + with step('Edit saved address to new name'): + wallet.left_panel.open_saved_addresses().open_edit_address_popup(name).edit_saved_address(new_name, address) + + with step('Verify that saved address with new name is in the list of saved addresses'): + assert driver.waitFor( + lambda: new_name in wallet.left_panel.open_saved_addresses().address_names, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found' + + with step('Delete address with new name'): + wallet.left_panel.open_saved_addresses().delete_saved_address(new_name) + + with step('Verify that saved address with new name is not in the list of saved addresses'): + assert driver.waitFor( + lambda: new_name not in wallet.left_panel.open_saved_addresses().address_names, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} not found'