Skip to content

Commit

Permalink
test(community): add a test that deletes a community category
Browse files Browse the repository at this point in the history
Close #6750
  • Loading branch information
MishkaRogachev committed Aug 18, 2022
1 parent ade9086 commit 48b7f1c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 18 deletions.
19 changes: 11 additions & 8 deletions test/ui-test/src/drivers/SquishDriverVerification.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,31 @@ def verify_text_matching(objName: str, text: str):

def verify_text_matching_insensitive(obj, text: str):
test.verify(is_text_matching_insensitive(obj, text), "text does not match")
def verify_equal(result: object, expected: object):
test.verify(result == expected, "Checking if objects are equal")

def verify_equal(result: object, expected: object, msg: str = "objects are not equal"):
test.verify(result == expected, msg)

def verify(result: bool, msg: str):
test.verify(result, msg)


def verify_false(result: bool, msg: str):
test.verify(not result, msg)

def verify_values_equal(found: str, wanted: str, msg : str):
test.verify(found == wanted, msg + " Found: " + found + " - Wanted: " + wanted)

def verify_text_contains(text: str, substring: str):
found = False
if substring in text:
found = True
verify(found, "Given substring: " + substring + " and complete text: " + text)

def verify_text_does_not_contain(text: str, substring: str):
found = False
if substring in text:
found = True
verify(not found, "Given substring: " + substring + " and complete text: " + text)

def verify_text(text1: str, text2: str):
test.compare(text1, text2, "Text 1: " + text1 + "\nText 2: " + text2)

Expand Down Expand Up @@ -91,6 +94,6 @@ def verify_equals(val1, val2):

def verify_failure(errorMsg: str):
test.fail(errorMsg)

def log(text: str):
test.log(text)
23 changes: 19 additions & 4 deletions test/ui-test/src/screens/StatusCommunityScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class CommunityScreenComponents(Enum):
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_EDIT_CATEGORY_MENU_ITEM = "edit_сategory_StatusMenuItemDelegate"
COMMUNITY_DELETE_CATEGORY_MENU_ITEM = "delete_сategory_StatusMenuItemDelegate"
COMMUNITY_CONFIRM_DELETE_CATEGORY_BUTTON = "confirmDeleteCategoryButton_StatusButton"
CHAT_IDENTIFIER_CHANNEL_NAME = "msgDelegate_channelIdentifierNameText_StyledText"
CHAT_IDENTIFIER_CHANNEL_ICON = "mainWindow_chatInfoBtnInHeader_StatusChatInfoButton"
CHAT_MORE_OPTIONS_BUTTON = "chat_moreOptions_menuButton"
Expand Down Expand Up @@ -133,7 +136,7 @@ def create_community_category(self, community_category_name, community_channel_n
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)
verify_failure("Unknown method to create a category: ", method)

click_obj_by_name(CommunityScreenComponents.COMMUNITY_CREATE_CATEGORY_MENU_ITEM.value)

Expand All @@ -143,14 +146,26 @@ def create_community_category(self, community_category_name, community_channel_n
if loaded:
click_obj(listItem)
else:
test.fail("Can't find channel " + community_channel_name)
verify_failure("Can't find channel " + community_channel_name)

click_obj_by_name(CreateOrEditCommunityCategoryPopup.COMMUNITY_CATEGORY_BUTTON.value)

def delete_community_category(self, community_category_name):
[loaded, category] = self._find_category_in_chat(community_category_name)
verify(loaded, "Can't find category " + community_category_name)

# For some reason it clicks on a first channel in category instead of category
squish.mouseClick(category.parent, squish.Qt.RightButton)
click_obj_by_name(CommunityScreenComponents.COMMUNITY_DELETE_CATEGORY_MENU_ITEM.value)
click_obj_by_name(CommunityScreenComponents.COMMUNITY_CONFIRM_DELETE_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)
verify(result, "Can't find category " + community_category_name)

def verify_category_name_missing(self, community_category_name):
[result, _] = self._find_category_in_chat(community_category_name)
verify_false(result, "Category " + community_category_name + " still exist")

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
mainWindow_communityHeader_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "communityHeaderButton", "type": "StatusChatInfoButton", "visible": True}
community_ChatInfo_Name_Text = {"container": mainWindow_communityHeader_StatusChatInfoButton, "objectName": "statusChatInfoButtonNameText", "type": "StatusBaseText", "visible": True}
mainWindow_createChannelOrCategoryBtn_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "createChannelOrCategoryBtn", "type": "StatusBaseText", "visible": True}
create_channel_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityChannelBtn", "type": "StatusMenuItemDelegate", "visible": True}
create_category_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityCategoryBtn", "type": "StatusMenuItemDelegate", "visible": True}
create_channel_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityChannelBtn", "type": "StatusMenuItemDelegate", "visible": True}
create_category_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityCategoryBtn", "type": "StatusMenuItemDelegate", "visible": True}
edit_сategory_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "editCategoryMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
delete_сategory_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteCategoryMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
confirmDeleteCategoryButton_StatusButton = {"container": statusDesktop_mainWindow, "objectName": "confirmDeleteCategoryButton", "type": "StatusButton"}
chat_moreOptions_menuButton = {"container": statusDesktop_mainWindow, "objectName": "chatToolbarMoreOptionsButton", "type": "StatusFlatRoundButton", "visible": True}
edit_Channel_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "editChannelMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
edit_Channel_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "editChannelMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
msgDelegate_channelIdentifierNameText_StyledText = {"container": chatMessageListView_msgDelegate_MessageView, "objectName": "channelIdentifierNameText", "type": "StyledText", "visible": True}
delete_Channel_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
delete_Channel_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
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:``
# Community channel popup:
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
createOrEditCommunityChannelDescriptionInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelDescriptionInput", "type": "TextEdit", "visible": True}
createOrEditCommunityChannelBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelBtn", "type": "StatusButton", "visible": True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ def step(context, community_channel_name):
def step(context, community_category_name, community_channel_name, method):
_statusCommunityScreen.create_community_category(community_category_name, community_channel_name, method)

@When("the admin deletes category named |any|")
def step(context, community_category_name):
_statusCommunityScreen.delete_community_category(community_category_name)

@Then("the category named |any| is created")
def step(context, community_category_name):
_statusCommunityScreen.verify_category_name(community_category_name)

@Then("the category named |any| is missing")
def step(context, community_category_name):
_statusCommunityScreen.verify_category_name_missing(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,25 @@ Feature: Status Desktop 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
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>
And 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: Admin deletes 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 test-channel, with description My description with the method bottom_menu
And the admin creates a community category named test-category, with channel test-channel and with the method bottom_menu
Then the category named test-category is created
When the admin deletes category named test-category
Then the category named test-category is missing


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
Expand All @@ -88,6 +99,7 @@ Feature: Status Desktop community
| new_community_name | new_community_description | new_community_color |
| myCommunityNamedChanged | Cool new description 123 | #ff0000 |


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
Expand All @@ -96,6 +108,7 @@ Feature: Status Desktop community
And the user leaves the community
Then the count of communities in navbar is 0


Scenario Outline: User changes the emoji of a 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
Expand Down
3 changes: 3 additions & 0 deletions ui/app/AppLayouts/Chat/views/CommunityColumnView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ Item {
}

StatusMenuItem {
objectName: "editCategoryMenuItem"
enabled: communityData.amISectionAdmin
text: qsTr("Edit Category")
icon.name: "edit"
Expand All @@ -277,6 +278,7 @@ Item {
}

StatusMenuItem {
objectName: "deleteCategoryMenuItem"
enabled: communityData.amISectionAdmin
text: qsTr("Delete Category")
icon.name: "delete"
Expand Down Expand Up @@ -551,6 +553,7 @@ Item {
id: deleteCategoryConfirmationDialogComponent
ConfirmationDialog {
property string categoryId
confirmButtonObjectName: "confirmDeleteCategoryButton"
btnType: "warn"
showCancelButton: true
onClosed: {
Expand Down

0 comments on commit 48b7f1c

Please sign in to comment.