diff --git a/.gitignore b/.gitignore index d14f4e9f25..c3a48cb58c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ nim_status_client.log **/fixtures/*/ipfs test/ui-test/testSuites/suite_status/config.xml -test/ui-test/testSuites/suite_status/envvars +test/ui-test/testSuites/*/envvars test/ui-test/**/__pycache__/* # CPP app ===================================================================== diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index 268930e68f..2b3b5baf92 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -261,6 +261,16 @@ def _find_link(objName: str, link: str): squish.uninstallSignalHandler(obj, "linkHovered(QString)", "_handle_link_hovered") return [-1, -1] + +def move_mouse_over_object(obj): + # Start moving the cursor: + end_x = obj.x + (obj.width / 2) + y = round(int(obj.height) / 2) + x = 0 + while x < end_x: + squish.mouseMove(obj, x, y) + x += 10 + def expect_true(assertionValue: bool, message: str): return test.verify(assertionValue, message) diff --git a/test/ui-test/src/screens/StatusCommunityScreen.py b/test/ui-test/src/screens/StatusCommunityScreen.py index bce619dc6f..e8d14ae00c 100644 --- a/test/ui-test/src/screens/StatusCommunityScreen.py +++ b/test/ui-test/src/screens/StatusCommunityScreen.py @@ -25,6 +25,7 @@ class CommunityCreateMethods(Enum): RIGHT_CLICK_MENU = "right_click_menu" class CommunityScreenComponents(Enum): + CHAT_LOG = "chatView_log" COMMUNITY_HEADER_BUTTON = "mainWindow_communityHeader_StatusChatInfoButton" COMMUNITY_HEADER_NAME_TEXT= "community_ChatInfo_Name_Text" COMMUNITY_CREATE_CHANNEL_OR_CAT_BUTTON = "mainWindow_createChannelOrCategoryBtn_StatusBaseText" @@ -43,7 +44,8 @@ class CommunityScreenComponents(Enum): NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList" COMMUNITY_CHAT_LIST_CATEGORIES = "communityChatListCategories_Repeater" CHAT_INPUT_ROOT = "chatInput_Root" - CHAT_LOG = "chatView_log" + TOGGLE_PIN_MESSAGE_BUTTON = "chatView_TogglePinMessageButton" + PIN_TEXT = "chatInfoButton_Pin_Text" class CommunitySettingsComponents(Enum): EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView" @@ -77,6 +79,7 @@ class CreateOrEditCommunityCategoryPopup(Enum): class StatusCommunityScreen: def __init__(self): + self._retry_number = 0 verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value) def _find_channel_in_category_popup(self, community_channel_name: str): @@ -273,7 +276,7 @@ class StatusCommunityScreen: def check_community_channel_emoji(self, emojiStr: str): obj = wait_and_get_obj(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_ICON.value) - expectTrue(str(obj.icon.emoji).find(emojiStr) >= 0, "Same emoji check") + expect_true(str(obj.icon.emoji).find(emojiStr) >= 0, "Same emoji check") def _verify_image_sent(self, message_index: int): image_obj = get_obj(CommunityScreenComponents.CHAT_LOG.value).itemAtIndex(message_index) @@ -304,3 +307,27 @@ class StatusCommunityScreen: image_index = 2 if has_message else 1 self._verify_image_sent(image_index) + + def _do_wait_for_pin_button(self, message_index: int): + if (self._retry_number > 3): + verify_failure("Cannot find the pin button after hovering the message") + + message_object_to_pin = wait_and_get_obj(CommunityScreenComponents.CHAT_LOG.value).itemAtIndex(int(message_index)) + move_mouse_over_object(message_object_to_pin) + pin_visible, _ = is_loaded_visible_and_enabled(CommunityScreenComponents.TOGGLE_PIN_MESSAGE_BUTTON.value, 100) + if not pin_visible: + self._retry_number += 1 + self._do_wait_for_pin_button(message_index) + + def _wait_for_pin_button(self, message_index: int): + self._retry_number = 0 + self._do_wait_for_pin_button(message_index) + + def toggle_pin_message_at_index(self, message_index: int): + self._wait_for_pin_button(message_index) + + click_obj_by_name(CommunityScreenComponents.TOGGLE_PIN_MESSAGE_BUTTON.value) + + def check_pin_count(self, wanted_pin_count: int): + pin_text_obj = wait_and_get_obj(CommunityScreenComponents.PIN_TEXT.value) + verify_equals(pin_text_obj.text, wanted_pin_count) diff --git a/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py b/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py index 557c0db74a..1a1080e2c8 100644 --- a/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py +++ b/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py @@ -12,6 +12,8 @@ chatView_editMessageButton = {"container": chatView_log, "objectName": "editMess 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"} +chatView_TogglePinMessageButton = {"container": chatView_log, "objectName": "MessageView_toggleMessagePin", "type": "StatusFlatRoundButton", "visible": True} +chatInfoButton_Pin_Text = {"container": chatView_StatusChatInfoButton, "objectName": "StatusChatInfo_pinText", "type": "StatusBaseText", "visible": True} chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "type": "StatusButton"} mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItemDelegate", "visible": True} chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"} 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 822adeb313..a14c2d9ef7 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py @@ -65,6 +65,11 @@ def step(contenxt): def step(context, message): _statusChat.send_message(message) +@When("the user sends the chat message |any|") +def step(context, message): + _statusChat.send_message(message) + _statusChat.verify_last_message_sent(message) + @Then("the user is able to send a random chat message") def step(context): random_int = randint(0, 10000) diff --git a/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py b/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py index 49e2f886de..39fb42b8aa 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py @@ -109,3 +109,16 @@ def step(context): @Then("the test images are displayed just before the last message") def step(context): _statusCommunityScreen.verify_sent_test_image(True, True) + +@When("the user pins the message at index |any|") +def step(context, message_index): + _statusCommunityScreen.toggle_pin_message_at_index(message_index) + +@When("the user unpins the message at index |any|") +def step(context, message_index): + _statusCommunityScreen.toggle_pin_message_at_index(message_index) + +@Then("the amount of pinned messages is |any|") +def step(context, amount): + _statusCommunityScreen.check_pin_count(amount) + diff --git a/test/ui-test/testSuites/suite_status/tst_communityFlows/test.feature b/test/ui-test/testSuites/suite_status/tst_communityFlows/test.feature index a20af93387..4048e0f75e 100644 --- a/test/ui-test/testSuites/suite_status/tst_communityFlows/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_communityFlows/test.feature @@ -131,3 +131,4 @@ Feature: Status Desktop community Examples: | new_emoji_description | new_emoji | | thumbs up | 👍 | + diff --git a/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature index 9692a57be2..d755353a0e 100644 --- a/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature @@ -36,3 +36,21 @@ Feature: Status Desktop community messages When the user sends multiple test images in the current channel with message Mesage with an image again Then the test images are displayed just before the last message And the message Mesage with an image again is displayed in the last message + + + Scenario: User pins and unpins messages + # This one wont work until #6554 is fixed + # And the amount of pinned messages is 0 + When the user sends the chat message Message 1 + And the user pins the message at index 0 + Then the amount of pinned messages is 1 + Then user is able to send chat message + | message | + | Hello | + | How are you | + | I am from status | + | tell me how you do? | + When the user pins the message at index 0 + Then the amount of pinned messages is 2 + When the user unpins the message at index 0 + Then the amount of pinned messages is 1 diff --git a/ui/StatusQ b/ui/StatusQ index 1e12636abd..01624316c2 160000 --- a/ui/StatusQ +++ b/ui/StatusQ @@ -1 +1 @@ -Subproject commit 1e12636abdd9f599fad802b0810b9162b37908c1 +Subproject commit 01624316c2349f9179514c06a84e5e941823a2fc diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 5ca5c34ab2..8be5817c92 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -711,6 +711,7 @@ Loader { } sourceComponent: StatusFlatRoundButton { + objectName: "MessageView_toggleMessagePin" width: d.chatButtonSize height: d.chatButtonSize icon.name: root.pinnedMessage ? "unpin" : "pin"