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):
|
||||
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)
|
||||
test.verify(result, 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):
|
||||
def verify_object_enabled(objName, timeout=_MIN_WAIT_OBJ_TIMEOUT, condition=True):
|
||||
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.SquishDriverVerification import *
|
||||
|
||||
# It defines the identifier for each Account View component:
|
||||
class SAccountsComponents(Enum):
|
||||
ACCOUNTS_POPUP = "accountsView_accountListPanel"
|
||||
|
||||
#It defines the status accounts popup behavior and properties.
|
||||
class StatusAccountsScreen():
|
||||
__is_loaded = False
|
||||
__accountsList = None
|
||||
class StatusAccountsScreen():
|
||||
|
||||
|
||||
def __init__(self):
|
||||
[self.__is_loaded, self.__accountsList] = is_loaded_visible_and_enabled(SAccountsComponents.ACCOUNTS_POPUP.value)
|
||||
|
||||
def is_loaded(self):
|
||||
return self.__is_loaded
|
||||
|
||||
verify_screen(SAccountsComponents.ACCOUNTS_POPUP.value)
|
||||
|
||||
def find_account(self, account):
|
||||
[found, account_obj] = self.__find_account(account)
|
||||
return found
|
||||
|
@ -38,8 +35,11 @@ class StatusAccountsScreen():
|
|||
def __find_account(self, account):
|
||||
found = False
|
||||
account_obj = None
|
||||
for index in range(self.__accountsList.count):
|
||||
a = self.__accountsList.itemAtIndex(index)
|
||||
__is_loaded = False
|
||||
__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):
|
||||
account_obj = a
|
||||
found = True
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
from enum import Enum
|
||||
from screens.StatusAccountsScreen import StatusAccountsScreen
|
||||
from drivers.SquishDriver import *
|
||||
from drivers.SquishDriverVerification import *
|
||||
|
||||
|
||||
# It defines the identifier for each Login View component:
|
||||
|
@ -35,16 +36,16 @@ class StatusLoginScreen():
|
|||
__login_view_obj = None
|
||||
|
||||
def __init__(self):
|
||||
[self.__is_loaded, self.__login_view_obj] = is_loaded_visible_and_enabled(SLoginComponents.MAIN_VIEW.value)
|
||||
|
||||
def is_loaded(self):
|
||||
return self.__is_loaded
|
||||
verify_screen(SLoginComponents.MAIN_VIEW.value)
|
||||
|
||||
def login(self, password):
|
||||
click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)
|
||||
type(SLoginComponents.PASSWORD_INPUT.value, 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 get_accounts_selector_popup(self):
|
||||
return StatusAccountsScreen()
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from data.StatusAccount import StatusAccount
|
||||
from processes.StatusLoginProcess import StatusLoginProcess
|
||||
from screens.StatusLoginScreen import StatusLoginScreen
|
||||
|
||||
_loginScreen = StatusLoginScreen()
|
||||
|
@ -9,53 +7,6 @@ _loginScreen = StatusLoginScreen()
|
|||
def step(context, 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")
|
||||
def step(context):
|
||||
accounts_popup = _loginScreen.get_accounts_selector_popup()
|
||||
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)
|
||||
_loginScreen.verify_error_message_is_displayed()
|
||||
|
|
Loading…
Reference in New Issue