2023-09-11 18:24:13 +00:00
|
|
|
import typing
|
|
|
|
|
|
|
|
import allure
|
2024-05-31 10:45:47 +00:00
|
|
|
import pyperclip
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
import configs.timeouts
|
|
|
|
import driver
|
|
|
|
from gui.components.base_popup import BasePopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
2024-11-05 08:44:18 +00:00
|
|
|
from gui.elements.check_box import CheckBox
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_edit import TextEdit
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InviteContactsPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._member_item = QObject(names.o_StatusMemberListItem)
|
2024-11-05 08:44:18 +00:00
|
|
|
self.member_checkbox = CheckBox(names.memberListCheckbox)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._next_button = Button(names.next_StatusButton)
|
|
|
|
self._message_text_edit = TextEdit(names.communityProfilePopupInviteMessagePanel_MessageInput_TextEdit)
|
|
|
|
self._invited_member_item = QObject(names.o_StatusMemberListItem_2)
|
|
|
|
self._send_button = Button(names.send_1_invite_StatusButton)
|
2024-05-31 10:45:47 +00:00
|
|
|
self._copy_button = Button(names.copy_icon_StatusIcon)
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get contacts')
|
|
|
|
def contacts(self) -> typing.List[str]:
|
2024-09-16 15:32:49 +00:00
|
|
|
return [str(user.userName) for user in driver.findAllObjects(self._member_item.real_name)]
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Invite contacts')
|
|
|
|
def invited_contacts(self) -> typing.List[str]:
|
2024-09-16 15:32:49 +00:00
|
|
|
return [str(user.userName) for user in driver.findAllObjects(self._invited_member_item.real_name)]
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
def invite(self, contacts: typing.List[str], message: str):
|
|
|
|
for contact in contacts:
|
|
|
|
assert driver.waitFor(lambda: contact in self.contacts, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), \
|
|
|
|
f'Contact: {contact} not found in {self.contacts}'
|
|
|
|
|
|
|
|
selected = []
|
2024-11-05 08:44:18 +00:00
|
|
|
for member in driver.findAllObjects(self.member_checkbox.real_name):
|
2024-11-06 18:49:46 +00:00
|
|
|
if str(getattr(member, 'objectName', '')).split('contactCheckbox-')[1] in contacts:
|
2024-11-05 08:44:18 +00:00
|
|
|
CheckBox(member).set(True)
|
|
|
|
assert member.checkState != 0, f"Member item checkbox is not checked"
|
2024-11-06 18:49:46 +00:00
|
|
|
selected.append(str(getattr(member, 'objectName', '')).split('contactCheckbox-')[1])
|
2023-09-11 18:24:13 +00:00
|
|
|
|
2024-11-05 08:44:18 +00:00
|
|
|
assert set(contacts) == set(selected), f'Selected contacts: {selected}, expected: {contacts}'
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
self._next_button.click()
|
|
|
|
self._message_text_edit.text = message
|
|
|
|
|
|
|
|
for contact in contacts:
|
|
|
|
assert driver.waitFor(lambda: contact in self.invited_contacts, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), \
|
|
|
|
f'Contact: {contact} not found in {self.invited_contacts}'
|
|
|
|
|
|
|
|
self._send_button.click()
|
2024-05-31 10:45:47 +00:00
|
|
|
|
|
|
|
@allure.step('Copy community link')
|
|
|
|
def copy_community_link(self):
|
|
|
|
self._copy_button.click()
|
|
|
|
return str(pyperclip.paste())
|