From 355506d3cf9580ed78eccb20022b552b4f2b34a3 Mon Sep 17 00:00:00 2001 From: Anastasiya Semiankevich Date: Wed, 13 Dec 2023 11:20:56 +0300 Subject: [PATCH] chore: move the TEST MODE back off for now and add some more fixes --- ci/Jenkinsfile | 2 +- .../{user_canvas.py => online_identifier.py} | 15 +++++------ gui/main_window.py | 27 ++++++++++++------- gui/screens/community.py | 1 + gui/screens/settings_wallet.py | 2 +- .../communities/test_communities_channels.py | 4 +-- tests/communities/test_join_community.py | 2 +- tests/messages/test_messaging_group_chat.py | 4 +-- .../test_onboarding_generate_new_keys.py | 2 +- .../onboarding/test_onboarding_import_seed.py | 2 +- .../test_onboarding_negative_scenarios.py | 2 +- tests/onboarding/test_onboarding_syncing.py | 2 +- .../test_online_identifier.py | 4 +-- .../test_messaging_settings_accept_request.py | 2 +- ...essaging_settings_identity_verification.py | 2 +- .../test_messaging_settings_reject_request.py | 3 ++- .../test_settings_profile_change_password.py | 2 +- 17 files changed, 43 insertions(+), 35 deletions(-) rename gui/components/{user_canvas.py => online_identifier.py} (92%) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 6623f952..14d4fc64 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { TESTRAIL_PROJECT_ID = 17 /* Runtime flag to make testing of the app easier. Switched off: unpredictable app behavior under new tests */ - STATUS_RUNTIME_TEST_MODE = 'True' + /* STATUS_RUNTIME_TEST_MODE = 'True' */ } stages { diff --git a/gui/components/user_canvas.py b/gui/components/online_identifier.py similarity index 92% rename from gui/components/user_canvas.py rename to gui/components/online_identifier.py index 977c2b5b..6cb509e8 100644 --- a/gui/components/user_canvas.py +++ b/gui/components/online_identifier.py @@ -11,10 +11,10 @@ from gui.elements.text_label import TextLabel -class UserCanvas(QObject): +class OnlineIdentifier(QObject): def __init__(self): - super(UserCanvas, self).__init__('o_StatusListView') + super(OnlineIdentifier, self).__init__('o_StatusListView') self._always_active_button = Button('userContextmenu_AlwaysActiveButton') self._inactive_button = Button('userContextmenu_InActiveButton') self._automatic_button = Button('userContextmenu_AutomaticButton') @@ -22,6 +22,11 @@ def __init__(self): self._user_name_text_label = TextLabel('userLabel_StyledText') self._profile_image = QObject('o_StatusIdenticonRing') + @allure.step('Wait until appears {0}') + def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + driver.waitFor(lambda: self._view_my_profile_button.is_visible, timeout_msec) + return self + @property @allure.step('Get profile image') def profile_image(self): @@ -32,12 +37,6 @@ def profile_image(self): def user_name(self) -> str: return self._user_name_text_label.text - @allure.step('Wait until appears {0}') - def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): - super(UserCanvas, self).wait_until_appears(timeout_msec) - time.sleep(1) - return self - @allure.step('Set user state online') def set_user_state_online(self): self._always_active_button.click() diff --git a/gui/main_window.py b/gui/main_window.py index 60f5182d..83adb3ad 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -14,7 +14,7 @@ from gui.components.onboarding.beta_consent_popup import BetaConsentPopup from gui.components.splash_screen import SplashScreen from gui.components.toast_message import ToastMessage -from gui.components.user_canvas import UserCanvas +from gui.components.online_identifier import OnlineIdentifier from gui.elements.button import Button from gui.elements.object import QObject from gui.elements.window import Window @@ -65,21 +65,21 @@ def open_messages_screen(self) -> MessagesScreen: self._messages_button.click() return MessagesScreen().wait_until_appears() - @allure.step('Open user online identifier') - def open_user_online_identifier(self, attempts: int = 2) -> UserCanvas: + @allure.step('Open online identifier') + def open_online_identifier(self, attempts: int = 2) -> OnlineIdentifier: time.sleep(0.5) self._profile_button.click() try: - return UserCanvas() + return OnlineIdentifier().wait_until_appears() except Exception as ex: if attempts: - self.open_user_online_identifier(attempts - 1) + self.open_online_identifier(attempts - 1) else: raise ex @allure.step('Set user to online') def set_user_to_online(self): - self.open_user_online_identifier().set_user_state_online() + self.open_online_identifier().set_user_state_online() @allure.step('Verify: User is online') def user_is_online(self) -> bool: @@ -87,7 +87,7 @@ def user_is_online(self) -> bool: @allure.step('Set user to offline') def set_user_to_offline(self): - self.open_user_online_identifier().set_user_state_offline() + self.open_online_identifier().set_user_state_offline() @allure.step('Verify: User is offline') def user_is_offline(self): @@ -95,7 +95,7 @@ def user_is_offline(self): @allure.step('Set user to automatic') def set_user_to_automatic(self): - self.open_user_online_identifier().set_user_automatic_state() + self.open_online_identifier().set_user_automatic_state() @allure.step('Verify: User is set to automatic') def user_is_set_to_automatic(self): @@ -130,9 +130,16 @@ def invite_people_in_community(self, contacts: typing.List[str], message: str, c InviteContactsPopup().wait_until_appears().invite(contacts, message) @allure.step('Open settings') - def open_settings(self) -> SettingsScreen: + def open_settings(self, attempts: int = 2) -> SettingsScreen: self._settings_button.click() - return SettingsScreen().wait_until_appears() + time.sleep(0.5) + try: + return SettingsScreen() + except Exception as ex: + if attempts: + self.open_settings(attempts - 1) + else: + raise ex @allure.step('Open Wallet section') def open_wallet(self, attempts: int = 2) -> WalletScreen: diff --git a/gui/screens/community.py b/gui/screens/community.py index 469c1832..7f98d31f 100644 --- a/gui/screens/community.py +++ b/gui/screens/community.py @@ -201,6 +201,7 @@ def is_join_community_visible(self) -> bool: @property @allure.step('Get channels') def channels(self) -> typing.List[UserChannel]: + time.sleep(0.5) channels_list = [] for obj in driver.findAllObjects(self._channel_list_item.real_name): container = driver.objectMap.realName(obj) diff --git a/gui/screens/settings_wallet.py b/gui/screens/settings_wallet.py index 6fca6ecc..d019a177 100644 --- a/gui/screens/settings_wallet.py +++ b/gui/screens/settings_wallet.py @@ -66,7 +66,7 @@ def get_keypairs_names(self): keypair_names = [] for item in driver.findAllObjects(self._wallet_settings_keypair_item.real_name): keypair_names.append(str(getattr(item, 'title', ''))) - if keypair_names == 0: + if len(keypair_names) == 0: raise LookupError( 'No keypairs found on the wallet settings screen') else: diff --git a/tests/communities/test_communities_channels.py b/tests/communities/test_communities_channels.py index e3d21e9e..bd7d6b9a 100644 --- a/tests/communities/test_communities_channels.py +++ b/tests/communities/test_communities_channels.py @@ -70,5 +70,5 @@ def test_delete_community_channel(main_screen): with step('Delete channel'): community_screen.delete_channel('general') - with step('Verify channel is not exists'): - assert not community_screen.left_panel.channels + with step('Verify channel list is empty'): + assert len(community_screen.left_panel.channels) == 0 diff --git a/tests/communities/test_join_community.py b/tests/communities/test_join_community.py index 76a53827..66e4f63f 100644 --- a/tests/communities/test_join_community.py +++ b/tests/communities/test_join_community.py @@ -35,7 +35,7 @@ def test_join_community_via_owner_invite(multiple_instance, user_data_one, user_ with step(f'User {user_two.name}, get chat key'): aut_two.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() diff --git a/tests/messages/test_messaging_group_chat.py b/tests/messages/test_messaging_group_chat.py index ad832bd4..11a3de9f 100644 --- a/tests/messages/test_messaging_group_chat.py +++ b/tests/messages/test_messaging_group_chat.py @@ -36,7 +36,7 @@ def test_group_chat(multiple_instance, user_data_one, user_data_two, user_data_t with step(f'User {user_two.name}, get chat key'): aut_two.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() @@ -63,7 +63,7 @@ def test_group_chat(multiple_instance, user_data_one, user_data_two, user_data_t with step(f'User {user_three.name}, get chat key'): aut_three.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() diff --git a/tests/onboarding/test_onboarding_generate_new_keys.py b/tests/onboarding/test_onboarding_generate_new_keys.py index ebd3dee2..178ad0dd 100755 --- a/tests/onboarding/test_onboarding_generate_new_keys.py +++ b/tests/onboarding/test_onboarding_generate_new_keys.py @@ -84,7 +84,7 @@ def test_generate_new_keys(main_window, keys_screen, user_name: str, password, u with step('Open User Canvas and verify user info'): - user_canvas = main_window.left_panel.open_user_online_identifier() + user_canvas = main_window.left_panel.open_online_identifier() assert user_canvas.user_name == user_name # TODO: temp removing tesseract usage because it is not stable # if user_image is None: diff --git a/tests/onboarding/test_onboarding_import_seed.py b/tests/onboarding/test_onboarding_import_seed.py index 3450349b..1e0f0f47 100644 --- a/tests/onboarding/test_onboarding_import_seed.py +++ b/tests/onboarding/test_onboarding_import_seed.py @@ -58,7 +58,7 @@ def test_import_seed_phrase(aut: AUT, keys_screen, main_window, user_account, au f"Recovered account should have address {user_account.status_address}, but has {address}" with step('Verify that the user logged in via seed phrase correctly'): - user_canvas = main_window.left_panel.open_user_online_identifier() + user_canvas = main_window.left_panel.open_online_identifier() profile_popup = user_canvas.open_profile_popup_from_online_identifier() assert profile_popup.user_name == user_account.name diff --git a/tests/onboarding/test_onboarding_negative_scenarios.py b/tests/onboarding/test_onboarding_negative_scenarios.py index a62ce481..21121adf 100644 --- a/tests/onboarding/test_onboarding_negative_scenarios.py +++ b/tests/onboarding/test_onboarding_negative_scenarios.py @@ -50,7 +50,7 @@ def test_login_with_wrong_password(aut: AUT, keys_screen, main_window, error: st BetaConsentPopup().confirm() with step('Verify that the user logged in correctly'): - user_canvas = main_window.left_panel.open_user_online_identifier() + user_canvas = main_window.left_panel.open_online_identifier() profile_popup = user_canvas.open_profile_popup_from_online_identifier() assert profile_popup.user_name == user_one.name diff --git a/tests/onboarding/test_onboarding_syncing.py b/tests/onboarding/test_onboarding_syncing.py index 79a3b85e..dbae074a 100644 --- a/tests/onboarding/test_onboarding_syncing.py +++ b/tests/onboarding/test_onboarding_syncing.py @@ -86,7 +86,7 @@ def test_sync_device_during_onboarding(multiple_instance, user_data): BetaConsentPopup().confirm() with step('Verify user details are the same with user in first instance'): - user_canvas = main_window.left_panel.open_user_online_identifier() + user_canvas = main_window.left_panel.open_online_identifier() user_canvas_name = user_canvas.user_name assert user_canvas_name == user.name # TODO: temp removing tesseract usage because it is not stable diff --git a/tests/online_identifier/test_online_identifier.py b/tests/online_identifier/test_online_identifier.py index 2cf81d2d..5d6b4e4c 100644 --- a/tests/online_identifier/test_online_identifier.py +++ b/tests/online_identifier/test_online_identifier.py @@ -16,7 +16,7 @@ @pytest.mark.parametrize('new_name', [pytest.param('NewUserName')]) def test_change_own_display_name(main_screen: MainWindow, user_account, new_name): with step('Open own profile popup and check name of user is correct'): - profile = main_screen.left_panel.open_user_online_identifier() + profile = main_screen.left_panel.open_online_identifier() profile_popup = profile.open_profile_popup_from_online_identifier() assert profile_popup.user_name == user_account.name @@ -24,7 +24,7 @@ def test_change_own_display_name(main_screen: MainWindow, user_account, new_name profile_popup.edit_profile().set_name(new_name) with step('Open own profile popup and check name of user is correct'): - assert main_screen.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier().user_name == new_name + assert main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier().user_name == new_name @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703002', 'Switch state to offline') diff --git a/tests/settings/settings_messaging/test_messaging_settings_accept_request.py b/tests/settings/settings_messaging/test_messaging_settings_accept_request.py index f9f6ebc8..cbc36d7a 100644 --- a/tests/settings/settings_messaging/test_messaging_settings_accept_request.py +++ b/tests/settings/settings_messaging/test_messaging_settings_accept_request.py @@ -31,7 +31,7 @@ def test_messaging_settings_accepting_request(multiple_instance, user_data_one, with step(f'User {user_two.name}, get chat key'): aut_two.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() diff --git a/tests/settings/settings_messaging/test_messaging_settings_identity_verification.py b/tests/settings/settings_messaging/test_messaging_settings_identity_verification.py index 99dbf2dc..2c7bbc8b 100644 --- a/tests/settings/settings_messaging/test_messaging_settings_identity_verification.py +++ b/tests/settings/settings_messaging/test_messaging_settings_identity_verification.py @@ -32,7 +32,7 @@ def test_messaging_settings_identity_verification(multiple_instance, user_data_o with step(f'User {user_two.name}, get chat key'): aut_two.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() diff --git a/tests/settings/settings_messaging/test_messaging_settings_reject_request.py b/tests/settings/settings_messaging/test_messaging_settings_reject_request.py index 3bb89595..cd52bee2 100644 --- a/tests/settings/settings_messaging/test_messaging_settings_reject_request.py +++ b/tests/settings/settings_messaging/test_messaging_settings_reject_request.py @@ -30,7 +30,8 @@ def test_messaging_settings_rejecting_request(multiple_instance, user_data_one, with step(f'User {user_two.name}, get chat key'): aut_two.attach() main_window.prepare() - profile_popup = main_window.left_panel.open_user_online_identifier().open_profile_popup_from_online_identifier() + online_identifier = main_window.left_panel.open_online_identifier() + profile_popup = online_identifier.open_profile_popup_from_online_identifier() chat_key = profile_popup.chat_key profile_popup.close() main_window.hide() diff --git a/tests/settings/settings_profile/test_settings_profile_change_password.py b/tests/settings/settings_profile/test_settings_profile_change_password.py index 68523a25..cc869d92 100644 --- a/tests/settings/settings_profile/test_settings_profile_change_password.py +++ b/tests/settings/settings_profile/test_settings_profile_change_password.py @@ -24,6 +24,6 @@ def test_change_password_and_login(aut: AUT, main_screen: MainWindow, user_accou main_screen.authorize_user(user_account_changed_password) with step('Verify that the user logged in correctly'): - user_canvas = main_screen.left_panel.open_user_online_identifier() + user_canvas = main_screen.left_panel.open_online_identifier() profile_popup = user_canvas.open_profile_popup_from_online_identifier() assert profile_popup.user_name == user_account.name