2023-08-04 18:27:03 +00:00
|
|
|
import allure
|
2023-09-11 18:24:13 +00:00
|
|
|
import pyperclip
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2024-05-22 10:09:58 +00:00
|
|
|
import configs
|
2023-08-04 18:27:03 +00:00
|
|
|
import constants
|
|
|
|
import driver
|
|
|
|
from gui.components.base_popup import BasePopup
|
2024-06-24 08:36:26 +00:00
|
|
|
from gui.components.context_menu import ContextMenu
|
2024-07-18 10:57:24 +00:00
|
|
|
from gui.components.settings.block_user_popup import BlockUserPopup
|
2024-06-24 08:36:26 +00:00
|
|
|
from gui.components.settings.review_contact_request_popup import AcceptRequestFromProfile
|
2024-05-22 10:09:58 +00:00
|
|
|
from gui.components.settings.send_contact_request_popup import SendContactRequestFromProfile
|
2024-07-18 10:57:24 +00:00
|
|
|
from gui.components.settings.unblock_user_popup import UnblockUserPopup
|
2024-07-11 06:16:55 +00:00
|
|
|
from gui.components.share_profile_popup import ShareProfilePopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_label import TextLabel
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-10-13 15:55:44 +00:00
|
|
|
from gui.screens.settings_profile import ProfileSettingsView
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProfilePopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
2024-05-31 14:00:33 +00:00
|
|
|
super().__init__()
|
|
|
|
self._profile_popup_content_item = QObject(names.ProfileContentItem)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._profile_image = QObject(names.ProfileHeader_userImage)
|
|
|
|
self._user_name_label = TextLabel(names.ProfilePopup_displayName)
|
|
|
|
self._edit_profile_button = Button(names.ProfilePopup_editButton)
|
2024-07-11 06:16:55 +00:00
|
|
|
self._share_profile_button = Button(names.share_Profile_StatusFlatButton)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._chat_key_text_label = TextLabel(names.https_status_app_StatusBaseText)
|
|
|
|
self._emoji_hash = QObject(names.profileDialog_userEmojiHash_EmojiHash)
|
|
|
|
self._chat_key_copy_button = Button(names.copy_icon_CopyButton)
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2024-05-31 14:00:33 +00:00
|
|
|
@allure.step('Wait until appears {0}')
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
self._profile_popup_content_item.wait_until_appears(timeout_msec)
|
|
|
|
return self
|
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@property
|
|
|
|
@allure.step('Get profile image')
|
|
|
|
def profile_image(self):
|
|
|
|
return self._profile_image.image
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get image without identicon_ring')
|
|
|
|
def cropped_profile_image(self):
|
|
|
|
# Profile image without identicon_ring
|
|
|
|
self._profile_image.image.update_view()
|
|
|
|
self._profile_image.image.crop(
|
|
|
|
driver.UiTypes.ScreenRectangle(
|
2023-10-09 17:04:29 +00:00
|
|
|
15, 15, self._profile_image.image.width - 30, self._profile_image.image.height - 30
|
2023-08-04 18:27:03 +00:00
|
|
|
))
|
|
|
|
return self._profile_image.image
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get user name')
|
|
|
|
def user_name(self) -> str:
|
|
|
|
return self._user_name_label.text
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get chat key')
|
2023-12-20 15:19:13 +00:00
|
|
|
def get_chat_key_from_profile_link(self) -> str:
|
2023-08-04 18:27:03 +00:00
|
|
|
chat_key = self._chat_key_text_label.text.split('https://status.app/u/')[1].strip()
|
|
|
|
if '#' in chat_key:
|
|
|
|
chat_key = chat_key.split('#')[1]
|
|
|
|
return chat_key
|
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
@property
|
2023-12-20 15:19:13 +00:00
|
|
|
@allure.step('Copy chat key')
|
|
|
|
def copy_chat_key(self) -> str:
|
2023-09-11 18:24:13 +00:00
|
|
|
self._chat_key_copy_button.click()
|
|
|
|
return pyperclip.paste()
|
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@allure.step('Verify: user image contains text')
|
|
|
|
def is_user_image_contains(self, text: str):
|
|
|
|
# To remove all artifacts, the image cropped.
|
|
|
|
crop = driver.UiTypes.ScreenRectangle(
|
|
|
|
15, 15, self._profile_image.image.width - 30, self._profile_image.image.height - 30
|
|
|
|
)
|
|
|
|
return self.profile_image.has_text(text, constants.tesseract.text_on_profile_image, crop=crop)
|
2023-09-20 11:35:56 +00:00
|
|
|
|
|
|
|
@allure.step('Click edit profile button')
|
|
|
|
def edit_profile(self):
|
|
|
|
self._edit_profile_button.click()
|
|
|
|
return ProfileSettingsView()
|
2024-05-22 10:09:58 +00:00
|
|
|
|
2024-07-11 06:16:55 +00:00
|
|
|
@allure.step('Click share profile button')
|
|
|
|
def share_profile(self):
|
|
|
|
self._share_profile_button.click()
|
|
|
|
return ShareProfilePopup()
|
|
|
|
|
2024-05-22 10:09:58 +00:00
|
|
|
@allure.step('Wait until appears {0}')
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
self._emoji_hash.wait_until_appears(timeout_msec)
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
class ProfilePopupFromMembers(ProfilePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(ProfilePopupFromMembers, self).__init__()
|
|
|
|
self._send_request_button = Button(names.send_contact_request_StatusButton)
|
2024-06-24 08:36:26 +00:00
|
|
|
self._review_request_button = Button(names.review_contact_request_StatusButton)
|
|
|
|
self._send_message_button = Button(names.send_Message_StatusButton)
|
2024-07-18 10:57:24 +00:00
|
|
|
self._unblock_button = Button(names.unblock_user_StatusButton)
|
2024-06-24 08:36:26 +00:00
|
|
|
self._menu_button = Button(names.menuButton_StatusFlatButton)
|
2024-07-18 10:57:24 +00:00
|
|
|
self._block_user_menu_item = Button(names.block_user_StatusMenuItem)
|
|
|
|
self._add_nickname_menu_item = Button(names.add_nickname_StatusMenuItem)
|
2024-05-22 10:09:58 +00:00
|
|
|
|
|
|
|
@allure.step('Click send request button')
|
|
|
|
def send_request(self):
|
|
|
|
self._send_request_button.click()
|
|
|
|
return SendContactRequestFromProfile().wait_until_appears()
|
|
|
|
|
2024-06-24 08:36:26 +00:00
|
|
|
@allure.step('Get send request button visibilty state')
|
|
|
|
def is_send_request_button_visible(self):
|
|
|
|
return self._send_request_button.is_visible
|
|
|
|
|
|
|
|
@allure.step('Click review contact request button')
|
|
|
|
def review_contact_request(self):
|
2024-10-24 15:45:38 +00:00
|
|
|
self._review_request_button.wait_until_appears(15000)
|
2024-06-24 08:36:26 +00:00
|
|
|
self._review_request_button.click()
|
|
|
|
return AcceptRequestFromProfile().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Get send message button visibility state')
|
|
|
|
def is_send_message_button_visible(self):
|
|
|
|
return self._send_message_button.is_visible
|
|
|
|
|
|
|
|
@allure.step('Click menu button')
|
|
|
|
def click_menu_button(self):
|
|
|
|
self._menu_button.click()
|
|
|
|
|
|
|
|
@allure.step('Choose option from context menu')
|
|
|
|
def choose_context_menu_option(self, value: str):
|
|
|
|
self.click_menu_button()
|
|
|
|
ContextMenu().select(value)
|
2024-07-18 10:57:24 +00:00
|
|
|
|
|
|
|
@allure.step('Block user from menu')
|
|
|
|
def block_user(self):
|
|
|
|
self.click_menu_button()
|
|
|
|
self._block_user_menu_item.click()
|
|
|
|
return BlockUserPopup().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Get unblock button visibility state')
|
|
|
|
def is_unblock_button_visible(self):
|
|
|
|
return self._unblock_button.is_visible
|
|
|
|
|
|
|
|
@allure.step('Unblock user from menu')
|
|
|
|
def unblock_user(self):
|
|
|
|
self._unblock_button.click()
|
|
|
|
return UnblockUserPopup().wait_until_appears()
|