diff --git a/test/ui-test/fixtures/images/ui-test-image0.jpg b/test/ui-test/fixtures/images/ui-test-image0.jpg new file mode 100644 index 0000000000..b3e73707ed Binary files /dev/null and b/test/ui-test/fixtures/images/ui-test-image0.jpg differ diff --git a/test/ui-test/fixtures/images/ui-test-image1.jpg b/test/ui-test/fixtures/images/ui-test-image1.jpg new file mode 100644 index 0000000000..eff8c5348c Binary files /dev/null and b/test/ui-test/fixtures/images/ui-test-image1.jpg differ diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index 9c9fe44b7e..8c42c37122 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -21,6 +21,22 @@ from utils.ObjectAccess import * _MENTION_SYMBOL = "@" _LINK_HREF_REGEX = '' +class MessageContentType(Enum): + FETCH_MORE_MESSAGES_BUTTON = -2 + CHAT_IDENTIFIER = -1 + UNKNOWN = 0 + MESSAGE = 1 + STICKER = 2 + STATUS = 3 + EMOJI = 4 + TRANSACTION = 5 + SYSTEM_MESSAGE_PRIVATE_GROUP= 6 + IMAGE = 7 + AUDIO = 8 + COMMUNITY_INVITE = 9 + GAP = 10 + EDIT = 11 + class ChatComponents(Enum): MESSAGE_INPUT = "chatView_messageInput" TOOLBAR_INFO_BUTTON = "chatView_StatusChatInfoButton" diff --git a/test/ui-test/src/screens/StatusCommunityScreen.py b/test/ui-test/src/screens/StatusCommunityScreen.py index 0e0625dcc0..bce619dc6f 100644 --- a/test/ui-test/src/screens/StatusCommunityScreen.py +++ b/test/ui-test/src/screens/StatusCommunityScreen.py @@ -17,6 +17,8 @@ from drivers.SquishDriver import * from drivers.SquishDriverVerification import * from drivers.SDKeyboardCommands import * from .StatusMainScreen import StatusMainScreen +from utils.FileManager import * +from screens.StatusChatScreen import MessageContentType class CommunityCreateMethods(Enum): BOTTOM_MENU = "bottom_menu" @@ -40,6 +42,8 @@ class CommunityScreenComponents(Enum): DELETE_CHANNEL_CONFIRMATION_DIALOG_DELETE_BUTTON = "delete_Channel_ConfirmationDialog_DeleteButton" NOT_CATEGORIZED_CHAT_LIST = "mainWindow_communityColumnView_statusChatList" COMMUNITY_CHAT_LIST_CATEGORIES = "communityChatListCategories_Repeater" + CHAT_INPUT_ROOT = "chatInput_Root" + CHAT_LOG = "chatView_log" class CommunitySettingsComponents(Enum): EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView" @@ -269,4 +273,34 @@ class StatusCommunityScreen: def check_community_channel_emoji(self, emojiStr: str): obj = wait_and_get_obj(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_ICON.value) - expect_true(str(obj.icon.emoji).find(emojiStr) >= 0, "Same emoji check") \ No newline at end of file + expectTrue(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) + verify_values_equal(str(image_obj.messageContentType), str(MessageContentType.IMAGE.value), "The last message is not an image.") + + def send_test_image(self, fixtures_root: str, multiple_images: bool, message: str): + chat_input = wait_and_get_obj(CommunityScreenComponents.CHAT_INPUT_ROOT.value) + + chat_input.selectImageString(fixtures_root + "images/ui-test-image0.jpg") + + if (multiple_images): + #self._select_test_image(fixtures_root, 1) + chat_input.selectImageString(fixtures_root + "images/ui-test-image1.jpg") + + if (message != ""): + # Type the message in the input (focus should be on the chat input) + native_type(message) + + # Send the image (and message if present) + native_type("") + + def verify_sent_test_image(self, multiple_images: bool, has_message: bool): + image_index = 1 if has_message else 0 + self._verify_image_sent(image_index) + + if (multiple_images): + # Verify second image + image_index = 2 if has_message else 1 + self._verify_image_sent(image_index) + diff --git a/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py b/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py index 5bd87368b4..8ea6a3fd5d 100644 --- a/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py +++ b/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py @@ -20,6 +20,20 @@ def hook(context): context.userData["fixtures_root"] = os.path.join(os.path.dirname(__file__), "../../../fixtures/") context.userData["search_images"] = os.path.join(os.path.dirname(__file__), "../shared/searchImages/") + base_path = os.path.join(os.path.dirname(__file__)) + split_path = base_path.split("/") + + # Remove the last three parts of the path to go back to the fixtures + del split_path[len(split_path) - 1] + del split_path[len(split_path) - 1] + del split_path[len(split_path) - 1] + + joined_path = "" + for path_part in split_path: + joined_path += path_part + "/" + + context.userData["fixtures_root"] = os.path.join(joined_path, "fixtures/") + @OnScenarioEnd def hook(context): currentApplicationContext().detach() 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 059dbe8a24..784909be2b 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 @@ -6,7 +6,7 @@ chatView_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectN mainWindow_scrollView_ScrollView = {"container": statusDesktop_mainWindow, "id": "scrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True} chatView_messageInput = {"container": statusDesktop_mainWindow, "objectName": "messageInputField", "type": "TextArea", "visible": True} chatView_chatLogView_lastMsg_MessageView = {"container": chatView_log, "index": 0, "type": "MessageView"} -chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "objectName": "StatusTextMessage_chatText", "type": "TextEdit"} +chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "type": "TextEdit", "objectName": "StatusTextMessage_chatText", "visible": True} chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton"} chatView_DeleteMessageButton = {"container": chatView_log, "objectName": "chatDeleteMessageButton", "type": "StatusFlatRoundButton"} chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "type": "StatusButton"} @@ -17,6 +17,7 @@ chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overl emojiPopup_Emoji_Button_Placeholder = {"container": statusDesktop_mainWindow, "objectName": "statusEmoji_%NAME%", "type": "StatusEmoji", "visible": True} chatInput_Emoji_Button = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputEmojiButton", "type": "StatusFlatRoundButton", "visible": True} chatView_ChatToolbarMoreOptionsButton = {"container": statusDesktop_mainWindow, "objectName": "chatToolbarMoreOptionsButton", "type": "StatusFlatRoundButton"} +chatInput_Root = {"container": statusDesktop_mainWindow, "objectName": "statusChatInput", "type": "Rectangle", "visible": True} # More options menu clearHistoryMenuItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "clearHistoryMenuItem", "type": "StatusMenuItemDelegate", "visible": True} 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 b7dc3490f9..02f40bbeb1 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py @@ -44,7 +44,7 @@ def step(context): _statusChat.send_message(row[0]) _statusChat.verify_last_message_sent(row[0]) -@Then("user is able to send a random chat message") +@Then("the user is able to send a random chat message") def step(context): random_int = randint(0, 10000) message = "random message " + str(random_int) 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 4aba29a379..49e2f886de 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/communitySteps.py @@ -84,3 +84,28 @@ def step(context, emoji_description: str): @Then("the community channel has emoji |any|") def step(context, emoji: str): _statusCommunityScreen.check_community_channel_emoji(emoji) + + +@When("the user sends a test image in the current channel") +def step(context): + _statusCommunityScreen.send_test_image(context.userData["fixtures_root"], False, "") + +@When("the user sends a test image in the current channel with message |any|") +def step(context, message): + _statusCommunityScreen.send_test_image(context.userData["fixtures_root"], False, message) + +@When("the user sends multiple test images in the current channel with message |any|") +def step(context, message): + _statusCommunityScreen.send_test_image(context.userData["fixtures_root"], True, message) + +@Then("the test image is displayed in the last message") +def step(context): + _statusCommunityScreen.verify_sent_test_image(False, False) + +@Then("the test image is displayed just before the last message") +def step(context): + _statusCommunityScreen.verify_sent_test_image(False, True) + +@Then("the test images are displayed just before the last message") +def step(context): + _statusCommunityScreen.verify_sent_test_image(True, True) diff --git a/test/ui-test/testSuites/suite_status/suite.conf b/test/ui-test/testSuites/suite_status/suite.conf index 20b1b9c20d..c0113d881a 100644 --- a/test/ui-test/testSuites/suite_status/suite.conf +++ b/test/ui-test/testSuites/suite_status/suite.conf @@ -5,6 +5,6 @@ HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=0 LANGUAGE=Python OBJECTMAPSTYLE=script -TEST_CASES=tst_statusLoginPassword tst_basicChatFlow tst_wallet tst_communityFlows tst_groupChat tst_transaction tst_settingsMenu tst_userIdentity tst_languageSettings tst_searchFlows +TEST_CASES=tst_statusLoginPassword tst_basicChatFlow tst_wallet tst_communityFlows tst_groupChat tst_transaction tst_settingsMenu tst_userIdentity tst_languageSettings tst_searchFlows tst_communityMessageFlows VERSION=3 WRAPPERS=Qt 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 353e3957e5..de3f452863 100644 --- a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature @@ -46,7 +46,7 @@ Feature: Status Desktop Chat Scenario: User can delete their own message When user joins chat room automation-test - Then user is able to send a random chat message + Then the user is able to send a random chat message Then the user can delete the message at index 0 Then the last message is not the random message @@ -104,7 +104,7 @@ Feature: Status Desktop Chat | second-chat | | first-chat | When user switches to second-chat chat - Then user is able to send a random chat message + Then the user is able to send a random chat message And user chats are sorted accordingly | second-chat | | third-chat | diff --git a/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature new file mode 100644 index 0000000000..9692a57be2 --- /dev/null +++ b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.feature @@ -0,0 +1,38 @@ +#****************************************************************************** +# Status.im +#*****************************************************************************/ +#/** +# * \file test.feature +# * +# * \test Status Desktop - Community Chat Flows +# * \date July 2022 +# ** +# *****************************************************************************/ + +Feature: Status Desktop community messages + + As a user I want to send messages and interact with channels in a community + + + Background: + Given A first time user lands on the status desktop and generates new key + When user signs up with username tester123 and password TesTEr16843/!@00 + Then the user lands on the signed in app + When the user opens the community portal section + Then the user lands on the community portal section + When the user creates a community named test_community, with description Community description, intro community intro and outro commmunity outro + Then the user lands on the community named test_community + + Scenario: User sends a test image + When the user sends a test image in the current channel + Then the test image is displayed in the last message + + Scenario: User sends a test image with a message + When the user sends a test image in the current channel with message Mesage with an image + Then the test image is displayed just before the last message + And the message Mesage with an image is displayed in the last message + + Scenario: User sends multiple test images with a message + 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 diff --git a/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.py b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.py new file mode 100644 index 0000000000..01702be131 --- /dev/null +++ b/test/ui-test/testSuites/suite_status/tst_communityMessageFlows/test.py @@ -0,0 +1,8 @@ +source(findFile('scripts', 'python/bdd.py')) + +setupHooks('../../global_shared/scripts/bdd_hooks.py') +collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps/', '../../suite_onboarding/shared/steps/') + +def main(): + testSettings.throwOnFailure = True + runFeatureFile('test.feature') diff --git a/test/ui-test/testSuites/suite_status/tst_searchFlows/test.feature b/test/ui-test/testSuites/suite_status/tst_searchFlows/test.feature index ae84d71573..f8919d9308 100644 --- a/test/ui-test/testSuites/suite_status/tst_searchFlows/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_searchFlows/test.feature @@ -45,7 +45,7 @@ Feature: Search feature (ctrl+F) Scenario: User can search for a message in a public channel When the user opens the chat section And user joins chat room search-automation-test-1 - Then user is able to send a random chat message + Then the user is able to send a random chat message # Go back to the portal so that we see if the search really redirects When the user opens the community portal section And the user opens the search menu diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 7526f7f34d..344289d45c 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -672,6 +672,15 @@ Rectangle { } } + // This is used by Squish tests to not have to access the file dialog + function selectImageString(filePath) { + let validImages = validateImages([filePath]) + if (validImages.length > 0) { + control.showImageArea(validImages) + } + messageInputField.forceActiveFocus(); + } + FileDialog { id: imageDialog title: qsTr("Please choose an image") @@ -1234,4 +1243,4 @@ Rectangle { } } -} +} \ No newline at end of file