From 0edf28f14d69af5aed29776fe7c924d783ec763d Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Fri, 15 Dec 2023 17:48:20 +0300 Subject: [PATCH] chore: add asserts for change password test --- .../gui/components/change_password_popup.py | 21 ++++++++++++++++-- test/e2e/gui/screens/onboarding.py | 1 - .../test_settings_profile_change_password.py | 22 ++++++++++++++----- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/test/e2e/gui/components/change_password_popup.py b/test/e2e/gui/components/change_password_popup.py index 43c11bb8c8..b2234bbd95 100644 --- a/test/e2e/gui/components/change_password_popup.py +++ b/test/e2e/gui/components/change_password_popup.py @@ -1,5 +1,6 @@ import allure +import driver from gui.components.base_popup import BasePopup from gui.elements.button import Button from gui.elements.text_edit import TextEdit @@ -15,10 +16,26 @@ class ChangePasswordPopup(BasePopup): self._submit_button = Button('change_password_menu_submit_button') self._quit_button = Button('change_password_success_menu_sign_out_quit_button') - @allure.step('Change password and confirm action') + @allure.step('Fill in the form, submit and sign out') def change_password(self, old_pwd: str, new_pwd: str): self._current_password_text_field.text = old_pwd self._new_password_text_field.text = new_pwd self._confirm_password_text_field.text = new_pwd self._submit_button.click() - self._quit_button.wait_until_appears(15000).click() + self.click_sign_out_and_quit_button() + + @allure.step('Wait for Sign out and quit button and click it') + def click_sign_out_and_quit_button(self): + """ + Timeout is set as rough estimation of 15 seconds. What is happening when changing password is + the process of re-hasing DB initiated. Taking into account the user is new , so DB is relatively small + I assume, 15 seconds should be enough to finish re-hashing and show the Sign-out and quit button + This time is not really predictable, especially for huge DBs. We might implement other solution, but since + this wait_until_appears method is barely working, I suggest this solution for now + """ + try: + assert driver.waitFor(lambda: self._quit_button.is_visible, 15000), \ + f'Sign out and quit button is not visible within 15 seconds' + self._quit_button.click() + except Exception as ex: + raise ex diff --git a/test/e2e/gui/screens/onboarding.py b/test/e2e/gui/screens/onboarding.py index 9cdbd9509d..3673b2a77b 100755 --- a/test/e2e/gui/screens/onboarding.py +++ b/test/e2e/gui/screens/onboarding.py @@ -573,7 +573,6 @@ class LoginView(QObject): self._password_text_edit.text = account.password self._arrow_right_button.click() - self.wait_until_hidden() @allure.step('Select user') def select_user_name(self, user_name, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): diff --git a/test/e2e/tests/settings/settings_profile/test_settings_profile_change_password.py b/test/e2e/tests/settings/settings_profile/test_settings_profile_change_password.py index f63ec84909..00e43b913d 100644 --- a/test/e2e/tests/settings/settings_profile/test_settings_profile_change_password.py +++ b/test/e2e/tests/settings/settings_profile/test_settings_profile_change_password.py @@ -1,4 +1,5 @@ import allure +import psutil import pytest from allure_commons._allure import step from . import marks @@ -9,6 +10,7 @@ from gui.main_window import MainWindow pytestmark = marks + @pytest.mark.critical @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703005', 'Change the password and login with new password') @@ -16,17 +18,27 @@ pytestmark = marks @pytest.mark.parametrize('user_account, user_account_changed_password', [pytest.param(constants.user.user_account_one, constants.user.user_account_one_changed_password)]) - def test_change_password_and_login(aut: AUT, main_screen: MainWindow, user_account, user_account_changed_password): - with step('Open profile settings and change password'): - main_screen.left_panel.open_settings().left_panel.open_profile_settings().open_change_password_popup().change_password( + with step('Open profile settings'): + settings_scr = main_screen.left_panel.open_settings().left_panel.open_profile_settings() + + with step('Open change password popup'): + change_psw_pop_up = settings_scr.open_change_password_popup() + + with step('Fill in the change password form and submit'): + change_psw_pop_up.change_password( user_account.password, user_account_changed_password.password) + with step('Verify the application process is not running'): + psutil.Process(aut.pid).wait(timeout=10) + with step('Restart application'): aut.restart() + + with step('Login with new password'): main_screen.authorize_user(user_account_changed_password) with step('Verify that the user logged in correctly'): - user_canvas = main_screen.left_panel.open_online_identifier() - profile_popup = user_canvas.open_profile_popup_from_online_identifier() + online_identifier = main_screen.left_panel.open_online_identifier() + profile_popup = online_identifier.open_profile_popup_from_online_identifier() assert profile_popup.user_name == user_account.name