Skip to content

Commit

Permalink
test(suite_settings): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Druzhinin committed May 3, 2023
1 parent d7d58b4 commit 7abe164
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 98 deletions.
1 change: 1 addition & 0 deletions test/ui-test/src/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import squish
3 changes: 3 additions & 0 deletions test/ui-test/src/configs/squish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

UI_LOAD_TIMEOUT_MSEC = 5000
APP_LOAD_TIMEOUT_MSEC = 60000
4 changes: 2 additions & 2 deletions test/ui-test/src/drivers/SquishDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ def sleep_test(seconds: float):
squish.snooze(seconds)


def wait_for(py_condition_to_check: str, timeout_msec: int = 500):
squish.waitFor(py_condition_to_check, timeout_msec)
def wait_for(py_condition_to_check: str, timeout_msec: int = 500) -> bool:
return squish.waitFor(lambda: py_condition_to_check, timeout_msec)


def wait_until_hidden(object_name: str, timeout_msec: int = _MAX_WAIT_OBJ_TIMEOUT) -> bool:
Expand Down
17 changes: 11 additions & 6 deletions test/ui-test/src/drivers/elements/base_element.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing

import configs
import names
import object
import squish
Expand All @@ -8,7 +9,11 @@
class BaseElement:

def __init__(self, object_name):
self.symbolic_name = object_name
self.object_name = getattr(names, object_name)

def __str__(self):
return f'{type(self).__qualname__}({self.symbolic_name})'

@property
def object(self):
Expand Down Expand Up @@ -42,8 +47,8 @@ def is_selected(self) -> bool:
@property
def is_visible(self) -> bool:
try:
return squish.waitForObject(self.object_name, 500).visible
except LookupError:
return squish.waitForObject(self.object_name, 0).visible
except (AttributeError, LookupError, RuntimeError):
return False

def click(
Expand All @@ -59,9 +64,9 @@ def click(
button or squish.MouseButton.LeftButton
)

def wait_utill_appears(self, timeout_sec: int = 5):
assert squish.waitFor(lambda: self.is_visible, timeout_sec * 1000), 'Object is not visible'
def wait_until_appears(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC):
assert squish.waitFor(lambda: self.is_visible, timeout_msec), f'Object {self} is not visible'
return self

def wait_utill_hidden(self, timeout_sec: int = 5):
assert squish.waitFor(lambda: not self.is_visible, timeout_sec * 1000), 'Object is not hidden'
def wait_until_hidden(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC):
assert squish.waitFor(lambda: not self.is_visible, timeout_msec), f'Object {self} is not hidden'
1 change: 1 addition & 0 deletions test/ui-test/src/drivers/elements/text_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def text(self, value: str):
assert squish.waitFor(lambda: self.text == value)

def type_text(self, value: str):
self.click()
squish.type(self.object, value)
assert squish.waitFor(lambda: self.text == value), \
f'Type text failed, value in field: "{self.text}", expected: {value}'
Expand Down
40 changes: 26 additions & 14 deletions test/ui-test/src/screens/SettingsScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,27 @@
from .components.social_links_popup import SocialLinksPopup


class SettingsScreenComponents(Enum):
SAVE_BUTTON: str = "settingsSave_StatusButton"
class SignOutPopup(BaseElement):

def __init__(self):
super(SignOutPopup, self).__init__('statusDesktop_mainWindow_overlay')
self._sign_out_quit_button = Button('signOutConfirmation_StatusButton')

def sign_out_and_quit(self):
self._sign_out_quit_button.click()


class MenuPanel(BaseElement):

def __init__(self):
super(MenuPanel, self).__init__('mainWindow_LeftTabView')
self._scroll = Scroll('LeftTabView_ScrollView')
self._back_up_seed_phrase_item = Button('sign_out_Quit_StatusNavigationListItem')

def sign_out_and_quit(self):
self._scroll.vertical_scroll_to(self._back_up_seed_phrase_item)
self._back_up_seed_phrase_item.click()
SignOutPopup().wait_until_appears().sign_out_and_quit()


class SidebarComponents(Enum):
Expand Down Expand Up @@ -94,10 +113,6 @@ class WalletSettingsScreen(Enum):
BACKUP_SEED_PHRASE_BUTTON: str = "settings_Wallet_MainView_BackupSeedPhrase"


class ConfirmationDialog(Enum):
SIGN_OUT_CONFIRMATION: str = "signOutConfirmation_StatusButton"


class CommunitiesSettingsScreen(Enum):
LIST_PANEL: str = "settings_Communities_CommunitiesListPanel"
LEAVE_COMMUNITY_BUTTONS: str = "settings_Communities_MainView_LeaveCommunityButtons"
Expand All @@ -124,6 +139,7 @@ class SettingsScreen:

def __init__(self):
verify_screen(SidebarComponents.ADVANCED_OPTION.value)
self.menu = MenuPanel()
self._profile_view = ProfileSettingsView()
self._profile_button = Button('profile_StatusNavigationListItem')

Expand Down Expand Up @@ -233,11 +249,6 @@ def _find_account_index(self, account_name: str) -> int:
return index
return -1

def sign_out_and_quit_the_app(self, pid: int):
SettingsScreen.__pid = pid
click_obj_by_name(SidebarComponents.SIGN_OUT_AND_QUIT_OPTION.value)
click_obj_by_name(ConfirmationDialog.SIGN_OUT_CONFIRMATION.value)

def verify_the_app_is_closed(self):
verify_the_app_is_closed(SettingsScreen.__pid)

Expand Down Expand Up @@ -383,9 +394,9 @@ class ProfileSettingsView(BaseElement):

def __init__(self):
super(ProfileSettingsView, self).__init__('mainWindow_MyProfileView')
self._scroll_view = Scroll('settingsContentBase_ScrollView')
self._display_name_text_field = TextEdit('displayName_TextEdit')
self._bio_text_field = TextEdit('bio_TextEdit')
self._scroll_view = Scroll('settingsContentBase_ScrollView')
self._add_more_links_label = TextLabel('addMoreSocialLinks')
self._save_button = Button('settingsSave_StatusButton')
self._links_list = BaseElement('linksView')
Expand Down Expand Up @@ -447,9 +458,10 @@ def save_changes(self):
def open_social_links_popup(self):
self._scroll_view.vertical_scroll_to(self._add_more_links_label)
self._add_more_links_label.click()
return SocialLinksPopup().wait_utill_appears()
return SocialLinksPopup().wait_until_appears()

def verify_display_name(self, display_name: str):
self._scroll_view.vertical_scroll_to(self._display_name_text_field)
compare_text(display_name, self.display_name)

def verify_bio(self, bio: str):
Expand Down Expand Up @@ -484,4 +496,4 @@ def verify_social_no_links(self):
def open_change_password_popup(self):
self._scroll_view.vertical_scroll_to(self._change_password_button)
self._change_password_button.click()
return ChangePasswordPopup().wait_utill_appears()
return ChangePasswordPopup().wait_until_appears()
18 changes: 8 additions & 10 deletions test/ui-test/src/screens/StatusLoginScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
# *****************************************************************************/

from enum import Enum
from screens.StatusAccountsScreen import StatusAccountsScreen

from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from screens.StatusAccountsScreen import StatusAccountsScreen

from .components.splash_screen import SplashScreen


# It defines the identifier for each Login View component:
class SLoginComponents(Enum):
MAIN_VIEW = "loginView_main"
PASSWORD_INPUT = "loginView_passwordInput"
SUBMIT_BTN = "loginView_submitBtn"
CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn"
CURRENT_USERNAME_LABEL = "loginView_currentUserNameLabel"
Expand All @@ -38,10 +40,11 @@ class StatusLoginScreen():

def __init__(self):
verify_screen(SLoginComponents.MAIN_VIEW.value)
self._password_text_edit = TextEdit('loginView_passwordInput')

def login(self, account, password):
self.select_account(account)
self.enter_password(password)
self.enter_password(password)

def select_account(self, account):
if self.is_account_selected(account):
Expand All @@ -55,8 +58,7 @@ def is_account_selected(self, account):
return obj.text == account

def enter_password(self, password):
click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)
type_text(SLoginComponents.PASSWORD_INPUT.value, password)
self._password_text_edit.text = password
click_obj_by_name(SLoginComponents.SUBMIT_BTN.value)

def verify_error_message_is_displayed(self):
Expand All @@ -72,11 +74,7 @@ def open_accounts_selector_popup(self):
return click_obj_by_name(SLoginComponents.CHANGE_ACCOUNT_BTN.value)

def get_password_placeholder_text(self):
result = ""
[loaded, obj] = is_loaded(SLoginComponents.PASSWORD_INPUT.value)
if loaded:
result = obj.placeholderText
return result
return self._password_text_edit.object.placeholderText

def get_error_message_text(self):
result = ""
Expand Down
74 changes: 45 additions & 29 deletions test/ui-test/src/screens/StatusMainScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from utils.ObjectAccess import *
import configs

from .components.splash_screen import SplashScreen
from .components.user_canvas import UserCanvas


class MainScreenComponents(Enum):
Expand All @@ -28,52 +32,72 @@ class MainScreenComponents(Enum):
START_CHAT_BTN = "mainWindow_startChat"
CHAT_LIST = "chatList"
COMMUNITY_NAVBAR_BUTTONS = "navBarListView_All_Community_Buttons"
PROFILE_SETTINGS_VIEW = "mainWindow_ProfileSettingsView"
PROFILE_NAVBAR_BUTTON = "mainWindow_ProfileNavBarButton"
USERSTATUSMENU_ALWAYS_ACTIVE_ACTION = "userContextmenu_AlwaysActiveButton"
USERSTATUSMENU_INACTIVE_ACTION = "userContextmenu_InActiveButton"
USERSTATUSMENU_AUTOMATIC_ACTION = "userContextmenu_AutomaticButton"
USERSTATUSMENU_OPEN_PROFILE_POPUP = "userContextMenu_ViewMyProfileAction"
SPLASH_SCREEN = "splashScreen"
PROFILE_SETTINGS_VIEW = "mainWindow_ProfileSettingsView"
TOOLBAR_BACK_BUTTON = "main_toolBar_back_button"
LEAVE_CHAT_MENUITEM = "leaveChatMenuItem"
CONTACTS_COLUMN_MESSAGES_HEADLINE = "mainWindow_ContactsColumn_Messages_Headline"
SECURE_YOUR_SEED_PHRASE_BANNER = "mainWindow_secureYourSeedPhraseBanner_ModuleWarning"


class ProfilePopup(Enum):
USER_IMAGE = "ProfileHeader_userImage"
DISPLAY_NAME = "ProfilePopup_displayName"
EDIT_PROFILE_BUTTON = "ProfilePopup_editButton"


class ChatNamePopUp(Enum):
CHAT_NAME_TEXT = "chat_name_PlaceholderText"
START_CHAT_BTN = "startChat_Btn"


class SharedPopup(Enum):
POPUP_CONTENT: str = "sharedPopup_Popup_Content"
PASSWORD_INPUT: str = "sharedPopup_Password_Input"
PRIMARY_BUTTON: str = "sharedPopup_Primary_Button"


def authenticate_popup_enter_password(password):
wait_for_object_and_type(SharedPopup.PASSWORD_INPUT.value, password)
click_obj_by_name(SharedPopup.PRIMARY_BUTTON.value)


class NavigationPanel(BaseElement):

def __init__(self):
super(NavigationPanel, self).__init__('mainWindow_StatusAppNavBar')
self._profile_button = Button('mainWindow_ProfileNavBarButton')

@property
def user_badge_color(self) -> str:
return str(self._profile_button.object.badge.color.name)

def open_user_canvas(self) -> UserCanvas:
self._profile_button.click()
return UserCanvas().wait_until_appears()

def user_is_online(self) -> bool:
return self.user_badge_color == '#4ebc60'

def user_is_offline(self):
return self.user_badge_color == '#7f8990'

def user_is_set_to_automatic(self):
return self.user_badge_color == '#4ebc60'


class StatusMainScreen:

def __init__(self):
verify_screen(MainScreenComponents.CONTACTS_COLUMN_MESSAGES_HEADLINE.value)
self.navigation_panel = NavigationPanel()

# Main screen is ready to interact with it (Splash screen animation not present)
def is_ready(self):
self.wait_for_splash_animation_ends()
verify(is_displayed(MainScreenComponents.CONTACTS_COLUMN_MESSAGES_HEADLINE.value, 15000), "Verifying if the Messages headline is displayed")

def wait_for_splash_animation_ends(self, timeoutMSec: int = 10000):
do_until_validation_with_timeout(
do_fn = lambda: time.sleep(0.5),
validation_fn = lambda: not is_loaded_visible_and_enabled(MainScreenComponents.SPLASH_SCREEN.value, 1000)[0],
message = "Splash screen animation has ended",
timeout_ms = timeoutMSec)
def wait_for_splash_animation_ends(self, timeoutMSec: int = configs.squish.APP_LOAD_TIMEOUT_MSEC):
SplashScreen().wait_until_appears().wait_until_hidden(timeoutMSec)

def open_chat_section(self):
click_obj_by_name(MainScreenComponents.CHAT_NAVBAR_ICON.value)
Expand Down Expand Up @@ -125,32 +149,25 @@ def verify_communities_count(self, expected_count: int):
verify_equals(len(objects), int(expected_count))

def user_is_online(self):
profileButton = squish.waitForObject(getattr(names, MainScreenComponents.PROFILE_NAVBAR_BUTTON.value))
verify_equal(profileButton.badge.color.name, "#4ebc60", "The user is not online by default")
verify_equal(wait_for(self.navigation_panel.user_is_online(), 10000), True, "The user is not online")

def user_is_offline(self):
profileButton = squish.waitForObject(getattr(names, MainScreenComponents.PROFILE_NAVBAR_BUTTON.value))
verify_equal(profileButton.badge.color.name, "#7f8990", "The user is not offline")
verify_equal(wait_for(self.navigation_panel.user_is_offline(), 10000), True, "The user is not offline")

def user_is_set_to_automatic(self):
profileButton = squish.waitForObject(getattr(names, MainScreenComponents.PROFILE_NAVBAR_BUTTON.value))
verify_equal(profileButton.badge.color.name, "#4ebc60", "The user is not online by default")
verify_equal(wait_for(self.navigation_panel.user_is_online(), 10000), True, "The user is not autoset")

def set_user_state_offline(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(MainScreenComponents.USERSTATUSMENU_INACTIVE_ACTION.value)
self.navigation_panel.open_user_canvas().set_user_state_offline()

def set_user_state_online(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(MainScreenComponents.USERSTATUSMENU_ALWAYS_ACTIVE_ACTION.value)
self.navigation_panel.open_user_canvas().set_user_state_online()

def set_user_state_to_automatic(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(MainScreenComponents.USERSTATUSMENU_AUTOMATIC_ACTION.value)
self.navigation_panel.open_user_canvas().set_user_automatic_state()

def open_own_profile_popup(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(MainScreenComponents.USERSTATUSMENU_OPEN_PROFILE_POPUP.value)
self.navigation_panel.open_user_canvas().open_profile_popup()

def verify_profile_popup_display_name(self, display_name: str):
verify_text_matching(ProfilePopup.DISPLAY_NAME.value, display_name)
Expand Down Expand Up @@ -178,8 +195,7 @@ def profile_image_is_updated(self):
image_present("loginUserName", True, 95, 75, 100, True, profilePopupImage)

def profile_modal_image_is_updated(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(MainScreenComponents.USERSTATUSMENU_OPEN_PROFILE_POPUP.value)
self.navigation_panel.open_user_canvas().open_profile_popup()
image_present("profiletestimage", True, 97, 95, 100, True)

def profile_settings_image_is_updated(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def change_password(self, old_pwd: str, new_pwd: str):
self._new_password_text_field.text = new_pwd
self._confirm_password_text_field.text = new_pwd
self._submit_button.click()
self._quit_button.click()
self._quit_button.wait_until_appears(15000).click()
2 changes: 1 addition & 1 deletion test/ui-test/src/screens/components/social_links_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def add_link(self, network: str, links: typing.List[str]):
for occurrence, link in enumerate(links):
self._get_text_field(occurrence).text = link
self._add_button.click()
self.wait_utill_hidden()
self.wait_until_hidden()
7 changes: 7 additions & 0 deletions test/ui-test/src/screens/components/splash_screen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from drivers.SquishDriver import *


class SplashScreen(BaseElement):

def __init__(self):
super(SplashScreen, self).__init__('splashScreen')
Loading

0 comments on commit 7abe164

Please # to comment.