2023-07-10 15:55:10 +00:00
|
|
|
import logging
|
2023-12-05 13:23:02 +00:00
|
|
|
import time
|
2023-08-29 14:43:00 +00:00
|
|
|
import typing
|
2023-07-10 15:55:10 +00:00
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
import allure
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
import configs
|
|
|
|
import driver
|
2024-10-15 15:31:37 +00:00
|
|
|
from constants import UserAccount, RandomUser, RandomCommunity, CommunityData
|
2023-09-11 18:24:13 +00:00
|
|
|
from gui.components.community.invite_contacts import InviteContactsPopup
|
2024-10-10 10:26:23 +00:00
|
|
|
from gui.components.onboarding.share_usage_data_popup import ShareUsageDataPopup
|
2023-12-28 08:49:05 +00:00
|
|
|
from gui.components.context_menu import ContextMenu
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.components.onboarding.before_started_popup import BeforeStartedPopUp
|
2023-09-22 03:58:45 +00:00
|
|
|
from gui.components.onboarding.beta_consent_popup import BetaConsentPopup
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.components.splash_screen import SplashScreen
|
2023-12-05 13:23:02 +00:00
|
|
|
from gui.components.toast_message import ToastMessage
|
2023-12-13 08:20:56 +00:00
|
|
|
from gui.components.online_identifier import OnlineIdentifier
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.window import Window
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.screens.community import CommunityScreen
|
|
|
|
from gui.screens.community_portal import CommunitiesPortal
|
2023-09-11 18:24:13 +00:00
|
|
|
from gui.screens.messages import MessagesScreen
|
2024-04-24 13:29:14 +00:00
|
|
|
from gui.screens.onboarding import AllowNotificationsView, WelcomeToStatusView, BiometricsView, LoginView, \
|
|
|
|
YourEmojihashAndIdenticonRingView
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.screens.settings import SettingsScreen
|
2023-09-01 11:18:04 +00:00
|
|
|
from gui.screens.wallet import WalletScreen
|
2023-08-29 14:43:00 +00:00
|
|
|
from scripts.tools.image import Image
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-12-01 13:58:22 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-07-10 15:55:10 +00:00
|
|
|
|
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
class LeftPanel(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
2024-02-13 09:04:24 +00:00
|
|
|
super(LeftPanel, self).__init__(names.mainWindow_StatusAppNavBar)
|
2024-07-18 08:44:36 +00:00
|
|
|
self.profile_button = Button(names.mainWindow_ProfileNavBarButton)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._messages_button = Button(names.messages_navbar_StatusNavBarTabButton)
|
|
|
|
self._communities_portal_button = Button(names.communities_Portal_navbar_StatusNavBarTabButton)
|
|
|
|
self._community_template_button = Button(names.statusCommunityMainNavBarListView_CommunityNavBarButton)
|
|
|
|
self._settings_button = Button(names.settings_navbar_StatusNavBarTabButton)
|
|
|
|
self._wallet_button = Button(names.wallet_navbar_StatusNavBarTabButton)
|
|
|
|
self._community_invite_people_context_item = QObject(names.invite_People_StatusMenuItem)
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get communities names')
|
|
|
|
def communities(self) -> typing.List[str]:
|
|
|
|
community_names = []
|
|
|
|
for obj in driver.findAllObjects(self._community_template_button.real_name):
|
|
|
|
community_names.append(obj.name)
|
2023-12-12 15:43:22 +00:00
|
|
|
|
2024-04-08 05:25:17 +00:00
|
|
|
return community_names
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get user badge color')
|
|
|
|
def user_badge_color(self) -> str:
|
2024-07-18 08:44:36 +00:00
|
|
|
return str(self.profile_button.object.badge.color.name)
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
@allure.step('Open messages screen')
|
|
|
|
def open_messages_screen(self) -> MessagesScreen:
|
|
|
|
self._messages_button.click()
|
2024-05-28 15:17:32 +00:00
|
|
|
return MessagesScreen()
|
2023-09-11 18:24:13 +00:00
|
|
|
|
2023-12-13 08:20:56 +00:00
|
|
|
@allure.step('Open online identifier')
|
|
|
|
def open_online_identifier(self, attempts: int = 2) -> OnlineIdentifier:
|
2023-12-12 15:43:22 +00:00
|
|
|
time.sleep(0.5)
|
2024-07-18 08:44:36 +00:00
|
|
|
self.profile_button.click()
|
2023-12-12 15:43:22 +00:00
|
|
|
try:
|
2023-12-13 08:20:56 +00:00
|
|
|
return OnlineIdentifier().wait_until_appears()
|
2023-12-12 15:43:22 +00:00
|
|
|
except Exception as ex:
|
|
|
|
if attempts:
|
2023-12-13 08:20:56 +00:00
|
|
|
self.open_online_identifier(attempts - 1)
|
2023-12-12 15:43:22 +00:00
|
|
|
else:
|
|
|
|
raise ex
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-09-20 11:35:56 +00:00
|
|
|
@allure.step('Set user to online')
|
|
|
|
def set_user_to_online(self):
|
2023-12-13 08:20:56 +00:00
|
|
|
self.open_online_identifier().set_user_state_online()
|
2023-09-20 11:35:56 +00:00
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@allure.step('Verify: User is online')
|
|
|
|
def user_is_online(self) -> bool:
|
|
|
|
return self.user_badge_color == '#4ebc60'
|
|
|
|
|
2023-09-20 11:35:56 +00:00
|
|
|
@allure.step('Set user to offline')
|
|
|
|
def set_user_to_offline(self):
|
2023-12-13 08:20:56 +00:00
|
|
|
self.open_online_identifier().set_user_state_offline()
|
2023-09-20 11:35:56 +00:00
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@allure.step('Verify: User is offline')
|
|
|
|
def user_is_offline(self):
|
|
|
|
return self.user_badge_color == '#7f8990'
|
|
|
|
|
2023-09-20 11:35:56 +00:00
|
|
|
@allure.step('Set user to automatic')
|
|
|
|
def set_user_to_automatic(self):
|
2023-12-13 08:20:56 +00:00
|
|
|
self.open_online_identifier().set_user_automatic_state()
|
2023-09-20 11:35:56 +00:00
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@allure.step('Verify: User is set to automatic')
|
|
|
|
def user_is_set_to_automatic(self):
|
|
|
|
return self.user_badge_color == '#4ebc60'
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Open community portal')
|
2024-04-24 07:49:03 +00:00
|
|
|
def open_communities_portal(self, attempts: int = 2) -> CommunitiesPortal:
|
2023-08-29 14:43:00 +00:00
|
|
|
self._communities_portal_button.click()
|
2024-04-24 07:49:03 +00:00
|
|
|
try:
|
|
|
|
return CommunitiesPortal().wait_until_appears()
|
|
|
|
except Exception as ex:
|
|
|
|
if attempts:
|
|
|
|
self.open_communities_portal(attempts - 1)
|
|
|
|
else:
|
|
|
|
raise ex
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
def _get_community(self, name: str):
|
|
|
|
community_names = []
|
|
|
|
for obj in driver.findAllObjects(self._community_template_button.real_name):
|
|
|
|
community_names.append(str(obj.name))
|
|
|
|
if str(obj.name) == str(name):
|
|
|
|
return obj
|
|
|
|
raise LookupError(f'Community: {name} not found in {community_names}')
|
|
|
|
|
|
|
|
@allure.step('Open community')
|
|
|
|
def select_community(self, name: str) -> CommunityScreen:
|
|
|
|
driver.mouseClick(self._get_community(name))
|
|
|
|
return CommunityScreen().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Get community logo')
|
|
|
|
def get_community_logo(self, name: str) -> Image:
|
|
|
|
return Image(driver.objectMap.realName(self._get_community(name)))
|
|
|
|
|
2023-12-28 08:49:05 +00:00
|
|
|
@allure.step('Open context menu for community')
|
|
|
|
def open_community_context_menu(self, name: str) -> ContextMenu:
|
2024-05-31 10:45:47 +00:00
|
|
|
community = QObject(driver.objectMap.realName(self._get_community(name)))
|
|
|
|
community.right_click()
|
2023-12-28 08:49:05 +00:00
|
|
|
return ContextMenu().wait_until_appears()
|
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
@allure.step('Invite people in community')
|
|
|
|
def invite_people_in_community(self, contacts: typing.List[str], message: str, community_name: str):
|
|
|
|
driver.mouseClick(self._get_community(community_name), driver.Qt.RightButton)
|
|
|
|
self._community_invite_people_context_item.click()
|
|
|
|
InviteContactsPopup().wait_until_appears().invite(contacts, message)
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Open settings')
|
2023-12-13 08:20:56 +00:00
|
|
|
def open_settings(self, attempts: int = 2) -> SettingsScreen:
|
2023-08-29 14:43:00 +00:00
|
|
|
self._settings_button.click()
|
2023-12-13 08:20:56 +00:00
|
|
|
time.sleep(0.5)
|
|
|
|
try:
|
2024-07-19 06:43:44 +00:00
|
|
|
SettingsScreen().left_panel.wait_until_appears()
|
2023-12-13 08:20:56 +00:00
|
|
|
return SettingsScreen()
|
|
|
|
except Exception as ex:
|
|
|
|
if attempts:
|
|
|
|
self.open_settings(attempts - 1)
|
|
|
|
else:
|
|
|
|
raise ex
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-09-01 11:18:04 +00:00
|
|
|
@allure.step('Open Wallet section')
|
2024-05-15 07:00:43 +00:00
|
|
|
def open_wallet(self, attempts: int = 3) -> WalletScreen:
|
2024-10-07 11:45:43 +00:00
|
|
|
# TODO https://github.com/status-im/status-desktop/issues/15345
|
|
|
|
self._wallet_button.click(timeout=30)
|
2023-10-20 17:54:04 +00:00
|
|
|
try:
|
2023-12-11 07:20:29 +00:00
|
|
|
return WalletScreen()
|
|
|
|
except Exception as ex:
|
2023-10-20 17:54:04 +00:00
|
|
|
if attempts:
|
|
|
|
return self.open_wallet(attempts - 1)
|
|
|
|
else:
|
2023-12-11 07:20:29 +00:00
|
|
|
raise ex
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
class MainWindow(Window):
|
2023-07-10 15:55:10 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2024-02-13 09:04:24 +00:00
|
|
|
super(MainWindow, self).__init__(names.statusDesktop_mainWindow)
|
2023-08-04 18:27:03 +00:00
|
|
|
self.left_panel = LeftPanel()
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-11-17 05:53:17 +00:00
|
|
|
def prepare(self) -> 'Window':
|
|
|
|
return super().prepare()
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Sign Up user')
|
2024-10-15 15:31:37 +00:00
|
|
|
def sign_up(self, user_account: UserAccount):
|
2023-08-29 14:43:00 +00:00
|
|
|
BeforeStartedPopUp().get_started()
|
2024-06-14 09:47:39 +00:00
|
|
|
welcome_screen = WelcomeToStatusView().wait_until_appears()
|
|
|
|
profile_view = welcome_screen.get_keys().generate_new_keys()
|
2023-08-29 14:43:00 +00:00
|
|
|
profile_view.set_display_name(user_account.name)
|
2024-04-24 13:29:14 +00:00
|
|
|
create_password_view = profile_view.next()
|
2023-08-29 14:43:00 +00:00
|
|
|
confirm_password_view = create_password_view.create_password(user_account.password)
|
|
|
|
confirm_password_view.confirm_password(user_account.password)
|
2024-06-18 06:53:37 +00:00
|
|
|
if configs.system.get_platform() == "Darwin":
|
2023-09-22 03:58:45 +00:00
|
|
|
BiometricsView().wait_until_appears().prefer_password()
|
2023-08-29 14:43:00 +00:00
|
|
|
SplashScreen().wait_until_appears().wait_until_hidden()
|
2024-04-24 13:29:14 +00:00
|
|
|
YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
2024-06-18 06:53:37 +00:00
|
|
|
if configs.system.get_platform() == "Darwin":
|
2024-04-24 13:29:14 +00:00
|
|
|
AllowNotificationsView().start_using_status()
|
|
|
|
SplashScreen().wait_until_appears().wait_until_hidden()
|
2024-08-07 16:19:18 +00:00
|
|
|
if not configs.system.TEST_MODE and not configs._local.DEV_BUILD:
|
2023-11-16 10:48:17 +00:00
|
|
|
BetaConsentPopup().confirm()
|
2023-08-29 14:43:00 +00:00
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Log in user')
|
|
|
|
def log_in(self, user_account: UserAccount):
|
2024-10-10 10:26:23 +00:00
|
|
|
share_updates_popup = ShareUsageDataPopup()
|
2023-08-29 14:43:00 +00:00
|
|
|
LoginView().log_in(user_account)
|
|
|
|
SplashScreen().wait_until_appears().wait_until_hidden()
|
2024-08-07 16:19:18 +00:00
|
|
|
if not configs.system.TEST_MODE and not configs._local.DEV_BUILD:
|
2023-11-16 10:48:17 +00:00
|
|
|
BetaConsentPopup().confirm()
|
2024-10-10 10:26:23 +00:00
|
|
|
if share_updates_popup.is_visible:
|
|
|
|
share_updates_popup.skip()
|
2023-08-29 14:43:00 +00:00
|
|
|
return self
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
@allure.step('Authorize user')
|
|
|
|
def authorize_user(self, user_account) -> 'MainWindow':
|
|
|
|
assert isinstance(user_account, UserAccount)
|
|
|
|
if LoginView().is_visible:
|
|
|
|
return self.log_in(user_account)
|
|
|
|
else:
|
|
|
|
return self.sign_up(user_account)
|
|
|
|
|
|
|
|
@allure.step('Create community')
|
2024-10-15 15:31:37 +00:00
|
|
|
def create_community(self, community_data: CommunityData) -> CommunityScreen:
|
2023-09-11 18:24:13 +00:00
|
|
|
communities_portal = self.left_panel.open_communities_portal()
|
|
|
|
create_community_form = communities_portal.open_create_community_popup()
|
2024-10-15 15:31:37 +00:00
|
|
|
assert isinstance(community_data, CommunityData)
|
|
|
|
app_screen = create_community_form.create_community(community_data)
|
2023-09-11 18:24:13 +00:00
|
|
|
return app_screen
|
2023-12-05 13:23:02 +00:00
|
|
|
|
|
|
|
@allure.step('Wait for notification and get text')
|
2024-04-24 13:29:14 +00:00
|
|
|
def wait_for_notification(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC) -> list[str]:
|
2023-12-05 13:23:02 +00:00
|
|
|
started_at = time.monotonic()
|
|
|
|
while True:
|
|
|
|
try:
|
2024-03-11 06:15:12 +00:00
|
|
|
return ToastMessage().get_toast_messages()
|
2023-12-05 13:23:02 +00:00
|
|
|
except LookupError as err:
|
|
|
|
LOG.info(err)
|
2024-10-24 15:45:38 +00:00
|
|
|
if time.monotonic() - started_at > timeout_msec:
|
|
|
|
raise LookupError(f'Notifications are not found')
|