From 46d47e3746efd75fee62ff38f4ffd5450453e1b4 Mon Sep 17 00:00:00 2001 From: femi Date: Fri, 17 Jun 2022 10:17:02 +0100 Subject: [PATCH] feat(@DesktopApp): Refactor Login Steps https://github.com/status-im/status-desktop/issues/6101 Refactor Login Steps --- test/ui-test/src/common/Common.py | 2 +- .../src/drivers/SquishDriverVerification.py | 9 +--- .../src/screens/StatusAccountsScreen.py | 20 ++++---- test/ui-test/src/screens/StatusLoginScreen.py | 9 ++-- .../suite_status/shared/steps/loginSteps.py | 51 +------------------ 5 files changed, 19 insertions(+), 72 deletions(-) diff --git a/test/ui-test/src/common/Common.py b/test/ui-test/src/common/Common.py index 4c435f5349..cc34a6fcd1 100644 --- a/test/ui-test/src/common/Common.py +++ b/test/ui-test/src/common/Common.py @@ -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) diff --git a/test/ui-test/src/drivers/SquishDriverVerification.py b/test/ui-test/src/drivers/SquishDriverVerification.py index 83635fa777..a6d9168b7a 100644 --- a/test/ui-test/src/drivers/SquishDriverVerification.py +++ b/test/ui-test/src/drivers/SquishDriverVerification.py @@ -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) diff --git a/test/ui-test/src/screens/StatusAccountsScreen.py b/test/ui-test/src/screens/StatusAccountsScreen.py index 152c3d3b3f..47b875dfb9 100755 --- a/test/ui-test/src/screens/StatusAccountsScreen.py +++ b/test/ui-test/src/screens/StatusAccountsScreen.py @@ -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 diff --git a/test/ui-test/src/screens/StatusLoginScreen.py b/test/ui-test/src/screens/StatusLoginScreen.py index dcc2b903ec..c6665f0f63 100755 --- a/test/ui-test/src/screens/StatusLoginScreen.py +++ b/test/ui-test/src/screens/StatusLoginScreen.py @@ -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() diff --git a/test/ui-test/testSuites/suite_status/shared/steps/loginSteps.py b/test/ui-test/testSuites/suite_status/shared/steps/loginSteps.py index ec15f72985..7032509f04 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/loginSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/loginSteps.py @@ -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()