test(chat): add test to delete messages

Fixes #6757
This commit is contained in:
Jonathan Rainville 2022-08-02 16:04:29 -04:00
parent 8b4ceec773
commit 03f1fe500b
6 changed files with 67 additions and 4 deletions

View File

@ -30,5 +30,11 @@ def verify_text_contains(text: str, substring: str):
found = True found = True
verify(found, "Given substring: " + substring + " and complete text: " + text) verify(found, "Given substring: " + substring + " and complete text: " + text)
def verify_text_does_not_contain(text: str, substring: str):
found = False
if substring in text:
found = True
verify(not found, "Given substring: " + substring + " and complete text: " + text)
def verify_text(text1: str, text2: str): def verify_text(text1: str, text2: str):
test.compare(text1, text2, "Text 1: " + text1 + "\nText 2: " + text2) test.compare(text1, text2, "Text 1: " + text1 + "\nText 2: " + text2)

View File

@ -13,6 +13,7 @@ from enum import Enum
from drivers.SquishDriver import * from drivers.SquishDriver import *
from drivers.SquishDriverVerification import * from drivers.SquishDriverVerification import *
from drivers.SDKeyboardCommands import * from drivers.SDKeyboardCommands import *
from common.Common import *
class ChatComponents(Enum): class ChatComponents(Enum):
@ -22,6 +23,8 @@ class ChatComponents(Enum):
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text" LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
MEMBERS_LISTVIEW = "chatView_chatMembers_ListView" MEMBERS_LISTVIEW = "chatView_chatMembers_ListView"
REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton" REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton"
DELETE_MESSAGE_BUTTON = "chatView_DeleteMessageButton"
CONFIRM_DELETE_MESSAGE_BUTTON = "chatButtonsPanelConfirmDeleteMessageButton_StatusButton"
class ChatMessagesHistory(Enum): class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1 CHAT_CREATED_TEXT = 1
@ -44,6 +47,13 @@ class StatusChatScreen:
verify(loaded, "Checking last message sent: " + message) verify(loaded, "Checking last message sent: " + message)
verify_text_contains(str(last_message_obj.text), str(message)) verify_text_contains(str(last_message_obj.text), str(message))
def verify_last_message_sent_is_not(self, message: str):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value)
if not loaded:
test.passes("Success: No message was found")
return
verify_text_does_not_contain(str(last_message_obj.text), str(message))
def verify_chat_title(self, title: str): def verify_chat_title(self, title: str):
info_btn = get_obj(ChatComponents.TOOLBAR_INFO_BUTTON.value) info_btn = get_obj(ChatComponents.TOOLBAR_INFO_BUTTON.value)
verify_text(str(info_btn.title), title) verify_text(str(info_btn.title), title)
@ -93,3 +103,17 @@ class StatusChatScreen:
found = True found = True
break break
return found return found
def delete_message_at_index(self, index: int):
message_object_to_delete = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index))
hover_obj(message_object_to_delete)
click_obj_by_name(ChatComponents.DELETE_MESSAGE_BUTTON.value)
click_obj_by_name(ChatComponents.CONFIRM_DELETE_MESSAGE_BUTTON.value)
def cannot_delete_last_message(self):
[loaded, last_message_obj] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value)
if not loaded:
test.fail("No message found")
return
hover_obj(last_message_obj)
object_not_enabled(ChatComponents.DELETE_MESSAGE_BUTTON.value)

View File

@ -14,7 +14,9 @@ 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, "objectName": "chatText", "type": "StyledTextEdit"} chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "objectName": "chatText", "type": "StyledTextEdit"}
chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton", "visible": True} chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton"}
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} mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
# Join chat popup: # Join chat popup:

View File

@ -1,4 +1,5 @@
from drivers.SquishDriver import *
from screens.StatusMainScreen import StatusMainScreen from screens.StatusMainScreen import StatusMainScreen
from screens.StatusChatScreen import StatusChatScreen from screens.StatusChatScreen import StatusChatScreen
from screens.StatusCreateChatScreen import StatusCreateChatScreen from screens.StatusCreateChatScreen import StatusCreateChatScreen
@ -57,3 +58,16 @@ def step(context, message_index, message):
@Then("the user can mark the channel |any| as read") @Then("the user can mark the channel |any| as read")
def step(context, channel): def step(context, channel):
_statusMain.mark_as_read(channel) _statusMain.mark_as_read(channel)
@Then("the user can delete the message at index |any|")
def step(context, message_index):
_statusChat.delete_message_at_index(message_index)
@Then("the user cannot delete the last message")
def step(context):
_statusChat.cannot_delete_last_message()
@Then("the last message is not \"|any|\"")
def step(context, message):
_statusChat.verify_last_message_sent_is_not(message)

View File

@ -41,3 +41,18 @@ Feature: Status Desktop Chat
When user joins chat room test When user joins chat room test
Then the user can mark the channel test as read Then the user can mark the channel test as read
# TODO find a way to validate that it worked # TODO find a way to validate that it worked
Scenario: User can delete their own message
When user joins chat room automation-test
Then user is able to send chat message
| message |
| Delete this message |
Then the user can delete the message at index 0
Then the last message is not "Delete this message"
# TODO This test has a chance to fail since it relies on the mailserver. Until we host a local mailserver for the tests, this test is at risk
Scenario: User cannot delete another user's message
When user joins chat room test
Then the user cannot delete the last message

View File

@ -169,6 +169,7 @@ Rectangle {
active: buttonsContainer.deleteButtonActive && !buttonsContainer.isInPinnedPopup active: buttonsContainer.deleteButtonActive && !buttonsContainer.isInPinnedPopup
sourceComponent: StatusFlatRoundButton { sourceComponent: StatusFlatRoundButton {
id: deleteButton id: deleteButton
objectName: "chatDeleteMessageButton"
width: 32 width: 32
height: 32 height: 32
type: StatusFlatRoundButton.Type.Tertiary type: StatusFlatRoundButton.Type.Tertiary
@ -190,6 +191,7 @@ Rectangle {
id: deleteMessageConfirmationDialogComponent id: deleteMessageConfirmationDialogComponent
ConfirmationDialog { ConfirmationDialog {
confirmButtonObjectName: "chatButtonsPanelConfirmDeleteMessageButton"
header.title: qsTr("Confirm deleting this message") header.title: qsTr("Confirm deleting this message")
confirmationText: qsTr("Are you sure you want to delete this message? Be aware that other clients are not guaranteed to delete the message as well.") confirmationText: qsTr("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