fix(@desktop/test): Fixing chat flow test

Fixing hover menu problems: reply, edit, delete message.

Fix #7911
This commit is contained in:
Michal Iskierko 2022-11-23 16:15:17 +01:00 committed by Michał Iskierko
parent 8b9b399077
commit 48b2b978e4
6 changed files with 39 additions and 33 deletions

View File

@ -155,6 +155,10 @@ def right_click_obj_by_name(objName: str):
def hover_obj(obj):
squish.mouseMove(obj)
def move_mouse_over_object_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName))
move_mouse_over_object(obj)
def move_mouse_over_object(obj):
# Start moving the cursor:
end_x = obj.x + (obj.width / 2)

View File

@ -45,9 +45,6 @@ class ChatComponents(Enum):
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
LAST_MESSAGE = "chatView_chatLogView_lastMsg_MessageView"
MEMBERS_LISTVIEW = "chatView_chatMembers_ListView"
REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton"
EDIT_MESSAGE_BUTTON = "chatView_editMessageButton"
DELETE_MESSAGE_BUTTON = "chatView_DeleteMessageButton"
CONFIRM_DELETE_MESSAGE_BUTTON = "chatButtonsPanelConfirmDeleteMessageButton_StatusButton"
SUGGESTIONS_BOX = "chatView_SuggestionBoxPanel"
SUGGESTIONS_LIST = "chatView_suggestion_ListView"
@ -92,6 +89,11 @@ class ChatItems(Enum):
class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1
HAS_ADDED_TEXT = 0
class ChatMessageHoverMenu(Enum):
REPLY_TO_BUTTON = "replyToMessageButton"
EDIT_BUTTON = "editMessageButton"
DELETE_BUTTON = "chatDeleteMessageButton"
class Emoji(Enum):
EMOJI_SUGGESTIONS_FIRST_ELEMENT = "emojiSuggestions_first_inputListRectangle"
@ -193,13 +195,20 @@ class StatusChatScreen:
message_object_to_reply_to = self.get_message_at_index(index)
verify(not is_null(message_object_to_reply_to), "Message to reply to is loaded")
move_mouse_over_object(message_object_to_reply_to)
click_obj_by_name(ChatComponents.REPLY_TO_MESSAGE_BUTTON.value)
found_reply_to_button = get_children_with_object_name(message_object_to_reply_to, ChatMessageHoverMenu.REPLY_TO_BUTTON.value)[0]
verify(not is_null(found_reply_to_button), "Reply button found")
move_mouse_over_object(found_reply_to_button)
click_obj(found_reply_to_button)
self.send_message(message)
def edit_message_at_index(self, index: int, message: str):
message_object_to_edit = wait_and_get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index))
verify(not is_null(message_object_to_edit), "Message to edit is loaded")
move_mouse_over_object(message_object_to_edit)
click_obj_by_name(ChatComponents.EDIT_MESSAGE_BUTTON.value)
found_edit_button = get_children_with_object_name(message_object_to_edit, ChatMessageHoverMenu.EDIT_BUTTON.value)[0]
verify(not is_null(found_edit_button), "Edit button found")
move_mouse_over_object(found_edit_button)
click_obj(found_edit_button)
wait_for_object_and_type(ChatComponents.EDIT_MESSAGE_TEXTAREA.value, "<Ctrl+a>")
type(ChatComponents.EDIT_MESSAGE_TEXTAREA.value, message)
press_enter(ChatComponents.EDIT_MESSAGE_TEXTAREA.value)
@ -209,7 +218,7 @@ class StatusChatScreen:
verify(chat_lists.count > 0, "At least one chat exists")
for i in range(chat_lists.count):
chat = chat_lists.itemAt(i)
chat_list_items = getChildrenWithObjectName(chat, "chatItem")
chat_list_items = get_children_with_object_name(chat, "chatItem")
verify(len(chat_list_items) > 0, "StatusChatListItem exists")
if str(chat_list_items[0].name) == chatName:
click_obj(chat)
@ -231,7 +240,10 @@ class StatusChatScreen:
def delete_message_at_index(self, index: int):
message_object_to_delete = self.get_message_at_index(index)
move_mouse_over_object(message_object_to_delete)
click_obj_by_name(ChatComponents.DELETE_MESSAGE_BUTTON.value)
found_delete_button = get_children_with_object_name(message_object_to_delete, ChatMessageHoverMenu.DELETE_BUTTON.value)[0]
verify(not is_null(found_delete_button), "Delete button found")
move_mouse_over_object(found_delete_button)
click_obj(found_delete_button)
click_obj_by_name(ChatComponents.CONFIRM_DELETE_MESSAGE_BUTTON.value)
def cannot_delete_last_message(self):
@ -239,8 +251,9 @@ class StatusChatScreen:
if not loaded:
verify_failure("No message found")
return
hover_obj(last_message_obj)
object_not_enabled(ChatComponents.DELETE_MESSAGE_BUTTON.value)
move_mouse_over_object(last_message_obj)
found_delete_button = get_children_with_object_name(last_message_obj, ChatMessageHoverMenu.DELETE_BUTTON.value)[0]
verify_false(is_visible_and_enabled(found_delete_button), "Delete button is hidden")
def send_message_with_mention(self, displayName: str, message: str):
self.do_mention(displayName)
@ -340,19 +353,19 @@ class StatusChatScreen:
def verify_last_message_is_reply(self, message: str):
last_message_obj = self.get_message_at_index(0)
last_message_reply_details_obj = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
last_message_reply_details_obj = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
verify(not is_null(last_message_reply_details_obj), "Checking last message is a reply: " + message)
def verify_last_message_is_reply_to(self, reply: str, message: str):
last_message_obj = self.get_message_at_index(0)
last_message_reply_details_obj = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
text_message_obj = getChildrenWithObjectName(last_message_reply_details_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS_TEXT_MESSAGE.value)[0]
last_message_reply_details_obj = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
text_message_obj = get_children_with_object_name(last_message_reply_details_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS_TEXT_MESSAGE.value)[0]
verify_text_contains(str(text_message_obj.messageDetails.messageText), str(message))
def verify_last_message_is_reply_to_loggedin_user_message(self, reply: str, message: str):
last_message_obj = self.get_message_at_index(0)
last_message_reply_details_obj = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
text_message_obj = getChildrenWithObjectName(last_message_reply_details_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS_TEXT_MESSAGE.value)[0]
last_message_reply_details_obj = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS.value)[0]
text_message_obj = get_children_with_object_name(last_message_reply_details_obj, ChatItems.STATUS_MESSAGE_REPLY_DETAILS_TEXT_MESSAGE.value)[0]
verify_text_contains(str(text_message_obj.messageDetails.messageText), str(message))
verify_values_equal(str(last_message_reply_details_obj.replyDetails.sender.id), str(last_message_obj.senderId), "Message sender ID doesn't match reply message sender ID")
@ -365,19 +378,18 @@ class StatusChatScreen:
# Get the message text
# We don't search for StatusTextMessage_chatText directly, because there're 2 instances of it in a reply message
last_message_obj = self.get_message_at_index(0)
text_message_obj = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)[0]
text_edit_obj = getChildrenWithObjectName(text_message_obj, ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0]
text_message_obj = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)[0]
text_edit_obj = get_children_with_object_name(text_message_obj, ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0]
verify(not is_null(text_edit_obj), "Checking last message sent: " + message)
verify_text_contains(str(text_edit_obj.text), str(message))
def verify_last_message_sent_is_not(self, message: str):
chat_log_obj = wait_and_get_obj(ChatComponents.CHAT_LOG.value)
last_message_obj = chat_log_obj.itemAtIndex(int(0))
text_message_objs = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)
last_message_obj = self.get_message_at_index(0)
text_message_objs = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)
if len(text_message_objs) == 0:
passes("Success: No message was found")
return
text_edit_obj = getChildrenWithObjectName(text_message_objs[0], ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0]
text_edit_obj = get_children_with_object_name(text_message_objs[0], ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0]
verify(not is_null(text_edit_obj), "Checking last message sent: " + message)
verify_text_does_not_contain(str(text_edit_obj.text), str(message))
@ -453,7 +465,7 @@ class StatusChatScreen:
chat_lists = get_obj(ChatComponents.CHAT_LIST.value)
chat = chat_lists.itemAt(index)
verify(not is_null(chat), "Chat ({}) at index {} exists".format(chatName, index))
chat_list_items = getChildrenWithObjectName(chat, "chatItem")
chat_list_items = get_children_with_object_name(chat, "chatItem")
verify(len(chat_list_items) > 0, "StatusChatListItem exists")
verify(str(chat_list_items[0].name) == chatName, "Chat in order")

View File

@ -10,11 +10,11 @@ def getChildrenOfType(parent, typename, depth=1000):
children.extend(getChildrenOfType(child, typename, depth - 1))
return children
def getChildrenWithObjectName(parent, objectName, depth=1000):
def get_children_with_object_name(parent, objectName, depth=1000):
children = []
for child in object.children(parent):
if child.objectName == objectName:
children.append(child)
if depth:
children.extend(getChildrenWithObjectName(child, objectName, depth - 1))
children.extend(get_children_with_object_name(child, objectName, depth - 1))
return children

View File

@ -3,7 +3,6 @@ statusDesktop_mainWindow = {"name": "mainWindow", "type": "StatusWindow", "visib
statusDesktop_mainWindow_overlay = {"container": statusDesktop_mainWindow, "type": "Overlay", "unnamed": 1, "visible": True}
mainWindow_navBarListView_ListView = {"container": statusDesktop_mainWindow, "objectName": "statusMainNavBarListView", "type": "ListView", "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}
secureSeedPhrase_Banner = {"container": statusDesktop_mainWindow, "objectName": "secureYourSeedPhraseBanner", "type": "ModuleWarning"}
connectionInfo_Banner = {"container": statusDesktop_mainWindow, "objectName": "connectionInfoBanner", "type": "ModuleWarning"}
appVersionUpdate_Banner = {"container": statusDesktop_mainWindow, "objectName": "appVersionUpdateBanner", "type": "ModuleWarning"}

View File

@ -4,11 +4,8 @@ from scripts.global_names import *
mainWindow_scrollView_ScrollView = {"container": statusDesktop_mainWindow, "id": "scrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True}
chatView_chatLogView_lastMsg_MessageView = {"container": chatView_log, "index": 0, "type": "MessageView"}
chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "type": "TextEdit", "objectName": "StatusTextMessage_chatText", "visible": True}
chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton", "visible": True}
chatView_editMessageButton = {"container": chatView_log, "objectName": "editMessageButton", "type": "StatusFlatRoundButton"}
chatView_editMessageInputComponent = {"container": statusDesktop_mainWindow, "objectName": "editMessageInput", "type": "StatusChatInput", "visible": True}
chatView_editMessageInputTextArea = {"container": chatView_editMessageInputComponent, "objectName": "messageInputField", "type": "TextArea", "visible": True}
chatView_DeleteMessageButton = {"container": chatView_log, "objectName": "chatDeleteMessageButton", "type": "StatusFlatRoundButton"}
chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "type": "StatusButton"}
mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
chat_Input_Stickers_Button = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputStickersButton", "type": "StatusFlatRoundButton", "visible": True}

View File

@ -24,8 +24,6 @@ Feature: Status Desktop Chat Basic Flows
| I am from status |
| tell me how you do? |
@mayfail
# TODO: It works standalone but when it runs as part of the sequence, the action of reply is not done always. The popup option does not appear.
Scenario Outline: The user can reply to own message
Given the user sends a chat message "<message>"
When the user replies to the message at index 0 with "<reply>"
@ -34,8 +32,6 @@ Feature: Status Desktop Chat Basic Flows
| message | reply |
| random chat message | This is a reply |
@mayfail
# TODO: It works standalone but when it runs as part of the sequence, the action of edit is not done always. The popup option does not appear.
Scenario Outline: The user can edit a message
Given the user sends a chat message "Edit me"
When the user edits the message at index 0 and changes it to "<edited>"
@ -58,8 +54,6 @@ Feature: Status Desktop Chat Basic Flows
# And the user marks the channel "test" as read
# # TODO find a way to validate that it worked
@mayfail
# TODO: It works standalone but when it runs as part of the sequence, the action of delete is not done always. The popup option does not appear.
Scenario Outline: The user can delete his/her own message
Given the user sends a chat message "<message>"
When the user deletes the message at index 0