test(chat): Can edit a message and save

Closes: #6877
This commit is contained in:
Boris Melnik 2022-08-12 16:10:20 +03:00
parent f2dea729a1
commit c7efbe6629
5 changed files with 29 additions and 0 deletions

View File

@ -44,6 +44,7 @@ class ChatComponents(Enum):
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
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"
@ -54,6 +55,8 @@ class ChatComponents(Enum):
CHAT_LIST = "chatList_Repeater"
MORE_OPTIONS_BUTTON = "chatView_ChatToolbarMoreOptionsButton"
CLEAR_HISTORY_MENUITEM = "clearHistoryMenuItem"
EDIT_MESSAGE_INPUT = "chatView_editMessageInputComponent"
EDIT_MESSAGE_TEXTAREA = "chatView_editMessageInputTextArea"
class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1
@ -156,6 +159,14 @@ class StatusChatScreen:
click_obj_by_name(ChatComponents.REPLY_TO_MESSAGE_BUTTON.value)
self.send_message(message)
def edit_message_at_index(self, index: int, message: str):
message_object_to_edit = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index))
hover_obj(message_object_to_edit)
click_obj_by_name(ChatComponents.EDIT_MESSAGE_BUTTON.value)
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)
# TODO: Find ADMIN
def find_member_in_panel(self, member: str):
found = False

View File

@ -8,6 +8,9 @@ chatView_messageInput = {"container": statusDesktop_mainWindow, "objectName": "m
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"}
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}

View File

@ -81,6 +81,11 @@ def step(context, message):
def step(context, message_index, message):
_statusChat.reply_to_message_at_index(message_index, message)
_statusChat.verify_last_message_sent(message)
@When("the user edits the message at index |any| and changes it to \"|any|\"" )
def step(context, message_index, message):
_statusChat.edit_message_at_index(message_index, message)
_statusChat.verify_last_message_sent(message)
@Then("the user can mark the channel |any| as read")
def step(context, channel):

View File

@ -31,6 +31,14 @@ Feature: Status Desktop Chat
| Reply to this |
Then the user can reply to the message at index 0 with "This is a reply"
Scenario: User can edit a message
When user joins chat room test
Then user is able to send chat message
| message |
| Edit 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
@mayfail
Scenario: User can reply to another user's message

View File

@ -586,6 +586,7 @@ Loader {
statusChatInput: StatusChatInput {
id: editTextInput
objectName: "editMessageInput"
readonly property string messageText: editTextInput.textInput.text
@ -684,6 +685,7 @@ Loader {
active: !root.isInPinnedPopup && root.isText && !root.editModeOn && root.amISender
visible: active
sourceComponent: StatusFlatRoundButton {
objectName: "editMessageButton"
width: d.chatButtonSize
height: d.chatButtonSize
icon.name: "edit_pencil"