test(@desktop/chat): add scenario for chats order

covers: #6634
This commit is contained in:
Patryk Osmaczko 2022-08-18 09:27:57 +02:00 committed by osmaczko
parent 6339bd5782
commit 3aaa0fda13
5 changed files with 72 additions and 4 deletions

View File

@ -73,6 +73,8 @@ def is_displayed(objName: str):
def is_visible_and_enabled(obj):
return obj.visible and obj.enabled
def is_null(obj):
return squish.isNull(obj)
# Given a specific object, get a specific child.
def get_child(obj, child_index=None):

View File

@ -16,14 +16,15 @@ from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from drivers.SDKeyboardCommands import *
from common.Common import *
from utils.ObjectAccess import *
_MENTION_SYMBOL = "@"
_LINK_HREF_REGEX = '<a href="(.+?)">'
class ChatComponents(Enum):
MESSAGE_INPUT = "chatView_messageInput"
MESSAGE_INPUT = "chatView_messageInput"
TOOLBAR_INFO_BUTTON = "chatView_StatusChatInfoButton"
CHAT_LOG = "chatView_log"
CHAT_LOG = "chatView_log"
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
MEMBERS_LISTVIEW = "chatView_chatMembers_ListView"
REPLY_TO_MESSAGE_BUTTON = "chatView_replyToMessageButton"
@ -34,7 +35,7 @@ class ChatComponents(Enum):
MENTION_PROFILE_VIEW = "chatView_userMentioned_ProfileView"
CHAT_INPUT_EMOJI_BUTTON = "chatInput_Emoji_Button"
EMOJI_POPUP_EMOJI_PLACEHOLDER = "emojiPopup_Emoji_Button_Placeholder"
CHAT_LIST = "chatList_Repeater"
class ChatMessagesHistory(Enum):
CHAT_CREATED_TEXT = 1
@ -194,4 +195,23 @@ class StatusChatScreen:
click_obj_by_attr(emojiAttr)
press_enter(ChatComponents.MESSAGE_INPUT.value)
def verify_chat_order(self, index: int, chatName: str):
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")
verify(len(chat_list_items) > 0, "StatusChatListItem exists")
verify(str(chat_list_items[0].name) == chatName, "Chat in order")
def switch_to_chat(self, chatName: str):
chat_lists = get_obj(ChatComponents.CHAT_LIST.value)
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")
verify(len(chat_list_items) > 0, "StatusChatListItem exists")
if str(chat_list_items[0].name) == chatName:
click_obj(chat)
return
verify(False, "Chat switched")

View File

@ -0,0 +1,20 @@
import squish
import object
def getChildrenOfType(parent, typename, depth=1000):
children = []
for child in object.children(parent):
if squish.className(child) == typename:
children.append(child)
if depth:
children.extend(getChildrenOfType(child, typename, depth - 1))
return children
def getChildrenWithObjectName(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))
return children

View File

@ -118,3 +118,14 @@ def step(context, displayName):
@Then("the |any| mention with message |any| have been sent")
def step(context,displayName,message):
_statusChat.verify_last_message_sent_contains_mention(displayName, message)
@Then("user chats are sorted accordingly")
def step(context):
table = context.table
for i, row in enumerate(table):
chatName = row[0]
_statusChat.verify_chat_order(i, chatName)
@When("user switches to |any| chat")
def step(context, chatName):
_statusChat.switch_to_chat(chatName)

View File

@ -83,3 +83,18 @@ Feature: Status Desktop Chat
When user sends the emoji sunglasses with message wow I'm so cool
Then the emoji 😎 is displayed in the last message
And the message wow I'm so cool is displayed in the last message
Scenario: User sees chats sorted by most recent activity
When user joins chat room first-chat
And user joins chat room second-chat
And user joins chat room third-chat
Then user chats are sorted accordingly
| third-chat |
| second-chat |
| first-chat |
When user switches to second-chat chat
Then user is able to send a random chat message
And user chats are sorted accordingly
| second-chat |
| third-chat |
| first-chat |