test(community): add a test that creates a community category

Close #6752

test/ui-test/testSuites/suite_status/shared/scripts/sections/community_names.py
This commit is contained in:
MishkaRogachev 2022-08-16 14:21:39 +04:00 committed by Mikhail Rogachev
parent ffbe16da3e
commit 9e811838e8
5 changed files with 97 additions and 18 deletions

View File

@ -26,8 +26,8 @@ class CommunityScreenComponents(Enum):
COMMUNITY_HEADER_BUTTON = "mainWindow_communityHeader_StatusChatInfoButton"
COMMUNITY_HEADER_NAME_TEXT= "community_ChatInfo_Name_Text"
COMMUNITY_CREATE_CHANNEL_OR_CAT_BUTTON = "mainWindow_createChannelOrCategoryBtn_StatusBaseText"
COMMUNITY_CREATE_CHANNEL__MENU_ITEM = "create_channel_StatusMenuItemDelegate"
COMMUNITY_CREATE_CATEGORY__MENU_ITEM = "create_category_StatusMenuItemDelegate"
COMMUNITY_CREATE_CHANNEL_MENU_ITEM = "create_channel_StatusMenuItemDelegate"
COMMUNITY_CREATE_CATEGORY_MENU_ITEM = "create_category_StatusMenuItemDelegate"
CHAT_IDENTIFIER_CHANNEL_NAME = "msgDelegate_channelIdentifierNameText_StyledText"
CHAT_IDENTIFIER_CHANNEL_ICON = "mainWindow_chatInfoBtnInHeader_StatusChatInfoButton"
CHAT_MORE_OPTIONS_BUTTON = "chat_moreOptions_menuButton"
@ -36,7 +36,7 @@ class CommunityScreenComponents(Enum):
DELETE_CHANNEL_MENU_ITEM = "delete_Channel_StatusMenuItemDelegate"
DELETE_CHANNEL_CONFIRMATION_DIALOG_DELETE_BUTTON = "delete_Channel_ConfirmationDialog_DeleteButton"
NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList"
COMMUNITY_CHAT_LIST_CATEGORIES = "communityChatListCategories_Repeater"
class CommunitySettingsComponents(Enum):
EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView"
@ -62,11 +62,34 @@ class CreateOrEditCommunityChannelPopup(Enum):
EMOJI_SEARCH_TEXT_INPUT: str = "statusDesktop_mainWindow_AppMain_EmojiPopup_SearchTextInput"
EMOJI_POPUP_EMOJI_PLACEHOLDER = "emojiPopup_Emoji_Button_Placeholder"
class CreateOrEditCommunityCategoryPopup(Enum):
COMMUNITY_CATEGORY_NAME_INPUT: str = "createOrEditCommunityCategoryNameInput_TextEdit"
COMMUNITY_CATEGORY_LIST: str = "createOrEditCommunityCategoryChannelList_ListView"
COMMUNITY_CATEGORY_BUTTON: str = "createOrEditCommunityCategoryBtn_StatusButton"
class StatusCommunityScreen:
def __init__(self):
verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)
def _find_channel_in_category_popup(self, community_channel_name: str):
listView = get_obj(CreateOrEditCommunityCategoryPopup.COMMUNITY_CATEGORY_LIST.value)
for index in range(listView.count):
listItem = listView.itemAtIndex(index)
if (listItem.objectName.toLower() == community_channel_name.lower()):
return True, listItem
return False, None
def _find_category_in_chat(self, community_category_name: str):
chatListCategories = get_obj(CommunityScreenComponents.COMMUNITY_CHAT_LIST_CATEGORIES.value)
for index in range(chatListCategories.count):
item = chatListCategories.itemAt(index)
if (item.objectName == community_category_name):
return True, item
return False, None
def open_edit_channel_popup(self):
StatusMainScreen.wait_for_banner_to_disappear()
@ -84,7 +107,7 @@ class StatusCommunityScreen:
else:
print("Unknown method to create a channel: ", method)
click_obj_by_name(CommunityScreenComponents.COMMUNITY_CREATE_CHANNEL__MENU_ITEM.value)
click_obj_by_name(CommunityScreenComponents.COMMUNITY_CREATE_CHANNEL_MENU_ITEM.value)
wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, communityChannelName)
type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_DESCRIPTION_INPUT.value, communityChannelDescription)
@ -104,6 +127,31 @@ class StatusCommunityScreen:
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_SAVE_OR_CREATE_BUTTON.value)
time.sleep(0.5)
def create_community_category(self, community_category_name, community_channel_name, method):
if (method == CommunityCreateMethods.BOTTOM_MENU.value):
click_obj_by_name(CommunityScreenComponents.COMMUNITY_CREATE_CHANNEL_OR_CAT_BUTTON.value)
elif (method == CommunityCreateMethods.RIGHT_CLICK_MENU.value):
right_click_obj_by_name(CommunityScreenComponents.COMMUNITY_COLUMN_VIEW.value)
else:
test.fail("Unknown method to create a category: ", method)
click_obj_by_name(CommunityScreenComponents.COMMUNITY_CREATE_CATEGORY_MENU_ITEM.value)
wait_for_object_and_type(CreateOrEditCommunityCategoryPopup.COMMUNITY_CATEGORY_NAME_INPUT.value, community_category_name)
[loaded, listItem] = self._find_channel_in_category_popup(community_channel_name)
if loaded:
click_obj(listItem)
else:
test.fail("Can't find channel " + community_channel_name)
click_obj_by_name(CreateOrEditCommunityCategoryPopup.COMMUNITY_CATEGORY_BUTTON.value)
def verify_category_name(self, community_category_name):
[result, _] = self._find_category_in_chat(community_category_name)
if not result:
test.fail("Can't find category " + community_category_name)
def edit_community(self, new_community_name: str, new_community_description: str, new_community_color: str):
click_obj_by_name(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)
click_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_BUTTON.value)

View File

@ -15,6 +15,7 @@ delete_Channel_StatusMenuItemDelegate = {"checkable": False, "container": status
mainWindow_communityColumnView_statusChatList = {"container": mainWindow_communityColumnView_CommunityColumnView, "objectName": "statusChatListAndCategoriesChatList", "type": "StatusChatList"}
delete_Channel_ConfirmationDialog_DeleteButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton"}
mainWindow_chatInfoBtnInHeader_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "chatInfoBtnInHeader", "type": "StatusChatInfoButton", "visible": True}
communityChatListCategories_Repeater = {"container": statusDesktop_mainWindow, "objectName": "communityChatListCategories", "type": "Repeater"}
# Community channel popup:``
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
@ -22,6 +23,11 @@ createOrEditCommunityChannelDescriptionInput_TextEdit = {"container": statusDesk
createOrEditCommunityChannelBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelBtn", "type": "StatusButton", "visible": True}
createOrEditCommunityChannel_EmojiButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "StatusChannelPopup_emojiButton", "type": "StatusRoundButton", "visible": True}
# Community category popup:
createOrEditCommunityCategoryNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryNameInput", "type": "TextEdit", "visible": True}
createOrEditCommunityCategoryChannelList_ListView = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryChannelList", "type": "StatusListView", "visible": True}
createOrEditCommunityCategoryBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryBtn", "type": "StatusButton", "visible": True}
# Community settings
communitySettings_EditCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsEditCommunityButton", "type": "StatusButton"}
communitySettings_BackToCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communitySettingsBackToCommunityButton", "type": "StatusBaseText", "visible": True}
@ -37,7 +43,6 @@ communitySettings_EditCommunity_Description_Input = {"container": communitySetti
communitySettings_EditCommunity_ColorPicker_Button = {"container": communitySettings_EditCommunity_ScrollView, "objectName": "editCommunityColorPicker", "type": "CommunityColorPicker"}
communitySettings_Save_Button = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "StatusButton", "visible": True}
# Community color popup:
communitySettings_ColorPanel_HexColor_Input = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelHexInput", "type": "TextEdit"}
communitySettings_SaveColor_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelSelectColorButton", "type": "StatusButton", "visible": True}

View File

@ -37,6 +37,14 @@ def step(context, new_community_channel_name):
def step(context, community_channel_name):
_statusCommunityScreen.verify_channel_name(community_channel_name)
@When("the admin creates a community category named |any|, with channel |any| and with the method |any|")
def step(context, community_category_name, community_channel_name, method):
_statusCommunityScreen.create_community_category(community_category_name, community_channel_name, method)
@Then("the category named |any| is created")
def step(context, community_category_name):
_statusCommunityScreen.verify_category_name(community_category_name)
@When("the admin edits the current community to the name |any| and description |any| and color |any|")
def step(context, new_community_name, new_community_description, new_community_color):
_statusCommunityScreen.edit_community(new_community_name, new_community_description, new_community_color)

View File

@ -42,6 +42,7 @@ Feature: Status Desktop community
| test-channel | Community channel description tested 1 | bottom_menu |
| test-channel2 | Community channel description tested 2 | right_click_menu |
Scenario Outline: Admin edits a community channel
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
@ -54,6 +55,28 @@ Feature: Status Desktop community
| community_channel_name | community_channel_description | new_community_channel_name |
| test-channel | Community channel description tested 1 | new-test-channel |
Scenario: Admin deletes a community channel
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
And the channel count is 2
When the admin deletes current channel
Then the channel count is 1
Scenario Outline: Admin creates a community category
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named <community_channel_name>, with description Some description with the method <method>
When the admin creates a community category named <community_category_name>, with channel <community_channel_name> and with the method <method>
Then the category named <community_category_name> is created
Examples:
| community_channel_name | community_category_name | method |
| test-channel-1 | test-category-1 | bottom_menu |
| test-channel-2 | test-category-2 | right_click_menu |
Scenario Outline: Admin edits a community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
@ -65,15 +88,6 @@ Feature: Status Desktop community
| new_community_name | new_community_description | new_community_color |
| myCommunityNamedChanged | Cool new description 123 | #ff0000 |
Scenario: Admin deletes a community channel
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
And the channel count is 2
When the admin deletes current channel
Then the channel count is 1
Scenario: User leaves community
When the user creates a community named testCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named testCommunity

View File

@ -57,6 +57,7 @@ StatusModal {
anchors.left: parent.left
anchors.leftMargin: 16
input.edit.objectName: "createOrEditCommunityCategoryNameInput"
label: qsTr("Category title")
charLimit: maxCategoryNameLength
placeholderText: qsTr("Name the category")
@ -108,6 +109,7 @@ StatusModal {
StatusListView {
id: communityChannelList
objectName: "createOrEditCommunityCategoryChannelList"
anchors.top: channelsLabel.bottom
height: childrenRect.height
@ -116,6 +118,7 @@ StatusModal {
interactive: false
delegate: StatusListItem {
objectName: model.name
anchors.horizontalCenter: parent.horizontalCenter
visible: model.type != Constants.chatType.unknown
height: visible ? implicitHeight : 0
@ -204,6 +207,7 @@ StatusModal {
rightButtons: [
StatusButton {
objectName: "createOrEditCommunityCategoryBtn"
enabled: isFormValid()
text: isEdit ?
qsTr("Save") :