fix(tests): Fixed message reply test

This commit is contained in:
Igor Sirotin 2022-08-25 11:27:20 +03:00 committed by Igor Sirotin
parent e020466362
commit 41910c9a8a
7 changed files with 57 additions and 27 deletions

View File

@ -151,6 +151,14 @@ def right_click_obj_by_name(objName: str):
def hover_obj(obj): def hover_obj(obj):
squish.mouseMove(obj) squish.mouseMove(obj)
def move_mouse_over_object(obj):
# Start moving the cursor:
end_x = obj.x + (obj.width / 2)
y = round(int(obj.height) / 2)
x = 0
while x < end_x:
squish.mouseMove(obj, x, y)
x += 10
def scroll_obj_by_name(objName: str): def scroll_obj_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))

View File

@ -109,3 +109,6 @@ def verify_screenshot(vp: str):
def imagePresent(imageName: str, tolerant: bool = True, threshold: int = 99.5, minScale: int = 50, maxScale: int = 200, multiscale: bool = True): def imagePresent(imageName: str, tolerant: bool = True, threshold: int = 99.5, minScale: int = 50, maxScale: int = 200, multiscale: bool = True):
test.imagePresent(imageName, {"tolerant": tolerant, "threshold": threshold, "minScale": minScale, "maxScale": maxScale, "multiscale": multiscale}) test.imagePresent(imageName, {"tolerant": tolerant, "threshold": threshold, "minScale": minScale, "maxScale": maxScale, "multiscale": multiscale})
def passes(text: str):
test.passes(text)

View File

@ -43,6 +43,7 @@ class ChatComponents(Enum):
TOOLBAR_INFO_BUTTON = "chatView_StatusChatInfoButton" TOOLBAR_INFO_BUTTON = "chatView_StatusChatInfoButton"
CHAT_LOG = "chatView_log" CHAT_LOG = "chatView_log"
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text" LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
LAST_MESSAGE = "chatView_chatLogView_lastMsg_MessageView"
MEMBERS_LISTVIEW = "chatView_chatMembers_ListView" MEMBERS_LISTVIEW = "chatView_chatMembers_ListView"
REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton" REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton"
EDIT_MESSAGE_BUTTON = "chatView_editMessageButton" EDIT_MESSAGE_BUTTON = "chatView_editMessageButton"
@ -72,6 +73,10 @@ class ChatStickerPopup(Enum):
MODAL_CLOSE_BUTTON = "modal_Close_Button" MODAL_CLOSE_BUTTON = "modal_Close_Button"
STICKER_LIST_GRID = "chat_StickersPopup_StickerList_Grid" STICKER_LIST_GRID = "chat_StickersPopup_StickerList_Grid"
class ChatItems(Enum):
STATUS_MESSAGE_TEXT_MESSAGE = "StatusMessage_textMessage"
STATUS_TEXT_MESSAGE_CHAT_TEXT = "StatusTextMessage_chatText"
class ChatMessagesHistory(Enum): class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1 CHAT_CREATED_TEXT = 1
HAS_ADDED_TEXT = 0 HAS_ADDED_TEXT = 0
@ -87,7 +92,11 @@ class StatusChatScreen:
verify_screen(ChatComponents.TOOLBAR_INFO_BUTTON.value) verify_screen(ChatComponents.TOOLBAR_INFO_BUTTON.value)
def chat_loaded(self): def chat_loaded(self):
verify(is_displayed(ChatComponents.LAST_MESSAGE_TEXT.value), "Checking chat is loaded by looking if last message is displayed.") verify(is_displayed(ChatComponents.LAST_MESSAGE.value), "Checking chat is loaded by looking if last message is displayed.")
def get_message_at_index(self, index: int):
obj = wait_and_get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index))
return obj
# Screen actions region: # Screen actions region:
def type_message_in_chat_input(self, message: str): def type_message_in_chat_input(self, message: str):
@ -107,7 +116,7 @@ class StatusChatScreen:
# Verifications region: # Verifications region:
def verify_last_message_is_not_loaded(self): def verify_last_message_is_not_loaded(self):
[loaded, _] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value) [loaded, _] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value)
verify_fasle(loaded, "Success: No message was found") verify_false(loaded, "Success: No message was found")
def send_gif(self): def send_gif(self):
click_obj_by_name(ChatComponents.GIF_POPUP_BUTTON.value) click_obj_by_name(ChatComponents.GIF_POPUP_BUTTON.value)
@ -120,16 +129,24 @@ class StatusChatScreen:
# Verifications region: # Verifications region:
def verify_last_message_sent(self, message: str): def verify_last_message_sent(self, message: str):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value) # Get the message text
verify(loaded, "Checking last message sent: " + message) # We don't search for StatusTextMessage_chatText directly, because there're 2 instances of it in a reply message
verify_text_contains(str(last_message_obj.text), str(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]
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): def verify_last_message_sent_is_not(self, message: str):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value) chat_log_obj = wait_and_get_obj(ChatComponents.CHAT_LOG.value)
if not loaded: last_message_obj = chat_log_obj.itemAtIndex(int(0))
test.passes("Success: No message was found") text_message_objs = getChildrenWithObjectName(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)
if len(text_message_objs) == 0:
passes("Success: No message was found")
return return
verify_text_does_not_contain(str(last_message_obj.text), str(message)) text_edit_obj = getChildrenWithObjectName(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))
# This method expects to have just one mention / link in the last chat message # This method expects to have just one mention / link in the last chat message
def verify_last_message_sent_contains_mention(self, displayName: str, message: str): def verify_last_message_sent_contains_mention(self, displayName: str, message: str):
@ -177,19 +194,20 @@ class StatusChatScreen:
# NOTE: It is expecting a specific log order and will succeed only just after the chat is created and no messages have been sent. # NOTE: It is expecting a specific log order and will succeed only just after the chat is created and no messages have been sent.
# TODO: Improvement --> Iterate through the complete history, check all messages and verify the `createdTxt` is displayed. # TODO: Improvement --> Iterate through the complete history, check all messages and verify the `createdTxt` is displayed.
def verify_added_members_message_is_displayed_in_history(self, members): def verify_added_members_message_is_displayed_in_history(self, members):
chat_membersAdded_text_obj = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(ChatMessagesHistory.HAS_ADDED_TEXT.value) chat_membersAdded_text_obj = self.get_message_at_index(ChatMessagesHistory.HAS_ADDED_TEXT.value)
for member in members[0:]: for member in members[0:]:
verify_text_contains(str(chat_membersAdded_text_obj.message), member[0]) verify_text_contains(str(chat_membersAdded_text_obj.message), member[0])
# NOTE: It is expecting a specific log order and will succeed only just after the chat is created and no messages have been sent. # NOTE: It is expecting a specific log order and will succeed only just after the chat is created and no messages have been sent.
# TODO: Improvement --> Iterate through the complete history, check all messages and verify the `createdTxt` is displayed. # TODO: Improvement --> Iterate through the complete history, check all messages and verify the `createdTxt` is displayed.
def verify_chat_created_message_is_displayed_in_history(self, createdTxt: str): def verify_chat_created_message_is_displayed_in_history(self, createdTxt: str):
chat_createChat_text_obj = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(ChatMessagesHistory.CHAT_CREATED_TEXT.value) chat_createChat_text_obj = self.get_message_at_index(ChatMessagesHistory.CHAT_CREATED_TEXT.value)
verify_text_contains(str(chat_createChat_text_obj.message), createdTxt) verify_text_contains(str(chat_createChat_text_obj.message), createdTxt)
def reply_to_message_at_index(self, index: int, message: str): def reply_to_message_at_index(self, index: int, message: str):
message_object_to_reply_to = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index)) message_object_to_reply_to = self.get_message_at_index(index)
hover_obj(message_object_to_reply_to) 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) click_obj_by_name(ChatComponents.REPLY_TO_MESSAGE_BUTTON.value)
self.send_message(message) self.send_message(message)
@ -214,13 +232,13 @@ class StatusChatScreen:
return found return found
def delete_message_at_index(self, index: int): def delete_message_at_index(self, index: int):
message_object_to_delete = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index)) message_object_to_delete = self.get_message_at_index(index)
hover_obj(message_object_to_delete) move_mouse_over_object(message_object_to_delete)
click_obj_by_name(ChatComponents.DELETE_MESSAGE_BUTTON.value) click_obj_by_name(ChatComponents.DELETE_MESSAGE_BUTTON.value)
click_obj_by_name(ChatComponents.CONFIRM_DELETE_MESSAGE_BUTTON.value) click_obj_by_name(ChatComponents.CONFIRM_DELETE_MESSAGE_BUTTON.value)
def cannot_delete_last_message(self): def cannot_delete_last_message(self):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value) [loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE.value)
if not loaded: if not loaded:
verify_failure("No message found") verify_failure("No message found")
return return

View File

@ -7,7 +7,7 @@ mainWindow_scrollView_ScrollView = {"container": statusDesktop_mainWindow, "id":
chatView_messageInput = {"container": statusDesktop_mainWindow, "objectName": "messageInputField", "type": "TextArea", "visible": True} chatView_messageInput = {"container": statusDesktop_mainWindow, "objectName": "messageInputField", "type": "TextArea", "visible": True}
chatView_chatLogView_lastMsg_MessageView = {"container": chatView_log, "index": 0, "type": "MessageView"} 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_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "type": "TextEdit", "objectName": "StatusTextMessage_chatText", "visible": True}
chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton"} chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton", "visible": True}
chatView_editMessageButton = {"container": chatView_log, "objectName": "editMessageButton", "type": "StatusFlatRoundButton"} chatView_editMessageButton = {"container": chatView_log, "objectName": "editMessageButton", "type": "StatusFlatRoundButton"}
chatView_editMessageInputComponent = {"container": statusDesktop_mainWindow, "objectName": "editMessageInput", "type": "StatusChatInput", "visible": True} chatView_editMessageInputComponent = {"container": statusDesktop_mainWindow, "objectName": "editMessageInput", "type": "StatusChatInput", "visible": True}
chatView_editMessageInputTextArea = {"container": chatView_editMessageInputComponent, "objectName": "messageInputField", "type": "TextArea", "visible": True} chatView_editMessageInputTextArea = {"container": chatView_editMessageInputComponent, "objectName": "messageInputField", "type": "TextArea", "visible": True}

View File

@ -26,9 +26,7 @@ Feature: Status Desktop Chat
Scenario: User can reply to their own message Scenario: User can reply to their own message
When user joins chat room test When user joins chat room test
Then user is able to send chat message Then the user is able to send a random chat message
| message |
| Reply to this |
Then the user can reply to the message at index 0 with "This is a reply" Then the user can reply to the message at index 0 with "This is a reply"
Scenario: User can edit a message Scenario: User can edit a message
@ -36,7 +34,7 @@ Feature: Status Desktop Chat
Then user is able to send chat message Then user is able to send chat message
| message | | message |
| Edit me | | Edit me |
When the user edits the message at index 0 and changes it to "Edited by me" When the user edits the message at index 0 and changes it to "Edited by me"
Then the message (edited) is displayed in the last message Then the message (edited) is displayed in the last message
@ -68,7 +66,7 @@ Feature: Status Desktop Chat
| tell me how you do? | | tell me how you do? |
When the user clears chat history When the user clears chat history
Then the chat is cleared Then the chat is cleared
Scenario: User can send a gif Scenario: User can send a gif
When the user opens app settings screen When the user opens app settings screen
And the user opens the messaging settings And the user opens the messaging settings
@ -76,13 +74,13 @@ Feature: Status Desktop Chat
And the user opens the chat section And the user opens the chat section
And user joins chat room automation-test And user joins chat room automation-test
Then The user is able to send a gif message Then The user is able to send a gif message
Scenario: The user is able to use emoji suggestions Scenario: The user is able to use emoji suggestions
When user joins chat room automation-test When user joins chat room automation-test
When the user types "hello :thumbs" When the user types "hello :thumbs"
Then the user selects emoji in the suggestion list Then the user selects emoji in the suggestion list
When the user pressed enter When the user pressed enter
Then then the message 👍 is displayed in the last message Then the message 👍 is displayed in the last message
@mayfail @mayfail
@ -127,12 +125,12 @@ Feature: Status Desktop Chat
| second-chat | | second-chat |
| first-chat | | first-chat |
When user switches to second-chat chat When user switches to second-chat chat
Then the user is able to send a random chat message Then the user is able to send a random chat message
And user chats are sorted accordingly And user chats are sorted accordingly
| second-chat | | second-chat |
| third-chat | | third-chat |
| first-chat | | first-chat |
Scenario: User can type message with emoji autoreplace Scenario: User can type message with emoji autoreplace
When user joins chat room automation-test When user joins chat room automation-test
Then the user is able to send chat message "Hello :)" Then the user is able to send chat message "Hello :)"

View File

@ -45,7 +45,7 @@ Feature: Search feature (ctrl+F)
Scenario: User can search for a message in a public channel Scenario: User can search for a message in a public channel
When the user opens the chat section When the user opens the chat section
And user joins chat room search-automation-test-1 And user joins chat room search-automation-test-1
Then the user is able to send a random chat message Then the user is able to send a random chat message
# Go back to the portal so that we see if the search really redirects # Go back to the portal so that we see if the search really redirects
When the user opens the community portal section When the user opens the community portal section
And the user opens the search menu And the user opens the search menu

View File

@ -668,6 +668,7 @@ Loader {
Loader { Loader {
active: !root.isInPinnedPopup active: !root.isInPinnedPopup
sourceComponent: StatusFlatRoundButton { sourceComponent: StatusFlatRoundButton {
objectName: "replyToMessageButton"
width: d.chatButtonSize width: d.chatButtonSize
height: d.chatButtonSize height: d.chatButtonSize
icon.name: "reply" icon.name: "reply"
@ -758,6 +759,7 @@ Loader {
messageContentType === Constants.messageContentType.audioType); messageContentType === Constants.messageContentType.audioType);
} }
sourceComponent: StatusFlatRoundButton { sourceComponent: StatusFlatRoundButton {
objectName: "chatDeleteMessageButton"
width: d.chatButtonSize width: d.chatButtonSize
height: d.chatButtonSize height: d.chatButtonSize
icon.name: "delete" icon.name: "delete"
@ -781,6 +783,7 @@ Loader {
id: deleteMessageConfirmationDialogComponent id: deleteMessageConfirmationDialogComponent
ConfirmationDialog { ConfirmationDialog {
confirmButtonObjectName: "chatButtonsPanelConfirmDeleteMessageButton"
header.title: qsTrId("Confirm deleting this message") header.title: qsTrId("Confirm deleting this message")
confirmationText: qsTrId("Are you sure you want to delete this message? Be aware that other clients are not guaranteed to delete the message as well.") confirmationText: qsTrId("Are you sure you want to delete this message? Be aware that other clients are not guaranteed to delete the message as well.")
height: 260 height: 260