2023-12-06 12:00:09 +00:00
|
|
|
import time
|
2023-09-04 18:36:48 +00:00
|
|
|
import typing
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
import allure
|
2023-09-04 18:36:48 +00:00
|
|
|
from allure_commons._allure import step
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
import configs
|
2023-09-04 18:36:48 +00:00
|
|
|
import driver
|
|
|
|
from constants import UserChannel
|
2023-12-06 12:00:09 +00:00
|
|
|
from driver.objects_access import walk_children
|
|
|
|
from gui.components.community.community_category_popup import NewCategoryPopup
|
2023-09-04 18:36:48 +00:00
|
|
|
from gui.components.community.community_channel_popups import EditChannelPopup, NewChannelPopup
|
2023-09-11 18:24:13 +00:00
|
|
|
from gui.components.community.welcome_community import WelcomeCommunityPopup
|
2023-12-06 12:00:09 +00:00
|
|
|
from gui.components.delete_popup import DeletePopup, DeleteCategoryPopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.list import List
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_label import TextLabel
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.screens.community_settings import CommunitySettingsScreen
|
2023-09-04 18:36:48 +00:00
|
|
|
from scripts.tools import image
|
2023-08-29 14:43:00 +00:00
|
|
|
from scripts.tools.image import Image
|
|
|
|
|
|
|
|
|
|
|
|
class CommunityScreen(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('mainWindow_communityLoader_Loader')
|
|
|
|
self.left_panel = LeftPanel()
|
2023-09-04 18:36:48 +00:00
|
|
|
self.tool_bar = ToolBar()
|
|
|
|
self.chat = Chat()
|
2023-09-11 18:24:13 +00:00
|
|
|
self.right_panel = Members()
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@allure.step('Create channel')
|
|
|
|
def create_channel(self, name: str, description: str, emoji: str = None):
|
|
|
|
self.left_panel.open_create_channel_popup().create(name, description, emoji)
|
|
|
|
|
2023-12-12 14:05:33 +00:00
|
|
|
@allure.step('Edit channel')
|
2023-09-04 18:36:48 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
@allure.step('Delete channel')
|
|
|
|
def delete_channel(self, name: str):
|
|
|
|
self.left_panel.select_channel(name)
|
|
|
|
self.tool_bar.open_delete_channel_popup().delete()
|
|
|
|
|
|
|
|
@allure.step('Verify channel')
|
|
|
|
def verify_channel(
|
2023-12-08 07:20:15 +00:00
|
|
|
self, name: str, description: str, emoji, color: str):
|
2023-09-04 18:36:48 +00:00
|
|
|
with step('Channel is correct in channels list'):
|
|
|
|
channel = self.left_panel.get_channel_parameters(name)
|
|
|
|
assert channel.name == name
|
|
|
|
assert channel.selected
|
|
|
|
|
|
|
|
with step('Channel is correct in community toolbar'):
|
|
|
|
assert self.tool_bar.channel_name == name
|
|
|
|
assert self.tool_bar.channel_description == description
|
2023-12-08 07:20:15 +00:00
|
|
|
if emoji is not None:
|
|
|
|
assert self.tool_bar.channel_emoji == emoji
|
|
|
|
assert self.tool_bar.channel_color == color
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
with step('Verify channel in chat'):
|
|
|
|
assert self.chat.channel_name == name
|
2023-12-08 07:20:15 +00:00
|
|
|
if emoji is not None:
|
|
|
|
assert self.chat.channel_emoji == emoji
|
|
|
|
assert self.chat.channel_color == color
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
@allure.step('Create category')
|
|
|
|
def create_category(self, name: str, general_checkbox: bool):
|
|
|
|
self.left_panel.open_create_category_popup().create(name, general_checkbox)
|
|
|
|
|
|
|
|
@allure.step('Delete category from the list')
|
|
|
|
def delete_category(self):
|
|
|
|
self.left_panel.open_more_options()
|
|
|
|
self.left_panel.open_delete_category_popup().delete()
|
|
|
|
|
|
|
|
@allure.step('Verify category in the list')
|
|
|
|
def verify_category(self, category_name: str):
|
|
|
|
category = self.left_panel.find_category_in_list(category_name)
|
|
|
|
assert category.category_name == category_name
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
class ToolBar(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('mainWindow_statusToolBar_StatusToolBar')
|
|
|
|
self._more_options_button = Button('statusToolBar_chatToolbarMoreOptionsButton')
|
|
|
|
self._options_list = List('o_StatusListView')
|
2023-09-04 18:36:48 +00:00
|
|
|
self._edit_channel_context_item = QObject('edit_Channel_StatusMenuItem')
|
|
|
|
self._channel_icon = QObject('statusToolBar_statusSmartIdenticonLetter_StatusLetterIdenticon')
|
|
|
|
self._channel_name = TextLabel('statusToolBar_statusChatInfoButtonNameText_TruncatedTextWithTooltip')
|
|
|
|
self._channel_description = TextLabel('statusToolBar_TruncatedTextWithTooltip')
|
|
|
|
self._delete_channel_context_item = QObject('delete_Channel_StatusMenuItem')
|
2023-12-08 07:20:15 +00:00
|
|
|
self._channel_header = QObject('statusToolBar_chatInfoBtnInHeader_StatusChatInfoButton')
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel emoji')
|
|
|
|
def channel_emoji(self):
|
|
|
|
return self._channel_header.object.asset.emoji
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@property
|
2023-12-08 07:20:15 +00:00
|
|
|
@allure.step('Get channel color')
|
|
|
|
def channel_color(self) -> str:
|
|
|
|
return str(self._channel_header.object.asset.color.name).lower()
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel name')
|
|
|
|
def channel_name(self) -> str:
|
|
|
|
return self._channel_name.text
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel description')
|
|
|
|
def channel_description(self) -> str:
|
|
|
|
return self._channel_description.text
|
|
|
|
|
|
|
|
@allure.step('Open edit channel popup')
|
|
|
|
def open_edit_channel_popup(self):
|
|
|
|
self._more_options_button.click()
|
|
|
|
self._edit_channel_context_item.click()
|
|
|
|
return EditChannelPopup().wait_until_appears()
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-09-04 18:36:48 +00:00
|
|
|
@allure.step('Open delete channel popup')
|
|
|
|
def open_delete_channel_popup(self):
|
2023-08-29 14:43:00 +00:00
|
|
|
self._more_options_button.click()
|
2023-09-04 18:36:48 +00:00
|
|
|
self._delete_channel_context_item.click()
|
|
|
|
return DeletePopup().wait_until_appears()
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
class CategoryItem:
|
|
|
|
|
|
|
|
def __init__(self, obj):
|
|
|
|
self.object = obj
|
|
|
|
self.category_name: typing.Optional[Image] = None
|
|
|
|
self._add_category_button: typing.Optional[Button] = None
|
|
|
|
self._more_button: typing.Optional[Button] = None
|
|
|
|
self._arrow_button: typing.Optional[Button] = None
|
|
|
|
self.init_ui()
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return self.category_name
|
|
|
|
|
|
|
|
def init_ui(self):
|
|
|
|
for child in walk_children(self.object):
|
|
|
|
if str(getattr(child, 'id', '')) == 'statusChatListCategoryItem':
|
|
|
|
self.category_name = str(child.text)
|
|
|
|
elif str(getattr(child, 'id', '')) == 'addButton':
|
|
|
|
self._add_channel_button = Button(name='', real_name=driver.objectMap.realName(child))
|
|
|
|
elif str(getattr(child, 'id', '')) == 'menuButton':
|
|
|
|
self._more_button = Button(name='', real_name=driver.objectMap.realName(child))
|
|
|
|
elif str(getattr(child, 'id', '')) == 'toggleButton':
|
|
|
|
self._arrow_button = Button(name='', real_name=driver.objectMap.realName(child))
|
|
|
|
|
|
|
|
@allure.step('Click arrow button')
|
|
|
|
def click_arrow_button(self):
|
|
|
|
self._arrow_button.click()
|
|
|
|
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
class LeftPanel(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('mainWindow_communityColumnView_CommunityColumnView')
|
|
|
|
self._community_info_button = Button('mainWindow_communityHeaderButton_StatusChatInfoButton')
|
|
|
|
self._community_logo = QObject('mainWindow_identicon_StatusSmartIdenticon')
|
|
|
|
self._name_text_label = TextLabel('mainWindow_statusChatInfoButtonNameText_TruncatedTextWithTooltip')
|
|
|
|
self._members_text_label = TextLabel('mainWindow_Members_TruncatedTextWithTooltip')
|
2023-09-04 18:36:48 +00:00
|
|
|
self._channel_list_item = QObject('channel_listItem')
|
|
|
|
self._channel_icon_template = QObject('channel_identicon_StatusSmartIdenticon')
|
|
|
|
self._channel_or_category_button = Button('mainWindow_createChannelOrCategoryBtn_StatusBaseText')
|
|
|
|
self._create_channel_menu_item = Button('create_channel_StatusMenuItem')
|
2023-12-06 12:00:09 +00:00
|
|
|
self._create_category_menu_item = Button('create_category_StatusMenuItem')
|
2023-09-11 18:24:13 +00:00
|
|
|
self._join_community_button = Button('mainWindow_Join_Community_StatusButton')
|
2023-12-06 12:00:09 +00:00
|
|
|
self._categories_items_list = List('scrollView_chatListItems_StatusListView')
|
|
|
|
self._category_list_item = QObject('categoryItem_StatusChatListCategoryItem')
|
|
|
|
self._create_category_button = Button('add_categories_StatusFlatButton')
|
|
|
|
self._delete_category_item = QObject('delete_Category_StatusMenuItem')
|
|
|
|
self._add_channel_inside_category_item = QObject('scrollView_addButton_StatusChatListCategoryItemButton')
|
|
|
|
self._more_button = Button('scrollView_menuButton_StatusChatListCategoryItemButton')
|
|
|
|
self._arrow_button = Button('scrollView_toggleButton_StatusChatListCategoryItemButton')
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community logo')
|
|
|
|
def logo(self) -> Image:
|
|
|
|
return self._community_logo.image
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community name')
|
|
|
|
def name(self) -> str:
|
|
|
|
return self._name_text_label.text
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community members label')
|
|
|
|
def members(self) -> str:
|
|
|
|
return self._members_text_label.text
|
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
@property
|
|
|
|
@allure.step('Get Join button visible attribute')
|
|
|
|
def is_join_community_visible(self) -> bool:
|
|
|
|
return self._join_community_button.is_visible
|
|
|
|
|
2023-09-04 18:36:48 +00:00
|
|
|
@property
|
|
|
|
@allure.step('Get channels')
|
|
|
|
def channels(self) -> typing.List[UserChannel]:
|
2023-12-13 08:20:56 +00:00
|
|
|
time.sleep(0.5)
|
2023-09-04 18:36:48 +00:00
|
|
|
channels_list = []
|
|
|
|
for obj in driver.findAllObjects(self._channel_list_item.real_name):
|
|
|
|
container = driver.objectMap.realName(obj)
|
|
|
|
self._channel_icon_template.real_name['container'] = container
|
|
|
|
channels_list.append(UserChannel(
|
|
|
|
str(obj.objectName),
|
|
|
|
obj.item.selected
|
|
|
|
))
|
|
|
|
return channels_list
|
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
@property
|
|
|
|
@allure.step('Get categories')
|
|
|
|
def categories_items(self) -> typing.List[CategoryItem]:
|
|
|
|
return [CategoryItem(item) for item in self._categories_items_list.items]
|
|
|
|
|
2023-09-04 18:36:48 +00:00
|
|
|
@allure.step('Get channel params')
|
|
|
|
def get_channel_parameters(self, name) -> UserChannel:
|
2023-12-12 14:05:33 +00:00
|
|
|
for channel in self.channels:
|
|
|
|
if channel.name == name:
|
|
|
|
return channel
|
2023-09-04 18:36:48 +00:00
|
|
|
raise LookupError(f'Channel not found in {self.channels}')
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Open community settings')
|
|
|
|
def open_community_settings(self):
|
|
|
|
self._community_info_button.click()
|
|
|
|
return CommunitySettingsScreen().wait_until_appears()
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@allure.step('Open create channel popup')
|
|
|
|
def open_create_channel_popup(self) -> NewChannelPopup:
|
|
|
|
self._channel_or_category_button.click()
|
|
|
|
self._create_channel_menu_item.click()
|
|
|
|
return NewChannelPopup().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Select channel')
|
|
|
|
def select_channel(self, name: str):
|
|
|
|
for obj in driver.findAllObjects(self._channel_list_item.real_name):
|
|
|
|
if str(obj.objectName) == name:
|
|
|
|
driver.mouseClick(obj)
|
|
|
|
return
|
|
|
|
raise LookupError('Channel not found')
|
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
@allure.step('Open create category popup')
|
2023-12-12 14:05:33 +00:00
|
|
|
def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup:
|
2023-12-06 12:00:09 +00:00
|
|
|
self._channel_or_category_button.click()
|
2023-12-12 14:05:33 +00:00
|
|
|
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
|
2023-12-06 12:00:09 +00:00
|
|
|
|
2023-09-11 18:24:13 +00:00
|
|
|
@allure.step('Open join community popup')
|
|
|
|
def open_welcome_community_popup(self):
|
|
|
|
self._join_community_button.click()
|
|
|
|
return WelcomeCommunityPopup().wait_until_appears()
|
|
|
|
|
2023-12-06 12:00:09 +00:00
|
|
|
@allure.step('Find category')
|
|
|
|
def find_category_in_list(
|
|
|
|
self, category_name: str, timeout_sec: int = configs.timeouts.MESSAGING_TIMEOUT_SEC):
|
|
|
|
started_at = time.monotonic()
|
|
|
|
category = None
|
|
|
|
while category is None:
|
|
|
|
categories = self.categories_items
|
|
|
|
for _category in categories:
|
|
|
|
if _category.category_name == category_name:
|
|
|
|
category = _category
|
|
|
|
assert time.monotonic() - started_at < timeout_sec, f'Category: {category_name} not found in {categories}'
|
|
|
|
return category
|
|
|
|
|
|
|
|
@allure.step('Open more options')
|
|
|
|
def open_more_options(self):
|
|
|
|
self._arrow_button.click()
|
|
|
|
self._more_button.click()
|
|
|
|
|
|
|
|
@allure.step('Open delete category popup')
|
|
|
|
def open_delete_category_popup(self) -> DeleteCategoryPopup:
|
|
|
|
self._delete_category_item.click()
|
|
|
|
return DeleteCategoryPopup().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Open new channel popup inside category')
|
|
|
|
def open_new_channel_popup_in_category(self) -> NewChannelPopup:
|
|
|
|
self._arrow_button.click()
|
|
|
|
self._add_channel_inside_category_item.click()
|
|
|
|
return NewChannelPopup().wait_until_appears()
|
|
|
|
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
class Chat(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('mainWindow_ChatColumnView')
|
|
|
|
self._channel_icon = QObject('chatMessageViewDelegate_channelIdentifierSmartIdenticon_StatusSmartIdenticon')
|
|
|
|
self._channel_name_label = TextLabel('chatMessageViewDelegate_channelIdentifierNameText_StyledText')
|
|
|
|
self._channel_welcome_label = TextLabel('chatMessageViewDelegate_Welcome')
|
2023-12-08 07:20:15 +00:00
|
|
|
self._channel_identifier_view = QObject('chatMessageViewDelegate_ChannelIdentifierView')
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel emoji')
|
|
|
|
def channel_emoji(self):
|
|
|
|
return self._channel_identifier_view.object.chatEmoji
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@property
|
2023-12-08 07:20:15 +00:00
|
|
|
@allure.step('Get channel color')
|
|
|
|
def channel_color(self) -> str:
|
|
|
|
return str(self._channel_identifier_view.object.chatColor).lower()
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel name')
|
|
|
|
def channel_name(self) -> str:
|
|
|
|
return self._channel_name_label.text
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get channel welcome note')
|
|
|
|
def channel_welcome_note(self) -> str:
|
|
|
|
return self._channel_welcome_label.text
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Members(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('mainWindow_UserListPanel')
|
|
|
|
self._member_item = QObject('userListPanel_StatusMemberListItem')
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get all members')
|
|
|
|
def members(self) -> typing.List[str]:
|
|
|
|
return [str(member.statusListItemTitle.text) for member in driver.findAllObjects(self._member_item.real_name)]
|