Skip to content

Commit

Permalink
test(suite_onboarding): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Druzhinin committed May 3, 2023
1 parent 839937c commit 92433d7
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 224 deletions.
35 changes: 33 additions & 2 deletions test/ui-test/src/drivers/elements/base_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import names
import object
import squish
import test


class BaseElement:
Expand All @@ -18,7 +19,6 @@ def __str__(self):
@property
def object(self):
return squish.waitForObject(self.object_name)


@property
def existent(self):
Expand Down Expand Up @@ -50,6 +50,10 @@ def is_visible(self) -> bool:
return squish.waitForObject(self.object_name, 0).visible
except (AttributeError, LookupError, RuntimeError):
return False

@property
def image(self) -> squish.Image:
return object.grabScreenshot(self.object)

def click(
self,
Expand All @@ -69,4 +73,31 @@ def wait_until_appears(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_
return self

def wait_until_hidden(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC):
assert squish.waitFor(lambda: not self.is_visible, timeout_msec), f'Object {self} is not hidden'
squish.waitFor(lambda: not self.is_visible, timeout_msec), f'Object {self} is not hidden'

def wait_for_image(
self,
fp: str,
tolerant: bool = True,
threshold: int = 99.5,
min_scale: int = 50,
max_scale: int = 200,
multiscale: bool = True,
timeout_msec: int = squish.testSettings.waitForObjectTimeout
) -> squish.UiTypes.ScreenRectangle:
try:
squish.waitForImage(
fp,
{
'tolerant': tolerant,
'threshold': threshold,
'minScale': min_scale,
'maxScale': max_scale,
'multiscale': multiscale,
'timeout': timeout_msec
},
self.object
)
except LookupError as err:
test.attachImage(self.image, f'Image not found in/not equals to')
raise err
4 changes: 2 additions & 2 deletions test/ui-test/src/screens/StatusLoginScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def enter_password(self, password):
self._password_text_edit.text = password
click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)

def verify_error_message_is_displayed(self):
verify_object_enabled(SLoginComponents.ERR_MSG_LABEL.value)
def verify_error_message_is_displayed(self, timeout_msec: int = 500):
verify_object_enabled(SLoginComponents.ERR_MSG_LABEL.value, timeout_msec)

def get_accounts_selector_popup(self):
return StatusAccountsScreen()
Expand Down
98 changes: 65 additions & 33 deletions test/ui-test/src/screens/StatusWelcomeScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,68 @@
# * \brief Sign Up and Login for new users to the app.
# *****************************************************************************/

from array import array
from enum import Enum
import sys
from abc import abstractmethod
from enum import Enum

import common.Common as common
from common.SeedUtils import *
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from common.SeedUtils import *
import common.Common as common


class OnboardingBaseScreen(BaseElement):

def __init__(self, object_name):
super(OnboardingBaseScreen, self).__init__(object_name)
self._back_button = Button('onboarding_back_button')

@abstractmethod
def back(self):
pass


class CreatePasswordView(OnboardingBaseScreen):

def __init__(self):
super(CreatePasswordView, self).__init__('mainWindow_CreatePasswordView')
self._new_password_text_field = TextEdit('onboarding_newPsw_Input')
self._confirm_password_text_field = TextEdit('onboarding_confirmPsw_Input')
self._create_button = Button('onboarding_create_password_button')
self._password_strength_indicator = BaseElement('onboarding_strengthInditactor')

@property
def new_password(self) -> str:
return self._new_password_text_field.text

@new_password.setter
def new_password(self, value: str):
self._new_password_text_field.text = value

@property
def confirm_password(self) -> str:
return self._new_password_text_field.text

@confirm_password.setter
def confirm_password(self, value: str):
self._new_password_text_field.text = value

@property
def password_strength_indicator(self):
return self._password_strength_indicator.image

def is_password_strength_indicator_equal(self, indicator : str):
verify_text_matching(self._password_strength_indicator.symbolic_name, indicator)

def create_password(self, value: str):
self.new_password.text = value
self.confirm_password.text = value
self._create_button.click()
# TODO: return Confirm Password View

def back(self):
self._back_button.click()
# TODO: return Details View


class AgreementPopUp(Enum):
Expand All @@ -23,6 +78,7 @@ class AgreementPopUp(Enum):
TERMS_OF_USE_CHECK_BOX: str = "termsOfUseCheckBox_StatusCheckBox"
GET_STARTED_BUTTON: str = "getStartedStatusButton_StatusButton"


class SignUpComponents(Enum):
NEW_TO_STATUS: str = "mainWindow_I_am_new_to_Status_StatusBaseText"
GENERATE_NEW_KEYS: str = "keysMainView_PrimaryAction_Button"
Expand All @@ -44,6 +100,7 @@ class SignUpComponents(Enum):
WELCOME_SCREEN_CHAT_KEY_TEXT: str = "mainWindow_WelcomeScreen_ChatKeyText"
BACK_BTN: str = "onboarding_back_button"


class SeedPhraseComponents(Enum):
IMPORT_A_SEED_TEXT: str = "import_a_seed_phrase_StatusBaseText"
INVALID_SEED_TEXT: str = "onboarding_InvalidSeed_Text"
Expand All @@ -54,6 +111,7 @@ class SeedPhraseComponents(Enum):
SEEDS_WORDS_TEXTFIELD_template: str = "onboarding_SeedPhrase_Input_TextField_"
SUBMIT_BUTTON: str = "seedPhraseView_Submit_Button"


class PasswordStrengthPossibilities(Enum):
LOWER_VERY_WEAK = "lower_very_weak"
UPPER_VERY_WEAK = "upper_very_weak"
Expand All @@ -64,14 +122,17 @@ class PasswordStrengthPossibilities(Enum):
NUMBERS_SYMBOLS_LOWER_UPPER_GOOD = "numbers_symbols_lower_upper_good"
NUMBERS_SYMBOLS_LOWER_UPPER_GREAT = "numbers_symbols_lower_upper_great"


class MainScreen(Enum):
SETTINGS_BUTTON = "settings_navbar_settings_icon_StatusIcon"


class LoginView(Enum):
LOGIN_VIEW_USER_IMAGE: str = "loginView_userImage"
PASSWORD_INPUT = "loginView_passwordInput"
SUBMIT_BTN = "loginView_submitBtn"


class StatusWelcomeScreen:

def __init__(self):
Expand Down Expand Up @@ -172,35 +233,6 @@ def agree_terms_and_conditions(self):
def seed_phrase_visible(self):
is_loaded_visible_and_enabled(SeedPhraseComponents.INVALID_SEED_TEXT.value)

# The following validation is based in screenshots comparison and is OS dependent:
def validate_password_strength(self, strength: str):
if sys.platform == "darwin":
if strength == PasswordStrengthPossibilities.LOWER_VERY_WEAK.value:
verify_screenshot("VP-PWStrength-lower_very_weak")

elif strength == PasswordStrengthPossibilities.UPPER_VERY_WEAK.value:
verify_screenshot("VP-PWStrength-upper_very_weak")

elif strength == PasswordStrengthPossibilities.NUMBERS_VERY_WEAK.value:
verify_screenshot("VP-PWStrength-numbers_very_weak")

elif strength == PasswordStrengthPossibilities.SYMBOLS_VERY_WEAK.value:
verify_screenshot("VP-PWStrength-symbols_very_weak")

elif strength == PasswordStrengthPossibilities.NUMBERS_SYMBOLS_WEAK.value:
verify_screenshot("VP-PWStrength-numbers_symbols_weak")

elif strength == PasswordStrengthPossibilities.NUMBERS_SYMBOLS_LOWER_SOSO.value:
verify_screenshot("VP-PWStrength-numbers_symbols_lower_so-so")

elif strength == PasswordStrengthPossibilities.NUMBERS_SYMBOLS_LOWER_UPPER_GOOD.value:
verify_screenshot("VP-PWStrength-numbers_symbols_lower_upper_good")

elif strength == PasswordStrengthPossibilities.NUMBERS_SYMBOLS_LOWER_UPPER_GREAT.value:
verify_screenshot("VP-PWStrength-numbers_symbols_lower_upper_great")

# TODO: Get screenshots in Linux

def input_profile_image(self, profileImageUrl: str):
workflow = get_obj(SignUpComponents.PROFILE_IMAGE_CROP_WORKFLOW_ITEM.value)
workflow.cropImage(profileImageUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
# Main:
mainWindow_Welcome_to_Status_StyledText = {"container": statusDesktop_mainWindow, "text": "Welcome to Status", "type": "StyledText", "unnamed": 1, "visible": True}
mainWindow_startupOnboarding_OnboardingLayout = {"container": statusDesktop_mainWindow, "objectName": "startupOnboardingLayout", "type": "OnboardingLayout", "visible": True}
onboarding_newPsw_Input = {"container": statusDesktop_mainWindow, "objectName": "passwordViewNewPassword", "type": "StatusPasswordInput", "visible": True}
onboarding_confirmPsw_Input = {"container": statusDesktop_mainWindow, "objectName": "passwordViewNewPasswordConfirm", "type": "StatusPasswordInput", "visible": True}
onboarding_create_password_button = {"container": statusDesktop_mainWindow, "objectName": "onboardingCreatePasswordButton", "type": "StatusButton"}

# Create Password View
mainWindow_CreatePasswordView = {"container": statusDesktop_mainWindow, "type": "CreatePasswordView", "unnamed": 1, "visible": True}
onboarding_newPsw_Input = {"container": mainWindow_CreatePasswordView, "objectName": "passwordViewNewPassword", "type": "StatusPasswordInput", "visible": True}
onboarding_confirmPsw_Input = {"container": mainWindow_CreatePasswordView, "objectName": "passwordViewNewPasswordConfirm", "type": "StatusPasswordInput", "visible": True}
onboarding_create_password_button = {"container": mainWindow_CreatePasswordView, "objectName": "onboardingCreatePasswordButton", "type": "StatusButton"}
onboarding_strengthInditactor = {"container": mainWindow_CreatePasswordView, "type": "StatusPasswordStrengthIndicator", "unnamed": 1, "visible": True}

onboarding_confirmPswAgain_Input = {"container": statusDesktop_mainWindow, "objectName": "confirmAgainPasswordInput", "type": "StatusPasswordInput", "visible": True}
onboarding_finalise_password_button = {"container": statusDesktop_mainWindow, "objectName": "confirmPswSubmitBtn", "type": "StatusButton"}
acknowledge_checkbox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "objectName": "acknowledgeCheckBox", "type": "StatusCheckBox", "visible": True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def step(context, username, password):

@Then("the user is NOT able to login to Status Desktop application")
def step(context):
_main_screen = StatusMainScreen()
_main_screen.wait_for_splash_animation_ends()
_loginScreen.verify_error_message_is_displayed()
_loginScreen.verify_error_message_is_displayed(15000)

###########################################################################
### COMMON methods used in different steps given/when/then region:
Expand Down
16 changes: 13 additions & 3 deletions test/ui-test/testSuites/suite_onboarding/shared/steps/steps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from screens.StatusWelcomeScreen import StatusWelcomeScreen
from pathlib import Path
import sys
from screens.StatusWelcomeScreen import CreatePasswordView

_welcome_screen = CreatePasswordView()


@When('the user inputs the password \"|any|\"')
def step(context, password):
_welcome_screen.new_password = str(password)

_welcomeScreen = StatusWelcomeScreen()

@Then("the password strength indicator is \"|any|\"")
def step(context, strength):
_welcomeScreen.validate_password_strength(strength)
_welcome_screen.is_password_strength_indicator_equal(strength)


This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ Feature: Password strength validation including UI pixel-perfect validation
** and the user inputs username "tester123"

Scenario Outline: As a user I want to see the strength of the password
Given the user clears input "onboarding_newPsw_Input"
When the user inputs the following "<password>" with ui-component "onboarding_newPsw_Input"
When the user inputs the password "<password>"
Then the password strength indicator is "<strength>"

Examples:
| password | strength |
| abc | lower_very_weak |
| ABC | upper_very_weak |
| 123 | numbers_very_weak |
| +_! | symbols_very_weak |
| +1_3!48 | numbers_symbols_weak |
| +1_3!48a | numbers_symbols_lower_so-so |
| +1_3!48aT | numbers_symbols_lower_upper_good |
| +1_3!48aTq | numbers_symbols_lower_upper_great |
| password | strength |
| abc | Very weak |
| ABC | Very weak |
| 123 | Very weak |
| +_! | Very weak |
| +1_3!48 | Weak |
| +1_3!48a | So-so |
| +1_3!48aT | Good |
| +1_3!48aTq | Great |
Loading

0 comments on commit 92433d7

Please sign in to comment.