chore: test_create_keycard_account_with_new_seed_phrase improved (#307)

This commit is contained in:
Valentina1133 2023-11-16 13:48:04 +03:00 committed by GitHub
parent 0609eff86f
commit b72846e8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 107 additions and 29 deletions

View File

@ -5,7 +5,6 @@ class Keycard(Enum):
KEYCARD_PIN = '111111' KEYCARD_PIN = '111111'
KEYCARD_INCORRECT_PIN = '222222' KEYCARD_INCORRECT_PIN = '222222'
KEYCARD_NAME = 'Test Keycard' KEYCARD_NAME = 'Test Keycard'
ACCOUNT_NAME = 'Test Account'
KEYCARD_POPUP_HEADER_CREATE_SEED = 'Create a new Keycard account with a new seed phrase' KEYCARD_POPUP_HEADER_CREATE_SEED = 'Create a new Keycard account with a new seed phrase'
KEYCARD_POPUP_HEADER_IMPORT_SEED = 'Import or restore a Keycard via a seed phrase' KEYCARD_POPUP_HEADER_IMPORT_SEED = 'Import or restore a Keycard via a seed phrase'
KEYCARD_POPUP_HEADER_SET_UP_EXISTING = 'Set up a new Keycard with an existing account' KEYCARD_POPUP_HEADER_SET_UP_EXISTING = 'Set up a new Keycard with an existing account'

View File

@ -5,13 +5,14 @@ import allure
import configs import configs
import driver import driver
from constants import wallet_account_list_item
from gui.components.base_popup import BasePopup from gui.components.base_popup import BasePopup
from gui.components.emoji_popup import EmojiPopup
from gui.elements.button import Button from gui.elements.button import Button
from gui.elements.check_box import CheckBox from gui.elements.check_box import CheckBox
from gui.elements.object import QObject from gui.elements.object import QObject
from gui.elements.text_edit import TextEdit from gui.elements.text_edit import TextEdit
from gui.elements.text_label import TextLabel from gui.elements.text_label import TextLabel
from scripts.tools.image import Image
class KeycardPopup(BasePopup): class KeycardPopup(BasePopup):
@ -40,6 +41,9 @@ class KeycardPopup(BasePopup):
self._cancel_button = Button('cancel_StatusButton') self._cancel_button = Button('cancel_StatusButton')
self._understand_keypair_deleted_checkbox = CheckBox( self._understand_keypair_deleted_checkbox = CheckBox(
'i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox') 'i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox')
self._emoji_button = QObject('statusSmartIdenticonLetter_StatusLetterIdenticon')
self._add_another_account_button = Button('add_another_account_StatusButton')
self._color_radiobutton = QObject('color_StatusColorRadioButton')
@property @property
@allure.step('Get keycard image source path') @allure.step('Get keycard image source path')
@ -77,6 +81,18 @@ class KeycardPopup(BasePopup):
def keypair_name(self) -> str: def keypair_name(self) -> str:
return self._keypair_item.object.title return self._keypair_item.object.title
@property
@allure.step('Get accounts on keycard')
def account_tags(self) -> typing.List[wallet_account_list_item]:
_account_tags = []
for account_tag_item in driver.findAllObjects(self._keypair_tag.real_name):
element = QObject(name='', real_name=driver.objectMap.realName(account_tag_item))
name = str(account_tag_item.title)
icon_emoji = str(account_tag_item.asset.emoji)
icon_color = str(account_tag_item.bgColor.name)
_account_tags.append(wallet_account_list_item(name, icon_color, icon_emoji, element))
return sorted(_account_tags, key=lambda account: account.object.x)
@property @property
@allure.step('Get info title in keypair') @allure.step('Get info title in keypair')
def keypair_info_title(self) -> str: def keypair_info_title(self) -> str:
@ -93,9 +109,9 @@ class KeycardPopup(BasePopup):
return str(self._keypair_tag.object.bgColor.name) return str(self._keypair_tag.object.bgColor.name)
@property @property
@allure.step('Get keycard init state') @allure.step('Get account emoji in keypair')
def keycard_init_state(self) -> str: def keypair_account_emoji(self) -> str:
return self._keycard_init.object.state return str(self._keypair_tag.object.asset.emoji)
@property @property
@allure.step('Get selection box "checked" state') @allure.step('Get selection box "checked" state')
@ -156,6 +172,12 @@ class KeycardPopup(BasePopup):
@allure.step('Name keycard') @allure.step('Name keycard')
def name_keycard(self, name: str): def name_keycard(self, name: str):
driver.type(self.get_text_fields[0], name) driver.type(self.get_text_fields[0], name)
self.click_next()
return self
@allure.step('Add another account')
def add_account(self):
self._add_another_account_button.click()
return self return self
@allure.step('Name account') @allure.step('Name account')
@ -163,19 +185,37 @@ class KeycardPopup(BasePopup):
driver.type(self.get_text_fields[0], name) driver.type(self.get_text_fields[0], name)
return self return self
@allure.step('Set emoji for account')
def set_emoji(self, value: str):
self._emoji_button.click()
EmojiPopup().wait_until_appears().select(value)
return self
@allure.step('Set color for account')
def set_color(self, value: str):
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)]
assert value in colors, f'Color {value} not found in {colors}'
self._color_radiobutton.real_name['radioButtonColor'] = value
self._color_radiobutton.click()
return self
@allure.step('Create keycard account with seed phrase') @allure.step('Create keycard account with seed phrase')
def create_keycard_account_with_seed_phrase(self, keycard_name: str, account_name: str): def create_keycard_account_with_seed_phrase(self, keycard_name: str, account_name: str):
self.reveal_seed_phrase_and_confirm_words() self.confirm_seed_phrase()
self.name_keycard_and_account(keycard_name, account_name) self.name_keycard(keycard_name)
self.name_account(account_name).click_next()
@allure.step('Reveal seed phrase and confirm words') @allure.step('Confirm seed phrase')
def reveal_seed_phrase_and_confirm_words(self): def confirm_seed_phrase(self):
time.sleep(1) time.sleep(1)
self.click_next().reveal_seed_phrase() self.click_next().reveal_seed_phrase()
seed_phrases = self.get_seed_phrases seed_phrases = self.get_seed_phrases
self.click_next() self.click_next()
self.confirm_first_word(seed_phrases).confirm_second_word(seed_phrases).confirm_third_word(seed_phrases) self.confirm_first_word(seed_phrases).confirm_second_word(seed_phrases).confirm_third_word(seed_phrases)
self.click_next() self.click_next()
return self
@allure.step('Name keycard and account') @allure.step('Name keycard and account')
def name_keycard_and_account(self, keycard_name, account_name): def name_keycard_and_account(self, keycard_name, account_name):

View File

@ -344,3 +344,5 @@ switchTabBar_12_words_StatusSwitchTabButton = {"checkable": True, "container": s
switchTabBar_18_words_StatusSwitchTabButton = {"checkable": True, "container": switchTabBar_StatusSwitchTabBar, "objectName": "18SeedButton", "text": "18 words", "type": "StatusSwitchTabButton", "visible": True} switchTabBar_18_words_StatusSwitchTabButton = {"checkable": True, "container": switchTabBar_StatusSwitchTabBar, "objectName": "18SeedButton", "text": "18 words", "type": "StatusSwitchTabButton", "visible": True}
switchTabBar_24_words_StatusSwitchTabButton = {"checkable": True, "container": switchTabBar_StatusSwitchTabBar, "objectName": "24SeedButton", "text": "24 words", "type": "StatusSwitchTabButton", "visible": True} switchTabBar_24_words_StatusSwitchTabButton = {"checkable": True, "container": switchTabBar_StatusSwitchTabBar, "objectName": "24SeedButton", "text": "24 words", "type": "StatusSwitchTabButton", "visible": True}
i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "confirmation", "type": "StatusCheckBox", "visible": True} i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "confirmation", "type": "StatusCheckBox", "visible": True}
statusSmartIdenticonLetter_StatusLetterIdenticon = {"container": statusDesktop_mainWindow_overlay, "objectName": "statusSmartIdenticonLetter", "type": "StatusLetterIdenticon", "visible": True}
add_another_account_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "secondaryButton", "type": "StatusButton", "unnamed": 1, "visible": True}

View File

@ -1,14 +1,11 @@
import time
import allure import allure
import pytest import pytest
from allure import step from allure import step
import configs import configs
import driver import driver
from constants import ColorCodes, aut_options from constants import aut_options
from constants.images_paths import PLUG_IN_KEYCARD_IMAGE_PATH, INSERT_KEYCARD_IMAGE_PATH, KEYCARD_SUCCESS_IMAGE_PATH, \ from constants.images_paths import PLUG_IN_KEYCARD_IMAGE_PATH, INSERT_KEYCARD_IMAGE_PATH, CHOOSE_KEYCARD_PIN_IMAGE_PATH
CHOOSE_KEYCARD_PIN_IMAGE_PATH
from constants.keycard import Keycard from constants.keycard import Keycard
from gui.main_window import MainWindow from gui.main_window import MainWindow
from gui.mocked_keycard_controller import MockedKeycardController from gui.mocked_keycard_controller import MockedKeycardController
@ -18,8 +15,16 @@ from gui.mocked_keycard_controller import MockedKeycardController
'Create a new keycard account with a new seed phrase') 'Create a new keycard account with a new seed phrase')
@pytest.mark.case(703624) @pytest.mark.case(703624)
@pytest.mark.parametrize('options', [aut_options.MOCK_KEYCARD]) @pytest.mark.parametrize('options', [aut_options.MOCK_KEYCARD])
@pytest.mark.parametrize(
'name, color, emoji_name, emoji, name1, color1, emoji1_name, emoji1, name2, color2, emoji2_name, emoji2',
[
pytest.param('Test Account', '#216266', 'sunglasses', '😎 ', 'Test Account2', '#2a4af5',
'thumbsup', '👍 ', 'Test Account3', '#ff7d46', 'cool', '🆒 ')
])
@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/274") @pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/274")
def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, options): def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, options, name, color, emoji_name, emoji,
name1, color1, emoji1_name, emoji1, name2, color2, emoji2_name,
emoji2):
with step('Choose option Create a new Keycard account with a new seed phrase in settings'): with step('Choose option Create a new Keycard account with a new seed phrase in settings'):
main_screen.prepare() main_screen.prepare()
keycard_settings = main_screen.left_panel.open_settings().left_panel.open_keycard_settings() keycard_settings = main_screen.left_panel.open_settings().left_panel.open_keycard_settings()
@ -55,7 +60,7 @@ def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, op
keycard_controller.insert_keycard_1() keycard_controller.insert_keycard_1()
main_screen.show() main_screen.show()
with step('Verify displayed keycard popup instructions are correct'): with step('Verify displayed keycard popup instructions and image are correct'):
with step('Verify keycard is recognized'): with step('Verify keycard is recognized'):
assert driver.waitFor(lambda: Keycard.KEYCARD_RECOGNIZED.value in keycard_popup.keycard_instructions, assert driver.waitFor(lambda: Keycard.KEYCARD_RECOGNIZED.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
@ -63,9 +68,10 @@ def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, op
assert driver.waitFor(lambda: Keycard.KEYCARD_CHOOSE_PIN.value in keycard_popup.keycard_instructions, assert driver.waitFor(lambda: Keycard.KEYCARD_CHOOSE_PIN.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
assert Keycard.KEYCARD_PIN_NOTE.value in keycard_popup.keycard_instructions assert Keycard.KEYCARD_PIN_NOTE.value in keycard_popup.keycard_instructions
with step('Keycard image source path is correct'):
assert CHOOSE_KEYCARD_PIN_IMAGE_PATH == keycard_popup.keycard_image_source_path assert CHOOSE_KEYCARD_PIN_IMAGE_PATH == keycard_popup.keycard_image_source_path
with step('Insert PIN and repeat PIN and verify keycard popup instructions are correct'): with step('Enter and repeat PIN and verify keycard popup instructions are correct'):
pin = Keycard.KEYCARD_PIN.value pin = Keycard.KEYCARD_PIN.value
keycard_popup.input_pin(pin) keycard_popup.input_pin(pin)
assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \ assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \
@ -74,21 +80,52 @@ def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, op
assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \ assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \
"There is no correct keycard instruction" "There is no correct keycard instruction"
with step('Create keycard account using new seed phrase'): with step('Create keycard and first keycard account using new seed phrase'):
keycard_name = Keycard.KEYCARD_NAME.value keycard_name = Keycard.KEYCARD_NAME.value
account_name = Keycard.ACCOUNT_NAME.value keycard_popup.confirm_seed_phrase().name_keycard(keycard_name).name_account(name).set_color(color).set_emoji(
keycard_popup.create_keycard_account_with_seed_phrase(keycard_name, account_name) emoji_name)
with step('Verify that preview shows correct keycard and account name and color and instructions are correct'): with step('Verify keycard name and first account details on account tags are correct'):
assert keycard_name == keycard_popup.keypair_name
assert keycard_popup.account_tags[0].name == name
assert keycard_popup.account_tags[0].icon_color == color
assert keycard_popup.account_tags[0].icon_emoji == emoji
with step('Add second keycard account'):
keycard_popup.add_account().name_account(name1).set_emoji(emoji1_name).set_color(color1)
with step('Verify second account details on account tags are correct'):
assert keycard_popup.account_tags[1].name == name1
assert keycard_popup.account_tags[1].icon_color == color1
assert keycard_popup.account_tags[1].icon_emoji == emoji1
with step('Add third keycard account'):
keycard_popup.add_account().name_account(name2).set_emoji(emoji2_name).set_color(color2)
with step('Verify third account details on account tags are correct'):
assert keycard_popup.account_tags[2].name == name2
assert keycard_popup.account_tags[2].icon_color == color2
assert keycard_popup.account_tags[2].icon_emoji == emoji2
with step('Finalise keycard'):
keycard_popup.click_next()
with step('Verify that keycard instructions are correct'):
assert driver.waitFor(lambda: Keycard.KEYCARD_NEW_ACCOUNT_CREATED.value in keycard_popup.keycard_instructions), \ assert driver.waitFor(lambda: Keycard.KEYCARD_NEW_ACCOUNT_CREATED.value in keycard_popup.keycard_instructions), \
"There is no correct keycard instruction" "There is no correct keycard instruction"
assert keycard_popup.keypair_name == keycard_name, "Keycard name in preview is incorrect" with step('Go to wallet settings and verify accounts and account details are correct'):
assert keycard_popup.keypair_account_name == account_name, "Account name in preview is incorrect" account_order = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_order()
assert keycard_popup.keypair_account_color == ColorCodes.BLUE.value, "Color in preview is incorrect" with step('First account details are correct'):
assert account_order.accounts[1].name == name
assert account_order.accounts[1].icon_color == color
assert account_order.accounts[1].icon_emoji == emoji
with step('Second account details are correct'):
assert account_order.accounts[2].name == name1
assert account_order.accounts[2].icon_color == color1
assert account_order.accounts[2].icon_emoji == emoji1
with step('Third account details are correct'):
assert account_order.accounts[3].name == name2
assert account_order.accounts[3].icon_color == color2
assert account_order.accounts[3].icon_emoji == emoji2
with step('Keycard image source path is correct'):
time.sleep(2)
assert KEYCARD_SUCCESS_IMAGE_PATH == keycard_popup.keycard_image_source_path
keycard_popup.click_next()