test: edit_community_category

This commit is contained in:
Valentina Novgorodtceva 2023-12-15 17:59:58 +07:00 committed by Anastasiya
parent e6d752ba4c
commit d941bc031a
5 changed files with 107 additions and 6 deletions

View File

@ -1,7 +1,11 @@
import allure
import configs
import driver.objects_access
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.check_box import CheckBox
from gui.elements.object import QObject
from gui.elements.text_edit import TextEdit
@ -10,12 +14,28 @@ class CategoryPopup(BasePopup):
def __init__(self):
super(CategoryPopup, self).__init__()
self._name_text_edit = TextEdit('createOrEditCommunityCategoryNameInput_TextEdit')
self._general_item_checkbox = CheckBox('channelItemCheckbox_StatusCheckBox')
self._channel_item_checkbox = CheckBox('channelItemCheckbox_StatusCheckBox')
self._channels_view = QObject('createOrEditCommunityCategoryChannelList_StatusListView')
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self._name_text_edit.wait_until_appears(timeout_msec)
return self
@allure.step('Enter category title in category popup')
def enter_category_title(self, title):
self._name_text_edit.text = title
return self
@allure.step('Click checkbox in category popup')
def click_checkbox_by_index(self, index: int):
checkboxes = []
for child in driver.objects_access.walk_children(self._channels_view.object):
if child.id == 'channelItemCheckbox':
checkboxes.append(child)
driver.mouseClick(checkboxes[index])
return self
class NewCategoryPopup(CategoryPopup):
@ -23,9 +43,23 @@ class NewCategoryPopup(CategoryPopup):
super(NewCategoryPopup, self).__init__()
self._create_button = Button('create_StatusButton')
@allure.step('Create category')
def create(self, name: str, checkbox_state: bool):
self._name_text_edit.text = name
if checkbox_state:
self._general_item_checkbox.click()
self._channel_item_checkbox.click()
self._create_button.click()
self.wait_until_hidden()
class EditCategoryPopup(CategoryPopup):
def __init__(self):
super(EditCategoryPopup, self).__init__()
self._delete_button = Button('delete_Category_StatusButton')
self._save_button = Button('save_StatusButton')
@allure.step('Click save in edit category popup')
def save(self):
self._save_button.click()
self.wait_until_hidden()

View File

@ -27,6 +27,7 @@ add_categories_StatusFlatButton = {"checkable": False, "container": mainWindow_s
categoryItem_StatusChatListCategoryItem = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "categoryItem", "type": "StatusChatListCategoryItem", "visible": True}
delete_Category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteCategoryMenuItem", "type": "StatusMenuItem", "visible": True}
create_category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityCategoryBtn", "type": "StatusMenuItem", "visible": True}
edit_Category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "editCategoryMenuItem", "type": "StatusMenuItem", "visible": True}
scrollView_menuButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "menuButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True}
scrollView_toggleButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "toggleButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True}
scrollView_addButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "addButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True}

View File

@ -94,6 +94,7 @@ createCommunityNextBtn_StatusButton = {"container": statusDesktop_mainWindow_ove
createCommunityIntroMessageInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityIntroMessageInput", "type": "TextEdit", "visible": True}
createCommunityOutroMessageInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityOutroMessageInput", "type": "TextEdit", "visible": True}
createCommunityFinalBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityFinalBtn", "type": "StatusButton", "visible": True}
createOrEditCommunityCategoryChannelList_StatusListView = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryChannelList", "type": "StatusListView", "visible": True}
# Community Channel Popup
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
@ -106,6 +107,8 @@ createOrEditCommunityCategoryNameInput_TextEdit = {"container": statusDesktop_ma
category_item_name_general_StatusListItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "category_item_name_general", "type": "StatusListItem", "visible": True}
create_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryBtn", "type": "StatusButton", "visible": True}
channelItemCheckbox_StatusCheckBox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "channelItemCheckbox", "type": "StatusCheckBox", "unnamed": 1, "visible": True}
delete_Category_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "type": "StatusButton", "unnamed": 1, "visible": True}
save_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryBtn", "type": "StatusButton", "visible": True}
# Invite Contacts Popup
communityProfilePopupInviteFrindsPanel = {"container": statusDesktop_mainWindow_overlay, "objectName": "CommunityProfilePopupInviteFrindsPanel_ColumnLayout", "type": "ProfilePopupInviteFriendsPanel", "visible": True}

View File

@ -8,7 +8,7 @@ import configs
import driver
from constants import UserChannel
from driver.objects_access import walk_children
from gui.components.community.community_category_popup import NewCategoryPopup
from gui.components.community.community_category_popup import NewCategoryPopup, EditCategoryPopup, CategoryPopup
from gui.components.community.community_channel_popups import EditChannelPopup, NewChannelPopup
from gui.components.community.welcome_community import WelcomeCommunityPopup
from gui.components.delete_popup import DeletePopup, DeleteCategoryPopup
@ -74,6 +74,12 @@ class CommunityScreen(QObject):
self.left_panel.open_more_options()
self.left_panel.open_delete_category_popup().delete()
@allure.step('Edit category')
def edit_category(self):
self.left_panel.open_more_options()
self.left_panel.open_edit_category_popup()
return EditCategoryPopup()
@allure.step('Verify category in the list')
def verify_category(self, category_name: str):
category = self.left_panel.find_category_in_list(category_name)
@ -93,7 +99,6 @@ class ToolBar(QObject):
self._delete_channel_context_item = QObject('delete_Channel_StatusMenuItem')
self._channel_header = QObject('statusToolBar_chatInfoBtnInHeader_StatusChatInfoButton')
@property
@allure.step('Get channel emoji')
def channel_emoji(self):
@ -174,6 +179,7 @@ class LeftPanel(QObject):
self._category_list_item = QObject('categoryItem_StatusChatListCategoryItem')
self._create_category_button = Button('add_categories_StatusFlatButton')
self._delete_category_item = QObject('delete_Category_StatusMenuItem')
self._edit_category_item = QObject('edit_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')
@ -251,7 +257,7 @@ class LeftPanel(QObject):
return NewCategoryPopup().wait_until_appears()
except Exception as ex:
if attempts:
self.open_create_category_popup(attempts-1)
self.open_create_category_popup(attempts - 1)
else:
raise ex
@ -283,12 +289,23 @@ class LeftPanel(QObject):
self._delete_category_item.click()
return DeleteCategoryPopup().wait_until_appears()
@allure.step('Open edit category popup')
def open_edit_category_popup(self) -> EditCategoryPopup:
self._edit_category_item.click()
return CategoryPopup().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()
@allure.step('Get channel or category index in the list')
def get_channel_or_category_index(self, name: str) -> int:
for child in walk_children(self._categories_items_list.object):
if child.objectName == name:
return child.visualIndex
class Chat(QObject):
@ -299,7 +316,6 @@ class Chat(QObject):
self._channel_welcome_label = TextLabel('chatMessageViewDelegate_Welcome')
self._channel_identifier_view = QObject('chatMessageViewDelegate_ChannelIdentifierView')
@property
@allure.step('Get channel emoji')
def channel_emoji(self):

View File

@ -3,6 +3,7 @@ import pytest
from allure_commons._allure import step
import constants
from gui.components.community.community_category_popup import EditCategoryPopup, CategoryPopup
from gui.main_window import MainWindow
from . import marks
@ -53,3 +54,49 @@ def test_remove_community_category(main_screen: MainWindow, category_name, gener
general_channel = community_screen.left_panel.get_channel_parameters('general')
assert new_channel in community_screen.left_panel.channels
assert general_channel in community_screen.left_panel.channels
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703233', 'Edit category')
@pytest.mark.case(703233)
@pytest.mark.parametrize(
'category_name, general_checkbox, channel_name, channel_description, channel_emoji, second_channel_name, second_channel_description, second_channel_emoji',
[
pytest.param('Category in general', True, 'Channel', 'Description', 'sunglasses', 'Second-channel',
'Description', 'sunglasses')
])
def test_edit_community_category(main_screen: MainWindow, category_name, general_checkbox, channel_name,
channel_description, channel_emoji, second_channel_name, second_channel_description,
second_channel_emoji):
with step('Create community and select it'):
main_screen.create_community(constants.community_params)
community_screen = main_screen.left_panel.select_community(constants.community_params['name'])
with step('Create community category and verify that it displays correctly'):
community_screen.create_category(category_name, general_checkbox)
community_screen.verify_category(category_name)
with step('Create community channel inside category'):
community_screen.left_panel.open_new_channel_popup_in_category().create(channel_name, channel_description,
channel_emoji)
with step('Create community channel outside of category'):
community_screen.create_channel(second_channel_name, second_channel_description, second_channel_emoji)
with step('Verify that selected channel is listed outside of category'):
assert community_screen.left_panel.get_channel_or_category_index(second_channel_name) == 0
with step('Open edit category popup'):
category_popup = community_screen.edit_category()
category_popup.enter_category_title("New category").click_checkbox_by_index(0)
category_popup.save()
with step('Verify that selected channel is now listed inside category'):
assert community_screen.left_panel.get_channel_or_category_index(second_channel_name) == 3
with step('Open edit category popup'):
category_popup = community_screen.edit_category()
category_popup.click_checkbox_by_index(2)
category_popup.save()
with step('Verify that selected channel is now listed outside of category'):
assert community_screen.left_panel.get_channel_or_category_index(second_channel_name) == 0