test(Communities): can change the emoji of a community channel

Closes #6887
This commit is contained in:
Stefan 2022-08-15 13:43:38 +02:00 committed by Stefan Dunca
parent e33fdafc68
commit 057c0ee1c9
11 changed files with 88 additions and 14 deletions

View File

@ -17,6 +17,10 @@ import object
import names import names
import test import test
from objectmaphelper import Wildcard
import copy
# The default maximum timeout to find ui object # The default maximum timeout to find ui object
_MAX_WAIT_OBJ_TIMEOUT = 5000 _MAX_WAIT_OBJ_TIMEOUT = 5000
@ -96,6 +100,10 @@ def get_obj(objName: str):
obj = squish.findObject(getattr(names, objName)) obj = squish.findObject(getattr(names, objName))
return obj return obj
def wait_and_get_obj(objName: str):
obj = squish.waitForObject(getattr(names, objName))
return obj
def get_and_click_obj(obj_name: str): def get_and_click_obj(obj_name: str):
click_obj(get_obj(obj_name)) click_obj(get_obj(obj_name))
@ -108,6 +116,13 @@ def click_obj_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
squish.mouseClick(obj, squish.Qt.LeftButton) squish.mouseClick(obj, squish.Qt.LeftButton)
def click_obj_by_wildcards_name(objName: str, wildcardString: str):
wildcardRealName = copy.deepcopy(getattr(names, objName))
wildcardRealName["objectName"] = Wildcard(wildcardString)
obj = squish.waitForObject(wildcardRealName)
squish.mouseClick(obj, squish.Qt.LeftButton)
# It executes the right-click action into object with given object name: # It executes the right-click action into object with given object name:
def right_click_obj_by_name(objName: str): def right_click_obj_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
@ -166,7 +181,7 @@ def wait_for_object_and_type(objName: str, text: str):
return True return True
except LookupError: except LookupError:
return False return False
# Clicking link in label / textedit # Clicking link in label / textedit
def click_link(objName: str, link: str): def click_link(objName: str, link: str):
point = _find_link(getattr(names, objName), link) point = _find_link(getattr(names, objName), link)
@ -211,4 +226,7 @@ def _find_link(objName: str, link: str):
y += 10 y += 10
squish.uninstallSignalHandler(obj, "linkHovered(QString)", "_handle_link_hovered") squish.uninstallSignalHandler(obj, "linkHovered(QString)", "_handle_link_hovered")
return [-1, -1] return [-1, -1]
def expectTrue(assertionValue: bool, message: str):
return test.verify(assertionValue, message)

View File

@ -11,6 +11,8 @@
from enum import Enum from enum import Enum
import time import time
from unittest import TestSuite
from drivers.SquishDriver import * from drivers.SquishDriver import *
from drivers.SquishDriverVerification import * from drivers.SquishDriverVerification import *
from drivers.SDKeyboardCommands import * from drivers.SDKeyboardCommands import *
@ -27,6 +29,7 @@ class CommunityScreenComponents(Enum):
COMMUNITY_CREATE_CHANNEL__MENU_ITEM = "create_channel_StatusMenuItemDelegate" COMMUNITY_CREATE_CHANNEL__MENU_ITEM = "create_channel_StatusMenuItemDelegate"
COMMUNITY_CREATE_CATEGORY__MENU_ITEM = "create_category_StatusMenuItemDelegate" COMMUNITY_CREATE_CATEGORY__MENU_ITEM = "create_category_StatusMenuItemDelegate"
CHAT_IDENTIFIER_CHANNEL_NAME = "msgDelegate_channelIdentifierNameText_StyledText" CHAT_IDENTIFIER_CHANNEL_NAME = "msgDelegate_channelIdentifierNameText_StyledText"
CHAT_IDENTIFIER_CHANNEL_ICON = "mainWindow_chatInfoBtnInHeader_StatusChatInfoButton"
CHAT_MORE_OPTIONS_BUTTON = "chat_moreOptions_menuButton" CHAT_MORE_OPTIONS_BUTTON = "chat_moreOptions_menuButton"
EDIT_CHANNEL_MENU_ITEM = "edit_Channel_StatusMenuItemDelegate" EDIT_CHANNEL_MENU_ITEM = "edit_Channel_StatusMenuItemDelegate"
COMMUNITY_COLUMN_VIEW = "mainWindow_communityColumnView_CommunityColumnView" COMMUNITY_COLUMN_VIEW = "mainWindow_communityColumnView_CommunityColumnView"
@ -54,12 +57,21 @@ class CommunityColorPanelComponents(Enum):
class CreateOrEditCommunityChannelPopup(Enum): class CreateOrEditCommunityChannelPopup(Enum):
COMMUNITY_CHANNEL_NAME_INPUT: str = "createOrEditCommunityChannelNameInput_TextEdit" COMMUNITY_CHANNEL_NAME_INPUT: str = "createOrEditCommunityChannelNameInput_TextEdit"
COMMUNITY_CHANNEL_DESCRIPTION_INPUT: str = "createOrEditCommunityChannelDescriptionInput_TextEdit" COMMUNITY_CHANNEL_DESCRIPTION_INPUT: str = "createOrEditCommunityChannelDescriptionInput_TextEdit"
COMMUNITY_CHANNEL_BUTTON: str = "createOrEditCommunityChannelBtn_StatusButton" COMMUNITY_CHANNEL_SAVE_OR_CREATE_BUTTON: str = "createOrEditCommunityChannelBtn_StatusButton"
EMOJI_BUTTON: str = "createOrEditCommunityChannel_EmojiButton"
EMOJI_SEARCH_TEXT_INPUT: str = "statusDesktop_mainWindow_AppMain_EmojiPopup_SearchTextInput"
EMOJI_POPUP_EMOJI_PLACEHOLDER = "emojiPopup_Emoji_Button_Placeholder"
class StatusCommunityScreen: class StatusCommunityScreen:
def __init__(self): def __init__(self):
verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value) verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)
def open_edit_channel_popup(self):
StatusMainScreen.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)
def verify_community_name(self, communityName: str): def verify_community_name(self, communityName: str):
verify_text_matching(CommunityScreenComponents.COMMUNITY_HEADER_NAME_TEXT.value, communityName) verify_text_matching(CommunityScreenComponents.COMMUNITY_HEADER_NAME_TEXT.value, communityName)
@ -76,22 +88,20 @@ class StatusCommunityScreen:
wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, communityChannelName) wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, communityChannelName)
type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_DESCRIPTION_INPUT.value, communityChannelDescription) 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 click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_SAVE_OR_CREATE_BUTTON.value)
# 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): def verify_channel_name(self, community_channel_name: str):
verify_text_matching(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_NAME.value, community_channel_name) verify_text_matching(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_NAME.value, community_channel_name)
def edit_community_channel(self, new_community_channel_name: str): def edit_community_channel(self, new_community_channel_name: str):
StatusMainScreen.wait_for_banner_to_disappear() self.open_edit_channel_popup()
click_obj_by_name(CommunityScreenComponents.CHAT_MORE_OPTIONS_BUTTON.value)
click_obj_by_name(CommunityScreenComponents.EDIT_CHANNEL_MENU_ITEM.value)
# Select all text in the input before typing # Select all text in the input before typing
wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, "<Ctrl+a>") wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, "<Ctrl+a>")
type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, new_community_channel_name) type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, new_community_channel_name)
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_BUTTON.value) click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_SAVE_OR_CREATE_BUTTON.value)
time.sleep(0.5) time.sleep(0.5)
def edit_community(self, new_community_name: str, new_community_description: str, new_community_color: str): def edit_community(self, new_community_name: str, new_community_description: str, new_community_color: str):
@ -122,7 +132,7 @@ class StatusCommunityScreen:
verify_text_matching(CommunitySettingsComponents.COMMUNITY_NAME_TEXT.value, new_community_name) verify_text_matching(CommunitySettingsComponents.COMMUNITY_NAME_TEXT.value, new_community_name)
verify_text_matching(CommunitySettingsComponents.COMMUNITY_DESCRIPTION_TEXT.value, new_community_description) verify_text_matching(CommunitySettingsComponents.COMMUNITY_DESCRIPTION_TEXT.value, new_community_description)
obj = get_obj(CommunitySettingsComponents.COMMUNITY_LETTER_IDENTICON.value) obj = get_obj(CommunitySettingsComponents.COMMUNITY_LETTER_IDENTICON.value)
test.verify(obj.color.name == new_community_color, "Community color was not changed correctly") expectTrue(obj.color.name == new_community_color, "Community color was not changed correctly")
def go_back_to_community(self): def go_back_to_community(self):
click_obj_by_name(CommunitySettingsComponents.BACK_TO_COMMUNITY_BUTTON.value) click_obj_by_name(CommunitySettingsComponents.BACK_TO_COMMUNITY_BUTTON.value)
@ -138,3 +148,19 @@ class StatusCommunityScreen:
chatListObj = get_obj(CommunityScreenComponents.NOT_CATEGORIZED_CHAT_LIST.value) chatListObj = get_obj(CommunityScreenComponents.NOT_CATEGORIZED_CHAT_LIST.value)
# Squish doesn't follow the type hints when parsing gherkin values # Squish doesn't follow the type hints when parsing gherkin values
verify_equals(chatListObj.statusChatListItems.count, int(count_to_check)) verify_equals(chatListObj.statusChatListItems.count, int(count_to_check))
def search_and_change_community_channel_emoji(self, emoji_description: str):
self.open_edit_channel_popup()
click_obj_by_name(CreateOrEditCommunityChannelPopup.EMOJI_BUTTON.value)
# Search emoji
wait_for_object_and_type(CreateOrEditCommunityChannelPopup.EMOJI_SEARCH_TEXT_INPUT.value, emoji_description)
# Click on the first found emoji button
click_obj_by_wildcards_name(CreateOrEditCommunityChannelPopup.EMOJI_POPUP_EMOJI_PLACEHOLDER.value, "statusEmoji_*")
# save changes
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_SAVE_OR_CREATE_BUTTON.value)
def check_community_channel_emoji(self, emojiStr: str):
obj = wait_and_get_obj(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_ICON.value)
expectTrue(str(obj.icon.emoji).find(emojiStr) >= 0, "Same emoji check")

View File

@ -21,6 +21,8 @@ mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_ove
chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"} chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"}
chatView_suggestion_ListView ={"container": chatView_SuggestionBoxPanel, "objectName": "suggestionBoxList", "type": "StatusListView"} chatView_suggestion_ListView ={"container": chatView_SuggestionBoxPanel, "objectName": "suggestionBoxList", "type": "StatusListView"}
chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overlay, "objectName": "profileView", "type": "ProfileView"} chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overlay, "objectName": "profileView", "type": "ProfileView"}
# This will conflict with Jo's PR. Resolve it on rebase.
emojiPopup_Emoji_Button_Placeholder = {"container": statusDesktop_mainWindow, "objectName": "statusEmoji_%NAME%", "type": "StatusEmoji", "visible": True}
# Join chat popup: # Join chat popup:
startChat_Btn = {"container": statusDesktop_mainWindow_overlay, "objectName": "startChatButton", "type": "StatusButton"} startChat_Btn = {"container": statusDesktop_mainWindow_overlay, "objectName": "startChatButton", "type": "StatusButton"}

View File

@ -14,11 +14,13 @@ msgDelegate_channelIdentifierNameText_StyledText = {"container": chatMessageList
delete_Channel_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItemDelegate", "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"} mainWindow_communityColumnView_statusChatList = {"container": mainWindow_communityColumnView_CommunityColumnView, "objectName": "statusChatListAndCategoriesChatList", "type": "StatusChatList"}
delete_Channel_ConfirmationDialog_DeleteButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton"} delete_Channel_ConfirmationDialog_DeleteButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton"}
mainWindow_chatInfoBtnInHeader_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "chatInfoBtnInHeader", "type": "StatusChatInfoButton", "visible": True}
# Community channel popup: # Community channel popup:``
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True} createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
createOrEditCommunityChannelDescriptionInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelDescriptionInput", "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} 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 settings # Community settings
communitySettings_EditCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsEditCommunityButton", "type": "StatusButton"} communitySettings_EditCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsEditCommunityButton", "type": "StatusButton"}

View File

@ -5,4 +5,4 @@ mainWindow_navBarListView_ListView = {"container": statusDesktop_mainWindow, "ty
chatView_log = {"container": statusDesktop_mainWindow, "objectName": "chatLogView", "type": "StatusListView", "visible": True} chatView_log = {"container": statusDesktop_mainWindow, "objectName": "chatLogView", "type": "StatusListView", "visible": True}
chatMessageListView_msgDelegate_MessageView = {"container": chatView_log, "objectName": "chatMessageViewDelegate", "index": 1, "type": "MessageView", "visible": True} chatMessageListView_msgDelegate_MessageView = {"container": chatView_log, "objectName": "chatMessageViewDelegate", "index": 1, "type": "MessageView", "visible": True}
moduleWarning_Banner = {"container": statusDesktop_mainWindow, "objectName": "moduleWarningBanner", "type": "Rectangle", "visible": True} moduleWarning_Banner = {"container": statusDesktop_mainWindow, "objectName": "moduleWarningBanner", "type": "Rectangle", "visible": True}
statusDesktop_mainWindow_AppMain_EmojiPopup_SearchTextInput = {"container": statusDesktop_mainWindow_overlay, "objectName": "StatusEmojiPopup_searchBox", "type": "TextEdit", "visible": True}

View File

@ -56,3 +56,11 @@ def step(context, community_channel_count: int):
@Then("the count of communities in navbar is |any|") @Then("the count of communities in navbar is |any|")
def step(context: any, expected_count: int): def step(context: any, expected_count: int):
_statusMainScreen.verify_communities_count(expected_count) _statusMainScreen.verify_communities_count(expected_count)
@When("the user changes emoji of the current community channel with emoji by description |any|")
def step(context, emoji_description: str):
_statusCommunityScreen.search_and_change_community_channel_emoji(emoji_description)
@Then("the community channel has emoji |any|")
def step(context, emoji: str):
_statusCommunityScreen.check_community_channel_emoji(emoji)

View File

@ -81,3 +81,15 @@ Feature: Status Desktop community
And the user opens the communities settings And the user opens the communities settings
And the user leaves the community And the user leaves the community
Then the count of communities in navbar is 0 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
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
When the user changes emoji of the current community channel with emoji by description <new_emoji_description>
Then the community channel has emoji <new_emoji>
Examples:
| new_emoji_description | new_emoji |
| thumbs up | 👍 |

View File

@ -117,6 +117,7 @@ StatusDialog {
input.icon.color: colorDialog.color.toString() input.icon.color: colorDialog.color.toString()
rightPadding: 6 rightPadding: 6
input.rightComponent: StatusRoundButton { input.rightComponent: StatusRoundButton {
objectName: "StatusChannelPopup_emojiButton"
implicitWidth: 32 implicitWidth: 32
implicitHeight: 32 implicitHeight: 32
icon.width: 20 icon.width: 20

View File

@ -221,6 +221,7 @@ Popup {
height: searchBox.height + emojiHeader.headerMargin height: searchBox.height + emojiHeader.headerMargin
SearchBox { SearchBox {
input.edit.objectName: "StatusEmojiPopup_searchBox"
id: searchBox id: searchBox
anchors.right: skinToneEmoji.left anchors.right: skinToneEmoji.left
anchors.rightMargin: emojiHeader.headerMargin anchors.rightMargin: emojiHeader.headerMargin

View File

@ -89,6 +89,9 @@ Item {
anchors.leftMargin: emojiSection.imageMargin anchors.leftMargin: emojiSection.imageMargin
StatusEmoji { StatusEmoji {
// TODO: this will conflict with Jo's PR, fix it on rebase
objectName: "statusEmoji_" + modelData.shortname.replace(/:/g, "")
width: emojiSection.imageWidth width: emojiSection.imageWidth
height: emojiSection.imageWidth height: emojiSection.imageWidth
emojiId: modelData.filename emojiId: modelData.filename

View File

@ -23,6 +23,7 @@ Column {
property string chatIcon: "" property string chatIcon: ""
StatusSmartIdenticon { StatusSmartIdenticon {
objectName: "channelIdentifierSmartIdenticon"
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
name: root.chatName name: root.chatName
icon { icon {