Skip to content

Commit

Permalink
test(community): delete community channel
Browse files Browse the repository at this point in the history
Also adds  verify_equal helper function

Fixes #6751
  • Loading branch information
stefandunca committed Aug 16, 2022
1 parent 09d5d2a commit 5fb4c7f
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 30 deletions.
7 changes: 5 additions & 2 deletions test/ui-test/src/drivers/SquishDriverVerification.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def verify_text_does_not_contain(text: str, substring: str):

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

def process_terminated(pid):
try:
remotesys = RemoteSystem()
Expand Down Expand Up @@ -83,5 +83,8 @@ def verify_the_app_is_closed(pid: int):
closed = True
except:
closed = False

verify(closed, "app closed")

def verify_equals(val1, val2):
test.compare(val1, val2, "1st value [" + str(val1) + ("] equal to " if val1 == val2 else "] NOT equal to ") + "2nd value [" + str(val2) + "]")
57 changes: 39 additions & 18 deletions test/ui-test/src/screens/StatusCommunityScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import time
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from drivers.SDKeyboardCommands import *

class MainUi(Enum):
MODULE_WARNING_BANNER = "moduleWarning_Banner"

class CommunityCreateMethods(Enum):
BOTTOM_MENU = "bottom_menu"
RIGHT_CLICK_MENU = "right_click_menu"

class CommunityScreenComponents(Enum):
COMMUNITY_HEADER_BUTTON = "mainWindow_communityHeader_StatusChatInfoButton"
COMMUNITY_HEADER_NAME_TEXT= "community_ChatInfo_Name_Text"
Expand All @@ -31,6 +32,10 @@ class CommunityScreenComponents(Enum):
CHAT_MORE_OPTIONS_BUTTON = "chat_moreOptions_menuButton"
EDIT_CHANNEL_MENU_ITEM = "edit_Channel_StatusMenuItemDelegate"
COMMUNITY_COLUMN_VIEW = "mainWindow_communityColumnView_CommunityColumnView"
DELETE_CHANNEL_MENU_ITEM = "delete_Channel_StatusMenuItemDelegate"
DELETE_CHANNEL_CONFIRMATION_DIALOG_DELETE_BUTTON = "delete_Channel_ConfirmationDialog_DeleteButton"
NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList"


class CommunitySettingsComponents(Enum):
EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView"
Expand All @@ -43,11 +48,11 @@ class CommunitySettingsComponents(Enum):
COMMUNITY_NAME_TEXT = "communitySettings_CommunityName_Text"
COMMUNITY_DESCRIPTION_TEXT = "communitySettings_CommunityDescription_Text"
COMMUNITY_LETTER_IDENTICON = "communitySettings_Community_LetterIdenticon"

class CommunityColorPanelComponents(Enum):
HEX_COLOR_INPUT = "communitySettings_ColorPanel_HexColor_Input"
SAVE_COLOR_BUTTON = "communitySettings_SaveColor_Button"

class CreateOrEditCommunityChannelPopup(Enum):
COMMUNITY_CHANNEL_NAME_INPUT: str = "createOrEditCommunityChannelNameInput_TextEdit"
COMMUNITY_CHANNEL_DESCRIPTION_INPUT: str = "createOrEditCommunityChannelDescriptionInput_TextEdit"
Expand All @@ -57,32 +62,30 @@ class StatusCommunityScreen:

def __init__(self):
verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)

def verify_community_name(self, communityName: str):
verify_text_matching(CommunityScreenComponents.COMMUNITY_HEADER_NAME_TEXT.value, communityName)

def create_community_channel(self, communityChannelName: str, communityChannelDescription: str, method: str):
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:
print("Unknown method to create a channel: ", method)

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)
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_BUTTON.value)
# TODO check if this function is needed, it seems to do the same as verify_chat_title in StatusChatScreen

# TODO check if this function is needed, it seems to do the same as verify_chat_title in StatusChatScreen
def verify_channel_name(self, community_channel_name: str):
verify_text_matching(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_NAME.value, community_channel_name)

def edit_community_channel(self, new_community_channel_name: str):
[bannerLoaded, _] = is_loaded_visible_and_enabled(MainUi.MODULE_WARNING_BANNER.value)
if (bannerLoaded):
time.sleep(5) # Wait for the banner to disappear otherwise the click might land badly
wait_for_banner_to_disappear()

click_obj_by_name(CommunityScreenComponents.CHAT_MORE_OPTIONS_BUTTON.value)
click_obj_by_name(CommunityScreenComponents.EDIT_CHANNEL_MENU_ITEM.value)
Expand All @@ -100,23 +103,23 @@ def edit_community(self, new_community_name: str, new_community_description: str
# Select all text in the input before typing
wait_for_object_and_type(CommunitySettingsComponents.EDIT_COMMUNITY_NAME_INPUT.value, "<Ctrl+a>")
type(CommunitySettingsComponents.EDIT_COMMUNITY_NAME_INPUT.value, new_community_name)

wait_for_object_and_type(CommunitySettingsComponents.EDIT_COMMUNITY_DESCRIPTION_INPUT.value, "<Ctrl+a>")
type(CommunitySettingsComponents.EDIT_COMMUNITY_DESCRIPTION_INPUT.value, new_community_description)

scroll_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_SCROLL_VIEW.value)
time.sleep(1)
scroll_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_SCROLL_VIEW.value)
time.sleep(1)

click_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_COLOR_PICKER_BUTTON.value)
wait_for_object_and_type(CommunityColorPanelComponents.HEX_COLOR_INPUT.value, "<Ctrl+a>")
type(CommunityColorPanelComponents.HEX_COLOR_INPUT.value, new_community_color)
click_obj_by_name(CommunityColorPanelComponents.SAVE_COLOR_BUTTON.value)

click_obj_by_name(CommunitySettingsComponents.SAVE_BUTTON.value)
time.sleep(0.5)

# Validation
verify_text_matching(CommunitySettingsComponents.COMMUNITY_NAME_TEXT.value, new_community_name)
verify_text_matching(CommunitySettingsComponents.COMMUNITY_DESCRIPTION_TEXT.value, new_community_description)
Expand All @@ -125,3 +128,21 @@ def edit_community(self, new_community_name: str, new_community_description: str

def go_back_to_community(self):
click_obj_by_name(CommunitySettingsComponents.BACK_TO_COMMUNITY_BUTTON.value)

def delete_current_community_channel(self):
wait_for_banner_to_disappear()

click_obj_by_name(CommunityScreenComponents.CHAT_MORE_OPTIONS_BUTTON.value)
click_obj_by_name(CommunityScreenComponents.DELETE_CHANNEL_MENU_ITEM.value)
click_obj_by_name(CommunityScreenComponents.DELETE_CHANNEL_CONFIRMATION_DIALOG_DELETE_BUTTON.value)

def check_channel_count(self, count_to_check: int):
chatListObj = get_obj(CommunityScreenComponents.NOT_CATEGORIZED_CHAT_LIST.value)
# Squish doesn't follow the type hints when parsing gherkin values
verify_equals(chatListObj.statusChatListItems.count, int(count_to_check))

# Wait for the banner to disappear otherwise the click might land badly
def wait_for_banner_to_disappear():
[bannerLoaded, _] = is_loaded_visible_and_enabled(MainUi.MODULE_WARNING_BANNER.value)
if (bannerLoaded):
time.sleep(5)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
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}
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}
mainWindow_communityColumnView_statusChatList = {"container": mainWindow_communityColumnView_CommunityColumnView, "objectName": "statusChatListAndCategoriesChatList", "type": "StatusChatList"}
delete_Channel_ConfirmationDialog_DeleteButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton"}

# Community channel popup:
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def step(context: any):
_statusMainScreen.open_community_portal()

@Then("the user lands on the community portal section")
def step(context):
def step(context):
StatusCommunityPortalScreen()

@When("the user creates a community named |any|, with description |any|, intro |any| and outro |any|")
Expand All @@ -24,17 +24,17 @@ def step(context, community_name, community_description, community_intro, commun
def step(context, community_name):
StatusCommunityScreen()
_statusCommunityScreen.verify_community_name(community_name)

@When("the admin creates a community channel named |any|, with description |any| with the method |any|")
def step(context, community_channel_name, community_channel_description, method):
_statusCommunityScreen.create_community_channel(community_channel_name, community_channel_description, method)

@When("the admin edits the current community channel to the name |any|")
def step(context, new_community_channel_name):
_statusCommunityScreen.edit_community_channel(new_community_channel_name)

@Then("the user lands on the community channel named |any|")
def step(context, community_channel_name):
def step(context, community_channel_name):
_statusCommunityScreen.verify_channel_name(community_channel_name)

@When("the admin edits the current community to the name |any| and description |any| and color |any|")
Expand All @@ -44,4 +44,11 @@ def step(context, new_community_name, new_community_description, new_community_c
@When("the admin goes back to the community")
def step(context):
_statusCommunityScreen.go_back_to_community()


@When("the admin deletes current channel")
def step(context):
_statusCommunityScreen.delete_current_community_channel()

@Then("the channel count is |any|")
def step(context, community_channel_count: int):
_statusCommunityScreen.check_channel_count(community_channel_count)
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ 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
2 changes: 1 addition & 1 deletion ui/StatusQ
8 changes: 5 additions & 3 deletions ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,15 @@ StatusPopupMenu {
text: qsTr("Download")
enabled: localAccountSensitiveSettings.downloadChannelMessagesEnabled
icon.name: "download"
onTriggered: downdloadDialog.open()
onTriggered: downloadDialog.open()
}

StatusMenuSeparator {
visible: deleteOrLeaveMenuItem.enabled
}

StatusMenuItem {
objectName: "deleteOrLeaveMenuItem"
id: deleteOrLeaveMenuItem
text: {
if (root.isCommunityChat) {
Expand Down Expand Up @@ -250,21 +251,22 @@ StatusPopupMenu {
}

FileDialog {
id: downdloadDialog
id: downloadDialog
acceptLabel: qsTr("Save")
fileMode: FileDialog.SaveFile
title: qsTr("Download messages")
currentFile: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/messages.json"
defaultSuffix: "json"

onAccepted: {
root.downloadMessages(downdloadDialog.currentFile)
root.downloadMessages(downloadDialog.currentFile)
}
}

Component {
id: deleteChatConfirmationDialogComponent
ConfirmationDialog {
confirmButtonObjectName: "deleteChatConfirmationDialogDeleteButton"
btnType: "warn"
header.title: root.isCommunityChat ? qsTr("Delete #%1").arg(root.chatName) :
root.chatType === Constants.chatType.oneToOne ?
Expand Down

0 comments on commit 5fb4c7f

Please sign in to comment.