fix(EmojiPopup): Fix emoji suggestions and add tests for it

Closes: #7020
This commit is contained in:
Boris Melnik 2022-08-17 17:47:06 +03:00
parent 04ce8df483
commit 02b9ceff78
5 changed files with 42 additions and 9 deletions

View File

@ -65,6 +65,9 @@ class ChatComponents(Enum):
class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1
HAS_ADDED_TEXT = 0
class Emoji(Enum):
EMOJI_SUGGESTIONS_FIRST_ELEMENT = "emojiSuggestions_first_inputListRectangle"
class StatusChatScreen:
@ -77,9 +80,15 @@ class StatusChatScreen:
verify(is_displayed(ChatComponents.LAST_MESSAGE_TEXT.value), "Checking chat is loaded by looking if last message is displayed.")
# Screen actions region:
def send_message(self, message: str):
def type_message_in_chat_input(self, message: str):
type(ChatComponents.MESSAGE_INPUT.value, message)
def press_enter_in_chat_input(self):
press_enter(ChatComponents.MESSAGE_INPUT.value)
def send_message(self, message: str):
self.type_message_in_chat_input(message)
self.press_enter_in_chat_input()
def clear_history(self):
click_obj_by_name(ChatComponents.MORE_OPTIONS_BUTTON.value)
@ -96,6 +105,9 @@ class StatusChatScreen:
click_obj_by_name(ChatComponents.GIF_MOUSEAREA.value)
press_enter(ChatComponents.MESSAGE_INPUT.value)
def select_the_emoji_in_suggestion_list(self):
click_obj_by_name(Emoji.EMOJI_SUGGESTIONS_FIRST_ELEMENT.value)
# Verifications region:
def verify_last_message_sent(self, message: str):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value)
@ -212,13 +224,13 @@ class StatusChatScreen:
def cannot_do_mention(self, displayName: str):
self.chat_loaded()
type(ChatComponents.MESSAGE_INPUT.value, _MENTION_SYMBOL + displayName)
self.type_message_in_chat_input(_MENTION_SYMBOL + displayName)
displayed = is_displayed(ChatComponents.SUGGESTIONS_BOX.value)
verify(displayed == False , "Checking suggestion box is not displayed when trying to mention a non existing user.")
def do_mention(self, displayName: str):
self.chat_loaded()
type(ChatComponents.MESSAGE_INPUT.value, _MENTION_SYMBOL + displayName)
self.type_message_in_chat_input(_MENTION_SYMBOL + displayName)
displayed = is_displayed(ChatComponents.SUGGESTIONS_BOX.value)
verify(displayed, "Checking suggestion box displayed when trying to do a mention")
[loaded, suggestions_list] = is_loaded_visible_and_enabled(ChatComponents.SUGGESTIONS_LIST.value)
@ -236,14 +248,13 @@ class StatusChatScreen:
def send_emoji(self, emoji_short_name: str, message: str):
if (message != ""):
type(ChatComponents.MESSAGE_INPUT.value, message)
self.type_message_in_chat_input(message)
click_obj_by_name(ChatComponents.CHAT_INPUT_EMOJI_BUTTON.value)
emojiAttr = copy.deepcopy(getattr(names, ChatComponents.EMOJI_POPUP_EMOJI_PLACEHOLDER.value))
emojiAttr["objectName"] = emojiAttr["objectName"].replace("%NAME%", emoji_short_name)
click_obj_by_attr(emojiAttr)
press_enter(ChatComponents.MESSAGE_INPUT.value)
click_obj_by_attr(emojiAttr)
self.press_enter_in_chat_input()
def verify_chat_order(self, index: int, chatName: str):
chat_lists = get_obj(ChatComponents.CHAT_LIST.value)
@ -264,3 +275,4 @@ class StatusChatScreen:
click_obj(chat)
return
verify(False, "Chat switched")

View File

@ -17,6 +17,7 @@ mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_ove
chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"}
chatView_suggestion_ListView ={"container": chatView_SuggestionBoxPanel, "objectName": "suggestionBoxList", "type": "StatusListView"}
chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overlay, "objectName": "profileView", "type": "ProfileView"}
emojiSuggestions_first_inputListRectangle ={"container": statusDesktop_mainWindow_overlay, "objectName": "inputListRectangle_0", "type": "Rectangle"}
emojiPopup_Emoji_Button_Placeholder = {"container": statusDesktop_mainWindow, "objectName": "statusEmoji_%NAME%", "type": "StatusEmoji", "visible": True}
chatInput_Emoji_Button = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputEmojiButton", "type": "StatusFlatRoundButton", "visible": True}
chatView_ChatToolbarMoreOptionsButton = {"container": statusDesktop_mainWindow, "objectName": "chatToolbarMoreOptionsButton", "type": "StatusFlatRoundButton"}

View File

@ -35,7 +35,15 @@ def step(context,displayName,message):
@When("the user clears chat history")
def step(context):
_statusChat.clear_history()
_statusChat.clear_history()
@When("the user types \"|any|\"")
def step(context, message):
_statusChat.type_message_in_chat_input(message)
@When("the user pressed enter")
def step(context):
_statusChat.press_enter_in_chat_input()
@Then("user is able to send chat message")
def step(context):
@ -48,6 +56,10 @@ def step(context):
def step(context):
_statusChat.send_gif()
_statusChat.verify_last_message_sent("tenor.gif")
@Then("the user selects emoji in the suggestion list")
def step(contenxt):
_statusChat.select_the_emoji_in_suggestion_list()
@Then("the user is able to send a random chat message")
def step(context):

View File

@ -76,6 +76,13 @@ Feature: Status Desktop Chat
And the user opens the chat section
And user joins chat room automation-test
Then The user is able to send a gif message
Scenario: The user is able to use emoji suggestions
When user joins chat room automation-test
When the user types "hello :thumbs"
Then the user selects emoji in the suggestion list
When the user pressed enter
Then then the message 👍 is displayed in the last message
@mayfail

View File

@ -140,9 +140,10 @@ Popup {
anchors.bottom: parent.bottom
delegate: Rectangle {
id: rectangle
objectName: "inputListRectangle_" + index
property variant myData: typeof modelData === "undefined" ? model : modelData
property string myText: popup.getText(myData)
id: rectangle
visible: searchBox.text === "" || myText.includes(searchBox.text)
color: listView.currentIndex === index ? Style.current.backgroundHover : Style.current.transparent
border.width: 0