tests(suite_messaging): properly check if reply message has reply

Prior to this commit we were merely checking if the message in question
was the last one.

With this commit we now check whether there's a reply in the first place
and whether the reply-to-message is the correct one.

We also distinguish whether the message we're replying to is the one
from the loggedin user (and not someone else's)
This commit is contained in:
Pascal Precht 2022-11-15 15:58:11 +01:00 committed by r4bbit.eth
parent 6e5b98d157
commit dbf7fa4aab
5 changed files with 38 additions and 10 deletions

View File

@ -84,6 +84,8 @@ class ChatStickerPopup(Enum):
class ChatItems(Enum): class ChatItems(Enum):
STATUS_MESSAGE_TEXT_MESSAGE = "StatusMessage_textMessage" STATUS_MESSAGE_TEXT_MESSAGE = "StatusMessage_textMessage"
STATUS_MESSAGE_REPLY_DETAILS = "StatusMessage_replyDetails"
STATUS_MESSAGE_REPLY_DETAILS_TEXT_MESSAGE = "StatusMessage_replyDetails_textMessage"
STATUS_TEXT_MESSAGE_CHAT_TEXT = "StatusTextMessage_chatText" STATUS_TEXT_MESSAGE_CHAT_TEXT = "StatusTextMessage_chatText"
class ChatMessagesHistory(Enum): class ChatMessagesHistory(Enum):
@ -318,7 +320,26 @@ class StatusChatScreen:
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_false(loaded, "Success: No message was found") verify_false(loaded, "Success: No message was found")
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]
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]
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]
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")
def verify_last_message_sent(self, message: str): def verify_last_message_sent(self, message: str):
# Get the message text # Get the message text
# We don't search for StatusTextMessage_chatText directly, because there're 2 instances of it in a reply message # We don't search for StatusTextMessage_chatText directly, because there're 2 instances of it in a reply message

View File

@ -182,8 +182,15 @@ def step(context, message):
@Then("the chat message \"|any|\" is displayed as a reply") @Then("the chat message \"|any|\" is displayed as a reply")
def step(context, message): def step(context, message):
# TODO: Check the last message is really a reply. _statusChat.verify_last_message_is_reply(message)
_statusChat.verify_last_message_sent(message)
@Then("the chat message \"|any|\" is displayed as a reply of \"|any|\"")
def step(context, reply, message):
_statusChat.verify_last_message_is_reply_to(reply, message)
@Then("the chat message \"|any|\" is displayed as a reply of this user's \"|any|\"")
def step(context, reply, message):
_statusChat.verify_last_message_is_reply_to_loggedin_user_message(reply, message)
@Then("the chat message \"|any|\" is displayed as an edited one") @Then("the chat message \"|any|\" is displayed as an edited one")
def step(context, message): def step(context, message):

View File

@ -24,17 +24,15 @@ Feature: Status Desktop Chat Basic Flows
| I am from status | | I am from status |
| tell me how you do? | | tell me how you do? |
# TODO: Scenario: The user can reply to their OWN message
@mayfail @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. # 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 the last message Scenario Outline: The user can reply to own message
Given the user sends a chat message "random chat message" Given the user sends a chat message "<message>"
When the user replies to the message at index 0 with "<reply>" When the user replies to the message at index 0 with "<reply>"
# TODO: Check the last message is really a reply, now just checking the last message is the expected one but could not be a reply. The popup option does not appear. Then the chat message "<reply>" is displayed as a reply of this user's "<message>"
Then the chat message "<reply>" is displayed as a reply
Examples: Examples:
| reply | | message | reply |
| This is a reply | | random chat message | This is a reply |
@mayfail @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. # 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.

View File

@ -215,6 +215,7 @@ Control {
active: isAReply active: isAReply
visible: active visible: active
sourceComponent: StatusMessageReply { sourceComponent: StatusMessageReply {
objectName: "StatusMessage_replyDetails"
replyDetails: root.replyDetails replyDetails: root.replyDetails
profileClickable: root.profileClickable profileClickable: root.profileClickable
audioMessageInfoText: root.audioMessageInfoText audioMessageInfoText: root.audioMessageInfoText

View File

@ -97,6 +97,7 @@ Item {
} }
} }
StatusTextMessage { StatusTextMessage {
objectName: "StatusMessage_replyDetails_textMessage"
Layout.fillWidth: true Layout.fillWidth: true
textField.font.pixelSize: Theme.secondaryTextFontSize textField.font.pixelSize: Theme.secondaryTextFontSize
textField.color: Theme.palette.baseColor1 textField.color: Theme.palette.baseColor1