feat(@DesktopApp): Refactor Login Steps
https://github.com/status-im/status-desktop/issues/6101 Refactor Login Steps
This commit is contained in:
parent
02e63a5eee
commit
46d47e3746
|
@ -13,4 +13,4 @@ def input_text(text, obj):
|
||||||
|
|
||||||
|
|
||||||
def object_not_enabled(obj):
|
def object_not_enabled(obj):
|
||||||
verify_object_not_enabled(obj)
|
verify_object_enabled(obj, 500, False)
|
||||||
|
|
|
@ -11,11 +11,6 @@ def verify_screen(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT):
|
||||||
result = is_loaded_visible_and_enabled(objName, timeout)
|
result = is_loaded_visible_and_enabled(objName, timeout)
|
||||||
test.verify(result, True)
|
test.verify(result, True)
|
||||||
|
|
||||||
|
def verify_object_enabled(objName, timeout=_MIN_WAIT_OBJ_TIMEOUT, condition=True):
|
||||||
def verify_screen_is_loaded(self, condition=True):
|
|
||||||
test.verify(self.is_loaded, condition)
|
|
||||||
|
|
||||||
|
|
||||||
def verify_object_not_enabled(objName, timeout=_MIN_WAIT_OBJ_TIMEOUT):
|
|
||||||
result = is_loaded_visible_and_enabled(objName, timeout)
|
result = is_loaded_visible_and_enabled(objName, timeout)
|
||||||
test.verify(result, False)
|
test.verify(result, condition)
|
||||||
|
|
|
@ -9,22 +9,19 @@
|
||||||
# *****************************************************************************/
|
# *****************************************************************************/
|
||||||
|
|
||||||
from drivers.SquishDriver import *
|
from drivers.SquishDriver import *
|
||||||
|
from drivers.SquishDriverVerification import *
|
||||||
|
|
||||||
# It defines the identifier for each Account View component:
|
# It defines the identifier for each Account View component:
|
||||||
class SAccountsComponents(Enum):
|
class SAccountsComponents(Enum):
|
||||||
ACCOUNTS_POPUP = "accountsView_accountListPanel"
|
ACCOUNTS_POPUP = "accountsView_accountListPanel"
|
||||||
|
|
||||||
#It defines the status accounts popup behavior and properties.
|
#It defines the status accounts popup behavior and properties.
|
||||||
class StatusAccountsScreen():
|
class StatusAccountsScreen():
|
||||||
__is_loaded = False
|
|
||||||
__accountsList = None
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
[self.__is_loaded, self.__accountsList] = is_loaded_visible_and_enabled(SAccountsComponents.ACCOUNTS_POPUP.value)
|
verify_screen(SAccountsComponents.ACCOUNTS_POPUP.value)
|
||||||
|
|
||||||
def is_loaded(self):
|
|
||||||
return self.__is_loaded
|
|
||||||
|
|
||||||
def find_account(self, account):
|
def find_account(self, account):
|
||||||
[found, account_obj] = self.__find_account(account)
|
[found, account_obj] = self.__find_account(account)
|
||||||
return found
|
return found
|
||||||
|
@ -38,8 +35,11 @@ class StatusAccountsScreen():
|
||||||
def __find_account(self, account):
|
def __find_account(self, account):
|
||||||
found = False
|
found = False
|
||||||
account_obj = None
|
account_obj = None
|
||||||
for index in range(self.__accountsList.count):
|
__is_loaded = False
|
||||||
a = self.__accountsList.itemAtIndex(index)
|
__accountsList = None
|
||||||
|
[__is_loaded, __accountsList] = is_loaded_visible_and_enabled(SAccountsComponents.ACCOUNTS_POPUP.value)
|
||||||
|
for index in range(__accountsList.count):
|
||||||
|
a = __accountsList.itemAtIndex(index)
|
||||||
if(a.username == account):
|
if(a.username == account):
|
||||||
account_obj = a
|
account_obj = a
|
||||||
found = True
|
found = True
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from screens.StatusAccountsScreen import StatusAccountsScreen
|
from screens.StatusAccountsScreen import StatusAccountsScreen
|
||||||
from drivers.SquishDriver import *
|
from drivers.SquishDriver import *
|
||||||
|
from drivers.SquishDriverVerification import *
|
||||||
|
|
||||||
|
|
||||||
# It defines the identifier for each Login View component:
|
# It defines the identifier for each Login View component:
|
||||||
|
@ -35,16 +36,16 @@ class StatusLoginScreen():
|
||||||
__login_view_obj = None
|
__login_view_obj = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
[self.__is_loaded, self.__login_view_obj] = is_loaded_visible_and_enabled(SLoginComponents.MAIN_VIEW.value)
|
verify_screen(SLoginComponents.MAIN_VIEW.value)
|
||||||
|
|
||||||
def is_loaded(self):
|
|
||||||
return self.__is_loaded
|
|
||||||
|
|
||||||
def login(self, password):
|
def login(self, password):
|
||||||
click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)
|
click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)
|
||||||
type(SLoginComponents.PASSWORD_INPUT.value, password)
|
type(SLoginComponents.PASSWORD_INPUT.value, password)
|
||||||
click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)
|
click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)
|
||||||
|
|
||||||
|
def verify_error_message_is_displayed(self):
|
||||||
|
verify_object_enabled(SLoginComponents.ERR_MSG_LABEL.value)
|
||||||
|
|
||||||
def get_accounts_selector_popup(self):
|
def get_accounts_selector_popup(self):
|
||||||
return StatusAccountsScreen()
|
return StatusAccountsScreen()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from data.StatusAccount import StatusAccount
|
|
||||||
from processes.StatusLoginProcess import StatusLoginProcess
|
|
||||||
from screens.StatusLoginScreen import StatusLoginScreen
|
from screens.StatusLoginScreen import StatusLoginScreen
|
||||||
|
|
||||||
_loginScreen = StatusLoginScreen()
|
_loginScreen = StatusLoginScreen()
|
||||||
|
@ -9,53 +7,6 @@ _loginScreen = StatusLoginScreen()
|
||||||
def step(context, password):
|
def step(context, password):
|
||||||
_loginScreen.login(password)
|
_loginScreen.login(password)
|
||||||
|
|
||||||
|
|
||||||
@Given("A Status Desktop |any| and |any|")
|
|
||||||
def step(context, account, password):
|
|
||||||
# Create new data domain:
|
|
||||||
accountObj = StatusAccount(account, password)
|
|
||||||
|
|
||||||
# Create new process:
|
|
||||||
process = StatusLoginProcess(accountObj)
|
|
||||||
|
|
||||||
# Set needed context properties:
|
|
||||||
context.userData['process'] = process
|
|
||||||
context.userData['account'] = accountObj
|
|
||||||
|
|
||||||
# Verify process can be executed:
|
|
||||||
test.verify(process.can_execute_process(),
|
|
||||||
"Not possible to start login process. Check if expected Login Screen is available.")
|
|
||||||
|
|
||||||
|
|
||||||
@When("the user tries to login with valid credentials")
|
|
||||||
def step(context):
|
|
||||||
loginProcess = context.userData['process']
|
|
||||||
|
|
||||||
# Check valid process behavior:
|
|
||||||
loginProcess.execute_process(True)
|
|
||||||
|
|
||||||
|
|
||||||
@When("the user tries to login with invalid credentials")
|
|
||||||
def step(context):
|
|
||||||
loginProcess = context.userData['process']
|
|
||||||
|
|
||||||
# Check invalid process behavior:
|
|
||||||
loginProcess.execute_process(False)
|
|
||||||
|
|
||||||
|
|
||||||
@Then("the user is able to login to Status Desktop application")
|
|
||||||
def step(context):
|
|
||||||
get_process_result(context)
|
|
||||||
|
|
||||||
|
|
||||||
@Then("the user is NOT able to login to Status Desktop application")
|
@Then("the user is NOT able to login to Status Desktop application")
|
||||||
def step(context):
|
def step(context):
|
||||||
accounts_popup = _loginScreen.get_accounts_selector_popup()
|
_loginScreen.verify_error_message_is_displayed()
|
||||||
verify_screen_is_loaded(accounts_popup, False)
|
|
||||||
|
|
||||||
|
|
||||||
# Common:
|
|
||||||
def get_process_result(context):
|
|
||||||
loginProcess = context.userData['process']
|
|
||||||
result, description = loginProcess.get_process_result()
|
|
||||||
test.verify(result, description)
|
|
||||||
|
|
Loading…
Reference in New Issue