test(community-chat): add test to send images in chat

Fixes #6880
This commit is contained in:
Jonathan Rainville 2022-08-19 10:57:09 -04:00
parent 7b77973b86
commit 6a603413c6
14 changed files with 153 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -21,6 +21,22 @@ from utils.ObjectAccess import *
_MENTION_SYMBOL = "@"
_LINK_HREF_REGEX = '<a href="(.+?)">'
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"

View File

@ -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")
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("<Return>")
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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