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
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)
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):
result = is_loaded_visible_and_enabled(objName, timeout)
test.verify(result, False)

View File

@ -23,7 +23,7 @@ class ChatComponents(Enum):
class StatusChatScreen:
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):
type(ChatComponents.MESSAGE_INPUT.value, message)

View File

@ -12,6 +12,7 @@ from enum import Enum
from screens.StatusAccountsScreen import StatusAccountsScreen
from drivers.SquishDriver import *
# It defines the identifier for each Login View component:
class SLoginComponents(Enum):
MAIN_VIEW = "loginView_main"
@ -20,12 +21,14 @@ class SLoginComponents(Enum):
CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn"
ERR_MSG_LABEL = "loginView_errMsgLabel"
# It defines expected password placeholder text.
class PswPlaceholderTextType(Enum):
NONE = None
CONNECTING = "Connecting..."
PASSWORD = "Enter password"
# It defines the status login screen behavior and properties.
class StatusLoginScreen():
__is_loaded = False
@ -37,11 +40,13 @@ class StatusLoginScreen():
def is_loaded(self):
return self.__is_loaded
def introduce_password(self, password):
result = False
if click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value) and type(SLoginComponents.PASSWORD_INPUT.value, password):
result = True
return result
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 get_accounts_selector_popup(self):
return StatusAccountsScreen()
def submit_password(self):
return click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)
@ -49,9 +54,6 @@ class StatusLoginScreen():
def open_accounts_selector_popup(self):
return click_obj_by_name(SLoginComponents.CHANGE_ACCOUNT_BTN.value)
def get_accounts_selector_popup(self):
return StatusAccountsScreen()
def get_password_placeholder_text(self):
result = ""
[loaded, obj] = is_loaded(SLoginComponents.PASSWORD_INPUT.value)
@ -83,4 +85,3 @@ class StatusLoginScreen():
def get_current_identicon(self):
raise NotImplementedError("TODO: get_current_identicon method")

View File

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

View File

@ -39,7 +39,7 @@ class SignUpComponents(Enum):
class StatusWelcomeScreen:
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):
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()
@When("user inputs username |any| and password |any|")
@When("user signs up with username |any| and password |any|")
def step(context, username, password):
_welcomeScreen.input_username_and_password_and_finalize_sign_up(username, password)

View File

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

View File

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

View File

@ -16,7 +16,7 @@ Feature: Status Desktop Sign Up
Scenario: User signs up and signs in with password
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