diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index 236b02ed5e..268930e68f 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -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): diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index ff9a896ce0..286b768a86 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -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 = '' 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") diff --git a/test/ui-test/src/utils/ObjectAccess.py b/test/ui-test/src/utils/ObjectAccess.py new file mode 100644 index 0000000000..97886dc79d --- /dev/null +++ b/test/ui-test/src/utils/ObjectAccess.py @@ -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 \ No newline at end of file diff --git a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py index 0f7ee35f31..23fd0b336d 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py @@ -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) diff --git a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature index 1c9d6bf566..1560100412 100644 --- a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature @@ -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 |