feat(@DesktopApp): Refactor Login Steps

https://github.com/status-im/status-desktop/issues/6101

Refactor Login Steps
This commit is contained in:
femi 2022-06-16 02:46:45 +01:00 committed by Olufemi Ade-Olusile
parent 8d3fad8342
commit a19b17aeac
10 changed files with 64 additions and 62 deletions

View File

@ -7,11 +7,15 @@ _MAX_WAIT_OBJ_TIMEOUT = 5000
_MIN_WAIT_OBJ_TIMEOUT = 500 _MIN_WAIT_OBJ_TIMEOUT = 500
def verify_screen_is_loaded(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT): 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_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_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, False)

View File

@ -23,7 +23,7 @@ class ChatComponents(Enum):
class StatusChatScreen: class StatusChatScreen:
def __init__(self): def __init__(self):
verify_screen_is_loaded(ChatComponents.TYPE_A_MESSAGE_PLACE_HOLDER.value) verify_screen(ChatComponents.TYPE_A_MESSAGE_PLACE_HOLDER.value)
def sendMessage(self, message): def sendMessage(self, message):
type(ChatComponents.MESSAGE_INPUT.value, message) type(ChatComponents.MESSAGE_INPUT.value, message)

View File

@ -1,7 +1,7 @@
#****************************************************************************** # ******************************************************************************
# Status.im # Status.im
#*****************************************************************************/ # *****************************************************************************/
#/** # /**
# * \file StatusLoginScreen.py # * \file StatusLoginScreen.py
# * # *
# * \date February 2022 # * \date February 2022
@ -12,19 +12,22 @@ from enum import Enum
from screens.StatusAccountsScreen import StatusAccountsScreen from screens.StatusAccountsScreen import StatusAccountsScreen
from drivers.SquishDriver import * from drivers.SquishDriver import *
# It defines the identifier for each Login View component: # It defines the identifier for each Login View component:
class SLoginComponents(Enum): class SLoginComponents(Enum):
MAIN_VIEW = "loginView_main" MAIN_VIEW = "loginView_main"
PASSWORD_INPUT = "loginView_passwordInput" PASSWORD_INPUT = "loginView_passwordInput"
SUBMIT_BTN = "loginView_submitBtn" SUBMIT_BTN = "loginView_submitBtn"
CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn" CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn"
ERR_MSG_LABEL = "loginView_errMsgLabel" ERR_MSG_LABEL = "loginView_errMsgLabel"
# It defines expected password placeholder text. # It defines expected password placeholder text.
class PswPlaceholderTextType(Enum): class PswPlaceholderTextType(Enum):
NONE = None NONE = None
CONNECTING = "Connecting..." CONNECTING = "Connecting..."
PASSWORD = "Enter password" PASSWORD = "Enter password"
# It defines the status login screen behavior and properties. # It defines the status login screen behavior and properties.
class StatusLoginScreen(): class StatusLoginScreen():
@ -37,11 +40,13 @@ class StatusLoginScreen():
def is_loaded(self): def is_loaded(self):
return self.__is_loaded return self.__is_loaded
def introduce_password(self, password): def login(self, password):
result = False click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)
if click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value) and type(SLoginComponents.PASSWORD_INPUT.value, password): type(SLoginComponents.PASSWORD_INPUT.value, password)
result = True click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)
return result
def get_accounts_selector_popup(self):
return StatusAccountsScreen()
def submit_password(self): def submit_password(self):
return click_obj_by_name(SLoginComponents.SUBMIT_BTN.value) return click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)
@ -49,9 +54,6 @@ class StatusLoginScreen():
def open_accounts_selector_popup(self): def open_accounts_selector_popup(self):
return click_obj_by_name(SLoginComponents.CHANGE_ACCOUNT_BTN.value) return click_obj_by_name(SLoginComponents.CHANGE_ACCOUNT_BTN.value)
def get_accounts_selector_popup(self):
return StatusAccountsScreen()
def get_password_placeholder_text(self): def get_password_placeholder_text(self):
result = "" result = ""
[loaded, obj] = is_loaded(SLoginComponents.PASSWORD_INPUT.value) [loaded, obj] = is_loaded(SLoginComponents.PASSWORD_INPUT.value)
@ -66,12 +68,12 @@ class StatusLoginScreen():
result = obj.text result = obj.text
return result return result
def get_expected_error_message_text(self):#, language): def get_expected_error_message_text(self): # , language):
# NOTE: It could introduce language checkers. # NOTE: It could introduce language checkers.
return "Login failed. Please re-enter your password and try again." return "Login failed. Please re-enter your password and try again."
# NOT IMPLEMENTED STUFF: # NOT IMPLEMENTED STUFF:
def get_expected_placeholder_text(self, pswPlaceholderTextType):#, language): def get_expected_placeholder_text(self, pswPlaceholderTextType): # , language):
# NOTE: It could introduce language checkers. # NOTE: It could introduce language checkers.
raise NotImplementedError("TODO: get_expected_placeholder_text method") raise NotImplementedError("TODO: get_expected_placeholder_text method")
@ -83,4 +85,3 @@ class StatusLoginScreen():
def get_current_identicon(self): def get_current_identicon(self):
raise NotImplementedError("TODO: get_current_identicon method") raise NotImplementedError("TODO: get_current_identicon method")

View File

@ -29,7 +29,7 @@ class ChatNamePopUp(Enum):
class StatusMainScreen: class StatusMainScreen:
def __init__(self): def __init__(self):
verify_screen_is_loaded(MainScreenComponents.STATUS_ICON.value) verify_screen(MainScreenComponents.STATUS_ICON.value)
def joinChatRoom(self, room): def joinChatRoom(self, room):
click_obj_by_name(MainScreenComponents.STATUS_ICON.value) click_obj_by_name(MainScreenComponents.STATUS_ICON.value)

View File

@ -39,7 +39,7 @@ class SignUpComponents(Enum):
class StatusWelcomeScreen: class StatusWelcomeScreen:
def __init__(self): def __init__(self):
verify_screen_is_loaded(AgreementPopUp.OK_GOT_IT_BUTTON.value) verify_screen(AgreementPopUp.OK_GOT_IT_BUTTON.value)
def agree_terms_conditions_and_generate_new_key(self): def agree_terms_conditions_and_generate_new_key(self):
click_obj_by_name(AgreementPopUp.OK_GOT_IT_BUTTON.value) click_obj_by_name(AgreementPopUp.OK_GOT_IT_BUTTON.value)

View File

@ -9,7 +9,7 @@ def step(context):
_welcomeScreen.agree_terms_conditions_and_generate_new_key() _welcomeScreen.agree_terms_conditions_and_generate_new_key()
@When("user inputs username |any| and password |any|") @When("user signs up with username |any| and password |any|")
def step(context, username, password): def step(context, username, password):
_welcomeScreen.input_username_and_password_and_finalize_sign_up(username, password) _welcomeScreen.input_username_and_password_and_finalize_sign_up(username, password)

View File

@ -16,9 +16,9 @@
from common.Common import * from common.Common import *
@Given("the application is restarted") @When("the user restarts the app")
def step(context): def step(context):
currentApplicationContext().detach() waitFor(lambda: currentApplicationContext().detach(), 100)
startApplication("nim_status_client") startApplication("nim_status_client")

View File

@ -10,7 +10,7 @@ Feature: Status Desktop Chat
Background: Background:
Given A first time user lands on the status desktop and generates new key Given A first time user lands on the status desktop and generates new key
When user inputs username tester123 and password TesTEr16843/!@00 When user signs up with username tester123 and password TesTEr16843/!@00
Then the user lands on the signed in app Then the user lands on the signed in app
Scenario: User joins a room and chats Scenario: User joins a room and chats

View File

@ -16,13 +16,11 @@ Feature: Status Desktop login
The following scenarios cover login by using a password. The following scenarios cover login by using a password.
Scenario Outline: User tries to login with a valid password Scenario Outline: User tries to login with a valid password
Given A first time user lands on the status desktop and generates new key Given A first time user lands on the status desktop and generates new key
When user inputs username <account> and password <password> When user signs up with username <account> and password <password>
Given the application is restarted And the user restarts the app
Given A Status Desktop <account> and <password> And the user logs in with password <password>
When the user tries to login with valid credentials Then the user lands on the signed in app
Then the user is able to login to Status Desktop application
Examples: Examples:
| account | password | | account | password |
| Athletic_Prime | TesTEr16843/!@00 | | Athletic_Prime | TesTEr16843/!@00 |
@ -33,10 +31,9 @@ Feature: Status Desktop login
Scenario Outline: User tries to login with an invalid password Scenario Outline: User tries to login with an invalid password
Given A first time user lands on the status desktop and generates new key Given A first time user lands on the status desktop and generates new key
When user inputs username <account> and password <password> When user signs up with username <account> and password <password>
Given the application is restarted And the user restarts the app
Given A Status Desktop <account> and <wrongpassword> And the user logs in with password <wrongpassword>
When the user tries to login with invalid credentials
Then the user is NOT able to login to Status Desktop application Then the user is NOT able to login to Status Desktop application
Examples: Examples:
| account | password | wrongpassword | | account | password | wrongpassword |

View File

@ -16,7 +16,7 @@ Feature: Status Desktop Sign Up
Scenario: User signs up and signs in with password Scenario: User signs up and signs in with password
Given A first time user lands on the status desktop and generates new key Given A first time user lands on the status desktop and generates new key
When user inputs username tester123 and password TesTEr16843/!@00 When user signs up with username tester123 and password TesTEr16843/!@00
Then the user lands on the signed in app Then the user lands on the signed in app