Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Chore/test mode: stabilise tests to allow them pass in STATUS_RUNTIME_TEST_MODE = True #378

Merged
merged 7 commits into from
Dec 13, 2023
2 changes: 1 addition & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '1' */
/* STATUS_RUNTIME_TEST_MODE = 'True' */
}

stages {
Expand Down
15 changes: 11 additions & 4 deletions gui/components/delete_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ def __init__(self):
super().__init__()
self._delete_button = Button('delete_StatusButton')

@allure.step("Delete entity")
def delete(self):
self._delete_button.click()
self.wait_until_hidden()
@allure.step("Delete channel")
def delete(self, attempts: int = 2):
try:
self._delete_button.click()
except Exception as ex:
if attempts:
self.delete(attempts-1)
else:
raise ex




class DeleteCategoryPopup(DeletePopup):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
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')
self._view_my_profile_button = Button('userContextMenu_ViewMyProfileAction')
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):
Expand All @@ -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()
Expand All @@ -53,10 +52,17 @@ def set_user_automatic_state(self):
self._automatic_button.click()
self.wait_until_hidden()

@allure.step('Open Profile popup')
def open_profile_popup(self) -> ProfilePopup:
@allure.step('Open Profile popup from online identifier')
def open_profile_popup_from_online_identifier(self, attempts: int =2) -> ProfilePopup:
self._view_my_profile_button.click()
return ProfilePopup().wait_until_appears()
time.sleep(0.5)
try:
return ProfilePopup()
except Exception as ex:
if attempts:
self.open_profile_popup_from_online_identifier(attempts - 1)
else:
raise ex

@allure.step('Verify: User image contains text')
def is_user_image_contains(self, text: str):
Expand Down
14 changes: 10 additions & 4 deletions gui/components/wallet/popup_delete_account_from_settings.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import allure

import configs
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.check_box import CheckBox
from gui.elements.text_label import TextLabel
from gui.screens.settings_wallet import *
from gui.elements.object import QObject


class RemoveAccountConfirmationSettings(QObject):
class RemoveAccountConfirmationSettings(BasePopup):

def __init__(self):
super(RemoveAccountConfirmationSettings, self).__init__('removeConfirmationTextTitle')
super(RemoveAccountConfirmationSettings, self).__init__()
self._remove_confirmation_close_button = Button('removeConfirmationCrossCloseButton')
self._remove_confirmation_title_text = TextLabel('removeConfirmationTextTitle')
self._remove_confirmation_body_text = TextLabel('removeConfirmationTextBody')
self._remove_confirmation_remove_account_button = Button('removeConfirmationRemoveButton')
self._remove_confirmation_agreement_checkbox = CheckBox('removeConfirmationAgreementCheckBox')
self._remove_confirmation_confirm_button = Button('removeConfirmationConfirmButton')

@allure.step('Click Remove account button')
def click_remove_account_button(self):
self._remove_confirmation_remove_account_button.click()
def remove_account_with_confirmation(self):
self._remove_confirmation_agreement_checkbox.set(True)
self._remove_confirmation_confirm_button.click()

39 changes: 29 additions & 10 deletions gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,7 +48,12 @@ def communities(self) -> typing.List[str]:
community_names = []
for obj in driver.findAllObjects(self._community_template_button.real_name):
community_names.append(obj.name)
return community_names

if len(community_names) == 0:
raise LookupError(
'Communities not found')
else:
return community_names

@property
@allure.step('Get user badge color')
Expand All @@ -60,30 +65,37 @@ def open_messages_screen(self) -> MessagesScreen:
self._messages_button.click()
return MessagesScreen().wait_until_appears()

@allure.step('Open user canvas')
def open_user_canvas(self) -> UserCanvas:
@allure.step('Open online identifier')
def open_online_identifier(self, attempts: int = 2) -> OnlineIdentifier:
time.sleep(0.5)
self._profile_button.click()
return UserCanvas().wait_until_appears()
try:
return OnlineIdentifier().wait_until_appears()
except Exception as ex:
if attempts:
self.open_online_identifier(attempts - 1)
else:
raise ex

@allure.step('Set user to online')
def set_user_to_online(self):
self.open_user_canvas().set_user_state_online()
self.open_online_identifier().set_user_state_online()

@allure.step('Verify: User is online')
def user_is_online(self) -> bool:
return self.user_badge_color == '#4ebc60'

@allure.step('Set user to offline')
def set_user_to_offline(self):
self.open_user_canvas().set_user_state_offline()
self.open_online_identifier().set_user_state_offline()

@allure.step('Verify: User is offline')
def user_is_offline(self):
return self.user_badge_color == '#7f8990'

@allure.step('Set user to automatic')
def set_user_to_automatic(self):
self.open_user_canvas().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):
Expand Down Expand Up @@ -118,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:
Expand Down
2 changes: 2 additions & 0 deletions gui/objects_map/component_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
removeConfirmationTextTitle = {"container": statusDesktop_mainWindow_overlay, "objectName": "headerTitle", "type": "StatusBaseText", "visible": True}
removeConfirmationTextBody = {"container": statusDesktop_mainWindow_overlay, "type": "StatusBaseText", "unnamed": 1, "visible": True}
removeConfirmationRemoveButton = {"container": statusDesktop_mainWindow_overlay, "objectName": RegularExpression("confirm*"), "type": "StatusButton"}
removeConfirmationAgreementCheckBox = {"container": statusDesktop_mainWindow_overlay, "objectName": "RemoveAccountPopup-HavePenPaper", "type": "StatusCheckBox"}
removeConfirmationConfirmButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "RemoveAccountPopup-ConfirmButton", "type": "StatusButton"}

# Testnet mode popup
turn_on_testnet_mode_StatusButton = {"container": statusDesktop_mainWindow_overlay, "id": "acceptBtn", "text": "Turn on testnet mode", "type": "StatusButton", "unnamed": 1, "visible": True}
Expand Down
21 changes: 14 additions & 7 deletions gui/screens/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self):
def create_channel(self, name: str, description: str, emoji: str = None):
self.left_panel.open_create_channel_popup().create(name, description, emoji)

@allure.step('Create channel')
@allure.step('Edit channel')
def edit_channel(self, channel, name: str, description: str, emoji: str = None):
self.left_panel.select_channel(channel)
self.tool_bar.open_edit_channel_popup().edit(name, description, emoji)
Expand Down Expand Up @@ -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)
Expand All @@ -218,9 +219,9 @@ def categories_items(self) -> typing.List[CategoryItem]:

@allure.step('Get channel params')
def get_channel_parameters(self, name) -> UserChannel:
for channal in self.channels:
if channal.name == name:
return channal
for channel in self.channels:
if channel.name == name:
return channel
raise LookupError(f'Channel not found in {self.channels}')

@allure.step('Open community settings')
Expand All @@ -243,10 +244,16 @@ def select_channel(self, name: str):
raise LookupError('Channel not found')

@allure.step('Open create category popup')
def open_create_category_popup(self) -> NewCategoryPopup:
def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup:
self._channel_or_category_button.click()
self._create_category_menu_item.click()
return NewCategoryPopup().wait_until_appears()
try:
self._create_category_menu_item.click()
return NewCategoryPopup().wait_until_appears()
except Exception as ex:
if attempts:
self.open_create_category_popup(attempts-1)
else:
raise ex

@allure.step('Open join community popup')
def open_welcome_community_popup(self):
Expand Down
13 changes: 10 additions & 3 deletions gui/screens/community_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import typing

import allure
Expand Down Expand Up @@ -86,10 +87,16 @@ def description(self) -> str:
return self._description_text_label.text

@allure.step('Open edit community view')
def open_edit_community_view(self) -> 'EditCommunityView':
def open_edit_community_view(self, attempts: int = 2) -> 'EditCommunityView':
time.sleep(0.5)
self._edit_button.click()
return EditCommunityView().wait_until_appears()

try:
return EditCommunityView()
except Exception as ex:
if attempts:
self.open_edit_community_view(attempts-1)
else:
raise ex

class EditCommunityView(QObject):

Expand Down
21 changes: 17 additions & 4 deletions gui/screens/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,27 @@ def open_messaging_settings(self) -> 'MessagingSettingsView':
return MessagingSettingsView()

@allure.step('Open communities settings')
def open_communities_settings(self) -> 'CommunitiesSettingsView':
def open_communities_settings(self, attempts: int = 2) -> 'CommunitiesSettingsView':
self._open_settings('12-AppMenuItem')
return CommunitiesSettingsView()
try:
return CommunitiesSettingsView()
except Exception as ex:
if attempts:
self.open_communities_settings(attempts-1)
else:
raise ex

@allure.step('Open wallet settings')
def open_wallet_settings(self) -> WalletSettingsView:
def open_wallet_settings(self, attempts: int = 2) -> WalletSettingsView:
self._open_settings('4-AppMenuItem')
return WalletSettingsView().wait_until_appears()
time.sleep(0.5)
try:
return WalletSettingsView()
except Exception as ex:
if attempts:
self.open_wallet_settings(attempts-1)
else:
raise ex

@allure.step('Open profile settings')
def open_profile_settings(self) -> ProfileSettingsView:
Expand Down
1 change: 1 addition & 0 deletions gui/screens/settings_communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self):
@property
@allure.step('Get communities')
def communities(self) -> typing.List[UserCommunityInfo]:
time.sleep(0.5)
_communities = []
for obj in driver.findAllObjects(self._community_item.real_name):
container = driver.objectMap.realName(obj)
Expand Down
12 changes: 9 additions & 3 deletions gui/screens/settings_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ def open_status_account_in_settings(self):

@allure.step('Get keypair names')
def get_keypairs_names(self):
return [str(getattr(item, 'title', '')) for item in
driver.findAllObjects(self._wallet_settings_keypair_item.real_name)]
keypair_names = []
for item in driver.findAllObjects(self._wallet_settings_keypair_item.real_name):
keypair_names.append(str(getattr(item, 'title', '')))
if len(keypair_names) == 0:
raise LookupError(
'No keypairs found on the wallet settings screen')
else:
return keypair_names

@allure.step('Open account view in wallet settings by name')
def open_account_in_settings(self, name):
Expand Down Expand Up @@ -252,7 +258,7 @@ def click_test_network_tab(self):
self._test_network_tab.click()

@allure.step('Click Revert to default button and redirect to Networks screen')
def click_revert_to_default_and_go_to_networks_main_screen(self, attempts: int=2):
def click_revert_to_default_and_go_to_networks_main_screen(self, attempts: int = 2):
self._network_edit_scroll.vertical_down_to(self._network_revert_to_default)
self._network_revert_to_default.click()
try:
Expand Down
Loading