test: test_check_whats_on_keycard added (#294)

This commit is contained in:
Valentina1133 2023-11-10 16:30:47 +01:00 committed by GitHub
parent 828b7fc02e
commit 1dd73a0f92
7 changed files with 214 additions and 12 deletions

View File

@ -2,7 +2,7 @@ from enum import Enum
class Keycard(Enum):
KEYCARD_PIN = '000000'
KEYCARD_PIN = '111111'
KEYCARD_NAME = 'Test Keycard'
ACCOUNT_NAME = 'Test Account'
KEYCARD_POPUP_HEADER_CREATE_SEED = 'Create a new Keycard account with a new seed phrase'
@ -12,9 +12,11 @@ class Keycard(Enum):
KEYCARD_INSTRUCTIONS_INSERT_KEYCARD = 'Insert Keycard...'
KEYCARD_RECOGNIZED = 'Keycard recognized'
KEYCARD_CHOOSE_PIN = 'Choose a Keycard PIN'
KEYCARD_ENTER_PIN = "Enter this Keycards PIN"
KEYCARD_PIN_NOTE = 'It is very important that you do not lose this PIN'
KEYCARD_REPEAT_PIN = 'Repeat Keycard PIN'
KEYCARD_PIN_SET = 'Keycard PIN set'
KEYCARD_PIN_VERIFIED = 'Keycard PIN verified!'
KEYCARD_NAME_KEYCARD = 'Name this Keycard'
KEYCARD_NAME_ACCOUNTS = 'Name accounts'
KEYCARD_NEW_ACCOUNT_CREATED = 'New account successfully created'
@ -25,3 +27,10 @@ class Keycard(Enum):
KEYCARD_MIGRATING = 'Migrating key pair to Keycard'
KEYCARD_KEYPAIR_MIGRATED = 'Keypair successfully migrated'
KEYCARD_COMPLETE_MIGRATION = 'To complete migration close Status and log in with your new Keycard'
KEYCARD_EMPTY = 'Keycard is empty'
KEYCARD_NO_KEYPAIR = 'There is no key pair on this Keycard'
KEYCARD_NOT = 'This is not a Keycard'
KEYCARD_NOT_RECOGNIZED_NOTE = 'The card inserted is not a recognised Keycard,\nplease remove and try and again'
KEYCARD_LOCKED = 'Keycard locked'
KEYCARD_LOCKED_NOTE = 'You will need to unlock it before proceeding'
KEYCARD_ACCOUNTS = 'Accounts on this Keycard'

View File

@ -32,9 +32,11 @@ class KeycardPopup(BasePopup):
self._seed_phrase_24_words_button = Button('switchTabBar_24_words_StatusSwitchTabButton')
self._field_object = QObject('edit_TextEdit')
self._keypair_item = QObject('o_KeyPairItem')
self._keypair_on_keycard_item = QObject('o_KeyPairUnknownItem')
self._keypair_tag = QObject('o_StatusListItemTag')
self._selection_box = QObject('radioButton_StatusRadioButton')
self._keycard_init = QObject('o_KeycardInit')
self._cancel_button = Button('cancel_StatusButton')
@property
@allure.step('Get keycard image')
@ -97,6 +99,11 @@ class KeycardPopup(BasePopup):
def is_keypair_selection_box_checked(self) -> bool:
return self._selection_box.object.checked
@property
@allure.step('Get keycard name in accounts on keycard section')
def keypair_on_keycard_name(self) -> str:
return str(self._keypair_on_keycard_item.object.keyPairName)
@property
@allure.step('Get next button "enabled" state')
def is_next_button_enabled(self) -> bool:
@ -180,6 +187,7 @@ class KeycardPopup(BasePopup):
self.input_pin(pin)
self.click_next()
@allure.step('Input seed phrase')
def input_seed_phrase(self, seed_phrase_words: list):
self.click_next()
if len(seed_phrase_words) == 12:
@ -194,3 +202,7 @@ class KeycardPopup(BasePopup):
self._seed_phrase_word_text_edit.real_name['objectName'] = f'statusSeedPhraseInputField{count}'
self._seed_phrase_word_text_edit.text = word
self.click_next()
@allure.step('Click cancel button')
def cancel(self):
self._cancel_button.click()

View File

@ -26,6 +26,10 @@ class MockedKeycardController(Window):
self._keycard_not_inserted_item = QObject('keycard_Not_Inserted_StatusMenuItem')
self._keycard_inserted_item = QObject('keycard_Inserted_StatusMenuItem')
self._custom_keycard_item = QObject('custom_Keycard_StatusMenuItem')
self._not_status_keycard_item = QObject('not_Status_Keycard_StatusMenuItem')
self._empty_keycard_item = QObject('empty_Keycard_StatusMenuItem')
self._max_slots_reached_item = QObject('max_Pairing_Slots_Reached_StatusMenuItem')
self._mnemonic_metadata_item = QObject('keycard_With_Mnemonic_Metadata_StatusMenuItem')
self._field_object = QObject('keycard_edit_TextEdit')
self._scroll = Scroll('keycardFlickable')
@ -50,6 +54,15 @@ class MockedKeycardController(Window):
time.sleep(1)
return self
@allure.step('Click Remove keycard')
def remove_keycard(self):
time.sleep(1)
if not self._remove_keycard_button.is_visible:
self._scroll.vertical_down_to(self._remove_keycard_button)
self._remove_keycard_button.click()
time.sleep(1)
return self
@allure.step('Click Insert Keycard 1')
def insert_keycard_1(self):
self._insert_keycard_1_button.click()
@ -71,3 +84,39 @@ class MockedKeycardController(Window):
self._scroll.vertical_scroll_to(QObject(name='', real_name=driver.objectMap.realName(fields[index])))
driver.type(fields[index], details)
time.sleep(1)
@allure.step('Choose not Status keycard from initial keycard state dropdown')
def choose_not_status_keycard(self):
if not self._keycard_state_button.is_visible:
self._scroll.vertical_scroll_to(self._keycard_state_button)
self._keycard_state_button.click()
self._not_status_keycard_item.click()
time.sleep(1)
return self
@allure.step('Choose empty keycard from initial keycard state dropdown')
def choose_empty_keycard(self):
if not self._keycard_state_button.is_visible:
self._scroll.vertical_scroll_to(self._keycard_state_button)
self._keycard_state_button.click()
self._empty_keycard_item.click()
time.sleep(1)
return self
@allure.step('Choose keycard with MAX pairing slots reached from initial keycard state dropdown')
def choose_max_slots_reached_keycard(self):
if not self._keycard_state_button.is_visible:
self._scroll.vertical_scroll_to(self._keycard_state_button)
self._keycard_state_button.click()
self._max_slots_reached_item.click()
time.sleep(1)
return self
@allure.step('Choose keycard with mnemonic and metadata from initial keycard state dropdown')
def choose_mnemonic_metadata_keycard(self):
if not self._keycard_state_button.is_visible:
self._scroll.vertical_scroll_to(self._keycard_state_button)
self._keycard_state_button.click()
self._mnemonic_metadata_item.click()
time.sleep(1)
return self

View File

@ -334,6 +334,7 @@ word0_StatusInput = {"container": statusDesktop_mainWindow_overlay, "id": "word0
word1_StatusInput = {"container": statusDesktop_mainWindow_overlay, "id": "word1", "type": "StatusInput", "unnamed": 1, "visible": True}
word2_StatusInput = {"container": statusDesktop_mainWindow_overlay, "id": "word2", "type": "StatusInput", "unnamed": 1, "visible": True}
o_KeyPairItem = {"container": statusDesktop_mainWindow_overlay, "type": "KeyPairItem", "unnamed": 1, "visible": True}
o_KeyPairUnknownItem = {"container": statusDesktop_mainWindow_overlay, "type": "KeyPairUnknownItem", "unnamed": 1, "visible": True}
o_StatusListItemTag = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListItemTag", "unnamed": 1, "visible": True}
radioButton_StatusRadioButton = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "radioButton", "type": "StatusRadioButton", "unnamed": 1, "visible": True}
statusSeedPhraseInputField_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "statusSeedPhraseInputField", "type": "TextEdit", "visible": True}

View File

@ -11,18 +11,18 @@ keycardSettingsTab = {"container": QQuickApplicationWindow, "type": "KeycardSett
set_initial_keycard_state_StatusButton = {"checkable": False, "container": keycardSettingsTab, "id": "selectKeycardsStateButton", "type": "StatusButton", "visible": True}
register_Keycard_StatusButton = {"checkable": False, "container": keycardSettingsTab, "objectName": "registerKeycardButton", "type": "StatusButton", "visible": True}
not_Status_Keycard_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "notStatusKeycardAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
empty_Keycard_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "emptyKeycardAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
max_Pairing_Slots_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPairingSlotsReachedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
max_PIN_Retries_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPINRetriesReachedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
max_PUK_Retries_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPUKRetriesReachedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
keycard_With_Mnemonic_Only_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "keycardWithMnemonicOnlyAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
keycard_With_Mnemonic_Metadata_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "keycardWithMnemonicAndMedatadaAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
not_Status_Keycard_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "notStatusKeycardAction", "type": "StatusMenuItem", "visible": True}
empty_Keycard_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "emptyKeycardAction", "text": "Empty Keycard", "type": "StatusMenuItem", "visible": True}
max_Pairing_Slots_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPairingSlotsReachedAction", "type": "StatusMenuItem", "visible": True}
max_PIN_Retries_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPINRetriesReachedAction", "type": "StatusMenuItem", "visible": True}
max_PUK_Retries_Reached_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "maxPUKRetriesReachedAction", "type": "StatusMenuItem", "visible": True}
keycard_With_Mnemonic_Only_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "keycardWithMnemonicOnlyAction", "type": "StatusMenuItem", "visible": True}
keycard_With_Mnemonic_Metadata_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "keycardWithMnemonicAndMedatadaAction", "type": "StatusMenuItem", "visible": True}
custom_Keycard_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "customKeycardAction", "type": "StatusMenuItem", "visible": True}
reader_Unplugged_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateReaderUnpluggedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
keycard_Not_Inserted_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateKeycardNotInsertedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
keycard_Inserted_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateKeycardInsertedAction", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
reader_Unplugged_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateReaderUnpluggedAction", "type": "StatusMenuItem", "visible": True}
keycard_Not_Inserted_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateKeycardNotInsertedAction", "type": "StatusMenuItem", "visible": True}
keycard_Inserted_StatusMenuItem = {"checkable": False, "container": mocked_Keycard_Lib_Controller_Overlay, "enabled": True, "objectName": "readerStateKeycardInsertedAction", "type": "StatusMenuItem", "visible": True}
keycard_edit_TextEdit = {"container": keycardSettingsTab, "id": "edit", "type": "TextEdit", "unnamed": 1, "visible": True}
keycardFlickable = {"container": keycardSettingsTab, "type": "Flickable", "unnamed": 1, "visible": True}
keycardFlickable = {"container": keycardSettingsTab, "type": "Flickable", "unnamed": 1, "visible": True}

View File

@ -39,6 +39,11 @@ class KeycardSettingsView(QObject):
self._setup_keycard_with_existing_account_button.click()
return KeycardPopup().wait_until_appears()
@allure.step('Choose check whats on keycard')
def click_check_whats_on_keycard(self):
self._check_whats_on_keycard_button.click()
return KeycardPopup().wait_until_appears()
@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'

View File

@ -0,0 +1,126 @@
import allure
import pytest
from allure import step
import configs
import constants
import driver
from constants import aut_options
from constants.keycard import Keycard
from gui.main_window import MainWindow
from gui.mocked_keycard_controller import MockedKeycardController
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703627', 'Check whats on a Keycard')
@pytest.mark.case(703627)
@pytest.mark.parametrize('user_account', [constants.user.user_account_one])
@pytest.mark.parametrize('options', [aut_options.MOCK_KEYCARD])
@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/274")
def test_check_whats_on_keycard(main_screen: MainWindow, user_account, options):
main_screen.prepare()
with step('Choose option Check whats on keycard in settings'):
keycard_settings = main_screen.left_panel.open_settings().left_panel.open_keycard_settings()
keycard_popup = keycard_settings.click_check_whats_on_keycard()
with step('Verify displayed keycard popup instructions are correct'):
assert Keycard.KEYCARD_INSTRUCTIONS_PLUG_IN.value in keycard_popup.keycard_instructions, \
"There is no correct keycard instruction"
with step('Plug in reader'):
main_screen.hide()
keycard_controller = MockedKeycardController().wait_until_appears()
keycard_controller.plugin_reader()
main_screen.show()
with step('Verify displayed keycard popup instructions are correct'):
assert driver.waitFor(
lambda: Keycard.KEYCARD_INSTRUCTIONS_INSERT_KEYCARD.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
with step('Register and insert not status keycard'):
main_screen.hide()
keycard_controller.choose_not_status_keycard()
keycard_controller.register_keycard()
keycard_controller.insert_keycard_1()
main_screen.show()
with step('Verify keycard is not recognized'):
assert driver.waitFor(lambda: Keycard.KEYCARD_NOT.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
assert driver.waitFor(lambda: Keycard.KEYCARD_NOT_RECOGNIZED_NOTE.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f"There is no correct keycard instruction {keycard_popup.keycard_instructions}"
with step('Close keycard popup'):
keycard_popup.cancel()
with step('Insert empty keycard'):
main_screen.hide()
keycard_controller.choose_empty_keycard()
keycard_controller.register_keycard()
keycard_controller.insert_keycard_1()
main_screen.show()
with step('Check what is on keycard'):
keycard_popup = keycard_settings.click_check_whats_on_keycard()
with step('Verify keycard is empty'):
assert driver.waitFor(lambda: Keycard.KEYCARD_EMPTY.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
assert driver.waitFor(lambda: Keycard.KEYCARD_NO_KEYPAIR.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
with step('Close keycard popup'):
keycard_popup.click_next()
with step('Insert locked keycard'):
main_screen.hide()
keycard_controller.choose_max_slots_reached_keycard()
keycard_controller.register_keycard()
keycard_controller.insert_keycard_1()
main_screen.show()
with step('Check what is on keycard'):
keycard_popup = keycard_settings.click_check_whats_on_keycard()
with step('Verify keycard is locked'):
assert driver.waitFor(lambda: Keycard.KEYCARD_LOCKED.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
assert driver.waitFor(lambda: Keycard.KEYCARD_LOCKED_NOTE.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
with step('Close keycard popup'):
keycard_popup.cancel()
with step('Remove keycard and insert keycard with accounts on it'):
main_screen.hide()
keycard_controller.remove_keycard()
keycard_controller.choose_mnemonic_metadata_keycard()
keycard_controller.register_keycard()
keycard_controller.insert_keycard_1()
main_screen.show()
with step('Check what is on keycard'):
keycard_popup = keycard_settings.click_check_whats_on_keycard()
with step('Insert PIN and repeat PIN and verify keycard popup instructions are correct'):
with step('Verify that asked to choose PIN'):
assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN.value in keycard_popup.keycard_instructions,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction"
pin = Keycard.KEYCARD_PIN.value
keycard_name = 'Card-1 Name'
keycard_popup.input_pin(pin)
assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_VERIFIED.value in keycard_popup.keycard_instructions), \
"There is no correct keycard instruction"
with step('Close keycard popup'):
keycard_popup.click_next()
with step('Verify that preview shows correct keycard and instructions are correct'):
assert driver.waitFor(lambda: Keycard.KEYCARD_ACCOUNTS.value in keycard_popup.keycard_instructions), \
"There is no correct keycard instruction"
assert keycard_popup.keypair_on_keycard_name == keycard_name, "Keycard name in preview is incorrect"
with step('Close keycard popup'):
keycard_popup.click_next()