2023-09-28 12:44:13 +00:00
|
|
|
import logging
|
2024-06-17 07:44:39 +00:00
|
|
|
import pathlib
|
2023-08-29 14:43:00 +00:00
|
|
|
import typing
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
2024-02-19 07:18:46 +00:00
|
|
|
import configs
|
|
|
|
import driver
|
2024-10-21 09:16:06 +00:00
|
|
|
from constants import CommunityData
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.components.base_popup import BasePopup
|
2024-02-19 07:18:46 +00:00
|
|
|
from gui.components.community.color_select_popup import ColorSelectPopup
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.components.community.tags_select_popup import TagsSelectPopup
|
|
|
|
from gui.components.picture_edit_popup import PictureEditPopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.check_box import CheckBox
|
2024-02-13 12:47:11 +00:00
|
|
|
from gui.elements.object import QObject
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.scroll import Scroll
|
|
|
|
from gui.elements.text_edit import TextEdit
|
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
|
|
|
|
|
2023-12-01 13:58:22 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-09-28 12:44:13 +00:00
|
|
|
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
class CreateCommunitiesBanner(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._crete_community_button = Button(names.create_new_StatusButton)
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
def open_create_community_popup(self) -> 'CreateCommunityPopup':
|
|
|
|
self._crete_community_button.click()
|
|
|
|
return CreateCommunityPopup().wait_until_appears()
|
|
|
|
|
|
|
|
|
|
|
|
class CreateCommunityPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-10-15 15:31:37 +00:00
|
|
|
self._scroll = Scroll(names.generalView_StatusScrollView)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._name_text_edit = TextEdit(names.createCommunityNameInput_TextEdit)
|
|
|
|
self._description_text_edit = TextEdit(names.createCommunityDescriptionInput_TextEdit)
|
|
|
|
self._add_logo_button = Button(names.addButton_StatusRoundButton2)
|
|
|
|
self._add_banner_button = Button(names.addButton_StatusRoundButton)
|
|
|
|
self._select_color_button = Button(names.StatusPickerButton)
|
|
|
|
self._choose_tag_button = Button(names.choose_tags_StatusPickerButton)
|
2024-02-19 07:18:46 +00:00
|
|
|
self._community_tags_picker_button = Button(names.communityTagsPicker_TagsPicker)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._archive_support_checkbox = CheckBox(names.archiveSupportToggle_StatusCheckBox)
|
|
|
|
self._request_to_join_checkbox = CheckBox(names.requestToJoinToggle_StatusCheckBox)
|
|
|
|
self._pin_messages_checkbox = CheckBox(names.pinMessagesToggle_StatusCheckBox)
|
|
|
|
self._next_button = Button(names.createCommunityNextBtn_StatusButton)
|
|
|
|
self._intro_text_edit = TextEdit(names.createCommunityIntroMessageInput_TextEdit)
|
|
|
|
self._outro_text_edit = TextEdit(names.createCommunityOutroMessageInput_TextEdit)
|
|
|
|
self._create_community_button = Button(names.createCommunityFinalBtn_StatusButton)
|
|
|
|
self._cropped_image_logo_item = QObject(names.croppedImageLogo)
|
|
|
|
self._cropped_image_banner_item = QObject(names.croppedImageBanner)
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2024-02-19 07:18:46 +00:00
|
|
|
@allure.step('Get next button enabled state')
|
|
|
|
def is_next_button_enabled(self) -> bool:
|
|
|
|
return driver.waitForObjectExists(self._next_button.real_name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC).enabled
|
|
|
|
|
|
|
|
@allure.step('Get archive support checkbox state')
|
|
|
|
def is_archive_checkbox_checked(self) -> bool:
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._archive_support_checkbox)
|
2024-02-19 07:18:46 +00:00
|
|
|
return self._archive_support_checkbox.is_checked
|
|
|
|
|
|
|
|
@allure.step('Get request to join checkbox state')
|
|
|
|
def is_request_to_join_checkbox_checked(self) -> bool:
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._request_to_join_checkbox)
|
2024-02-19 07:18:46 +00:00
|
|
|
return self._request_to_join_checkbox.is_checked
|
|
|
|
|
|
|
|
@allure.step('Get pin messaged checkbox state')
|
|
|
|
def is_pin_messages_checkbox_checked(self) -> bool:
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._pin_messages_checkbox)
|
2024-02-19 07:18:46 +00:00
|
|
|
return self._pin_messages_checkbox.is_checked
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Get community name')
|
2024-05-02 15:04:06 +00:00
|
|
|
def get_name(self) -> str:
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._name_text_edit)
|
2023-08-29 14:43:00 +00:00
|
|
|
return self._name_text_edit.text
|
|
|
|
|
|
|
|
@allure.step('Set community name')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_name(self, value: str):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._name_text_edit)
|
2023-08-29 14:43:00 +00:00
|
|
|
self._name_text_edit.text = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community description')
|
|
|
|
def description(self) -> str:
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._description_text_edit)
|
2023-08-29 14:43:00 +00:00
|
|
|
return self._description_text_edit.text
|
|
|
|
|
|
|
|
@allure.step('Set community name')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_description(self, value: str):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._description_text_edit)
|
2023-08-29 14:43:00 +00:00
|
|
|
self._description_text_edit.text = value
|
|
|
|
|
2024-02-13 12:47:11 +00:00
|
|
|
@allure.step('Set community logo without file upload dialog')
|
|
|
|
def set_logo_without_file_upload_dialog(self, path):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._add_logo_button)
|
2024-06-17 07:44:39 +00:00
|
|
|
fileuri = pathlib.Path(str(path)).as_uri()
|
|
|
|
self._cropped_image_logo_item.object.cropImage(fileuri)
|
2024-02-13 12:47:11 +00:00
|
|
|
return PictureEditPopup()
|
|
|
|
|
|
|
|
@allure.step('Set community banner without file upload dialog')
|
|
|
|
def set_banner_without_file_upload_dialog(self, path):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._add_banner_button)
|
2024-06-17 07:44:39 +00:00
|
|
|
fileuri = pathlib.Path(str(path)).as_uri()
|
|
|
|
self._cropped_image_banner_item.object.cropImage(fileuri)
|
2024-02-13 12:47:11 +00:00
|
|
|
return PictureEditPopup()
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Get community color')
|
2024-05-02 15:04:06 +00:00
|
|
|
def get_color(self):
|
2024-02-19 07:18:46 +00:00
|
|
|
return self._select_color_button.object.bgColor.name
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
@allure.step('Set community color')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_color(self, value: str):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._select_color_button)
|
2023-08-29 14:43:00 +00:00
|
|
|
self._select_color_button.click()
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._select_color_button)
|
2023-08-29 14:43:00 +00:00
|
|
|
ColorSelectPopup().wait_until_appears().select_color(value)
|
|
|
|
|
|
|
|
@allure.step('Get community tags')
|
2024-05-02 15:04:06 +00:00
|
|
|
def get_tags(self):
|
2024-02-19 07:18:46 +00:00
|
|
|
tags_string = str(self._community_tags_picker_button.object.selectedTags)
|
|
|
|
symbols = '[]"'
|
|
|
|
for symbol in symbols:
|
|
|
|
tags_string = tags_string.replace(symbol, '')
|
|
|
|
return tags_string.split(',')
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
@allure.step('Set community tags')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_tags(self, values: typing.List[str]):
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll.vertical_scroll_down(self._choose_tag_button)
|
2023-08-29 14:43:00 +00:00
|
|
|
self._choose_tag_button.click()
|
|
|
|
TagsSelectPopup().wait_until_appears().select_tags(values)
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community intro')
|
|
|
|
def intro(self) -> str:
|
|
|
|
return self._intro_text_edit.text
|
|
|
|
|
|
|
|
@allure.step('Set community intro')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_intro(self, value: str):
|
2023-08-29 14:43:00 +00:00
|
|
|
self._intro_text_edit.text = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get community outro')
|
|
|
|
def outro(self) -> str:
|
|
|
|
return self._outro_text_edit.text
|
|
|
|
|
|
|
|
@allure.step('Set community outro')
|
2024-05-02 15:04:06 +00:00
|
|
|
def set_outro(self, value: str):
|
2023-08-29 14:43:00 +00:00
|
|
|
self._outro_text_edit.text = value
|
|
|
|
|
|
|
|
@allure.step('Open intro/outro form')
|
|
|
|
def open_next_form(self):
|
|
|
|
self._next_button.click()
|
|
|
|
|
2024-05-02 15:04:06 +00:00
|
|
|
@allure.step('Select color and verify it was set correctly')
|
|
|
|
def verify_color(self, color: str):
|
|
|
|
assert self.get_color() == color
|
|
|
|
|
|
|
|
@allure.step('Select tags and verify they were set correctly')
|
2024-10-15 15:31:37 +00:00
|
|
|
def verify_tags(self, tags: typing.List[str]):
|
2024-05-02 15:04:06 +00:00
|
|
|
actual_tags = self.get_tags()
|
2024-10-15 15:31:37 +00:00
|
|
|
assert tags.sort(reverse=False) == actual_tags.sort(reverse=False)
|
2024-05-02 15:04:06 +00:00
|
|
|
|
|
|
|
@allure.step('Verify default values of checkboxes')
|
|
|
|
def verify_checkboxes_values(self):
|
|
|
|
assert not self.is_archive_checkbox_checked()
|
|
|
|
assert not self.is_request_to_join_checkbox_checked()
|
|
|
|
assert not self.is_pin_messages_checkbox_checked()
|
|
|
|
|
|
|
|
@allure.step('Verify community create popup fields and create community without file upload dialog usage')
|
2024-10-15 15:31:37 +00:00
|
|
|
def create_community(self, community_data: CommunityData):
|
|
|
|
self.set_name(community_data.name)
|
|
|
|
self.set_description(community_data.description)
|
|
|
|
self.set_logo_without_file_upload_dialog(community_data.logo['fp'])
|
2024-02-15 10:37:40 +00:00
|
|
|
PictureEditPopup().set_zoom_shift_for_picture(None, None)
|
2024-10-15 15:31:37 +00:00
|
|
|
self.set_banner_without_file_upload_dialog(community_data.banner['fp'])
|
2024-02-15 10:37:40 +00:00
|
|
|
PictureEditPopup().set_zoom_shift_for_picture(None, None)
|
2024-10-15 15:31:37 +00:00
|
|
|
self.set_color(community_data.color)
|
|
|
|
self.verify_color(community_data.color)
|
|
|
|
self.set_tags(community_data.tags)
|
|
|
|
self.verify_tags(community_data.tags)
|
2024-05-02 15:04:06 +00:00
|
|
|
self.verify_checkboxes_values()
|
2024-02-19 07:18:46 +00:00
|
|
|
self._next_button.click()
|
2024-10-15 15:31:37 +00:00
|
|
|
self.set_intro(community_data.introduction)
|
|
|
|
self.set_outro(community_data.leaving_message)
|
2024-05-03 09:36:51 +00:00
|
|
|
self._create_community_button.click()
|
2024-10-10 10:26:23 +00:00
|
|
|
self.wait_until_hidden()
|
2024-05-03 09:36:51 +00:00
|
|
|
return CommunityScreen().wait_until_appears()
|