test(community): add a test that pins and unpins messages

Fixes #6894
This commit is contained in:
Jonathan Rainville 2022-08-22 17:12:35 -04:00
parent cbd244b17d
commit 109b9ac290
10 changed files with 81 additions and 4 deletions

2
.gitignore vendored
View File

@ -42,7 +42,7 @@ nim_status_client.log
**/fixtures/*/ipfs **/fixtures/*/ipfs
test/ui-test/testSuites/suite_status/config.xml test/ui-test/testSuites/suite_status/config.xml
test/ui-test/testSuites/suite_status/envvars test/ui-test/testSuites/*/envvars
test/ui-test/**/__pycache__/* test/ui-test/**/__pycache__/*
# CPP app ===================================================================== # CPP app =====================================================================

View File

@ -261,6 +261,16 @@ def _find_link(objName: str, link: str):
squish.uninstallSignalHandler(obj, "linkHovered(QString)", "_handle_link_hovered") squish.uninstallSignalHandler(obj, "linkHovered(QString)", "_handle_link_hovered")
return [-1, -1] 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): def expect_true(assertionValue: bool, message: str):
return test.verify(assertionValue, message) return test.verify(assertionValue, message)

View File

@ -25,6 +25,7 @@ class CommunityCreateMethods(Enum):
RIGHT_CLICK_MENU = "right_click_menu" RIGHT_CLICK_MENU = "right_click_menu"
class CommunityScreenComponents(Enum): class CommunityScreenComponents(Enum):
CHAT_LOG = "chatView_log"
COMMUNITY_HEADER_BUTTON = "mainWindow_communityHeader_StatusChatInfoButton" COMMUNITY_HEADER_BUTTON = "mainWindow_communityHeader_StatusChatInfoButton"
COMMUNITY_HEADER_NAME_TEXT= "community_ChatInfo_Name_Text" COMMUNITY_HEADER_NAME_TEXT= "community_ChatInfo_Name_Text"
COMMUNITY_CREATE_CHANNEL_OR_CAT_BUTTON = "mainWindow_createChannelOrCategoryBtn_StatusBaseText" COMMUNITY_CREATE_CHANNEL_OR_CAT_BUTTON = "mainWindow_createChannelOrCategoryBtn_StatusBaseText"
@ -43,7 +44,8 @@ class CommunityScreenComponents(Enum):
NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList" NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList"
COMMUNITY_CHAT_LIST_CATEGORIES = "communityChatListCategories_Repeater" COMMUNITY_CHAT_LIST_CATEGORIES = "communityChatListCategories_Repeater"
CHAT_INPUT_ROOT = "chatInput_Root" CHAT_INPUT_ROOT = "chatInput_Root"
CHAT_LOG = "chatView_log" TOGGLE_PIN_MESSAGE_BUTTON = "chatView_TogglePinMessageButton"
PIN_TEXT = "chatInfoButton_Pin_Text"
class CommunitySettingsComponents(Enum): class CommunitySettingsComponents(Enum):
EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView" EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView"
@ -77,6 +79,7 @@ class CreateOrEditCommunityCategoryPopup(Enum):
class StatusCommunityScreen: class StatusCommunityScreen:
def __init__(self): def __init__(self):
self._retry_number = 0
verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value) verify_screen(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)
def _find_channel_in_category_popup(self, community_channel_name: str): 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): def check_community_channel_emoji(self, emojiStr: str):
obj = wait_and_get_obj(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_ICON.value) 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): def _verify_image_sent(self, message_index: int):
image_obj = get_obj(CommunityScreenComponents.CHAT_LOG.value).itemAtIndex(message_index) 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 image_index = 2 if has_message else 1
self._verify_image_sent(image_index) 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)

View File

@ -12,6 +12,8 @@ chatView_editMessageButton = {"container": chatView_log, "objectName": "editMess
chatView_editMessageInputComponent = {"container": statusDesktop_mainWindow, "objectName": "editMessageInput", "type": "StatusChatInput", "visible": True} chatView_editMessageInputComponent = {"container": statusDesktop_mainWindow, "objectName": "editMessageInput", "type": "StatusChatInput", "visible": True}
chatView_editMessageInputTextArea = {"container": chatView_editMessageInputComponent, "objectName": "messageInputField", "type": "TextArea", "visible": True} chatView_editMessageInputTextArea = {"container": chatView_editMessageInputComponent, "objectName": "messageInputField", "type": "TextArea", "visible": True}
chatView_DeleteMessageButton = {"container": chatView_log, "objectName": "chatDeleteMessageButton", "type": "StatusFlatRoundButton"} 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"} 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}
chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"} chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"}

View File

@ -65,6 +65,11 @@ def step(contenxt):
def step(context, message): def step(context, message):
_statusChat.send_message(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") @Then("the user is able to send a random chat message")
def step(context): def step(context):
random_int = randint(0, 10000) random_int = randint(0, 10000)

View File

@ -109,3 +109,16 @@ def step(context):
@Then("the test images are displayed just before the last message") @Then("the test images are displayed just before the last message")
def step(context): def step(context):
_statusCommunityScreen.verify_sent_test_image(True, True) _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)

View File

@ -131,3 +131,4 @@ Feature: Status Desktop community
Examples: Examples:
| new_emoji_description | new_emoji | | new_emoji_description | new_emoji |
| thumbs up | 👍 | | thumbs up | 👍 |

View File

@ -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 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 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 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

@ -1 +1 @@
Subproject commit 1e12636abdd9f599fad802b0810b9162b37908c1 Subproject commit 01624316c2349f9179514c06a84e5e941823a2fc

View File

@ -711,6 +711,7 @@ Loader {
} }
sourceComponent: StatusFlatRoundButton { sourceComponent: StatusFlatRoundButton {
objectName: "MessageView_toggleMessagePin"
width: d.chatButtonSize width: d.chatButtonSize
height: d.chatButtonSize height: d.chatButtonSize
icon.name: root.pinnedMessage ? "unpin" : "pin" icon.name: root.pinnedMessage ? "unpin" : "pin"