test(group chat): Testing changing group chat's name, color and image.

Fixes #7065
This commit is contained in:
Michal Iskierko 2022-09-01 09:53:22 +02:00 committed by Michał Iskierko
parent f4a78a1f10
commit 55cb3cbf33
18 changed files with 189 additions and 28 deletions

View File

@ -4,6 +4,8 @@ from drivers.SquishDriver import *
def press_enter(objName: str):
type(objName, "<Return>")
def press_backspace(objName: str):
type(objName, "<Backspace>")
def press_escape(objName: str):
type(objName, "<Escape>")

View File

@ -111,6 +111,11 @@ def get_objects(objName: str):
objs = squish.findAllObjects(getattr(names, objName))
return objs
def hover_and_click_object_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName))
hover_obj(obj)
squish.mouseClick(obj, squish.Qt.LeftButton)
# It executes the left-click action into object with given object name:
def click_obj_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName))

View File

@ -10,6 +10,7 @@
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from utils.ObjectAccess import *
# It defines the identifier for each Account View component:
class SAccountsComponents(Enum):
@ -37,10 +38,9 @@ class StatusAccountsScreen():
account_obj = None
[is_loaded, accountsList] = is_loaded_visible_and_enabled(SAccountsComponents.ACCOUNTS_POPUP.value)
if is_loaded:
for index in range(accountsList.count):
a = accountsList.itemAtIndex(index)
if(a.label == account):
account_obj = a
for child in getChildrenOfType(accountsList, "AccountMenuItemPanel"):
if(child.label == account):
account_obj = child
found = True
break
break
return found, account_obj

View File

@ -60,6 +60,9 @@ class ChatComponents(Enum):
EDIT_MESSAGE_INPUT = "chatView_editMessageInputComponent"
EDIT_MESSAGE_TEXTAREA = "chatView_editMessageInputTextArea"
EDIT_NAME_AND_IMAGE_MENUITEM = "editNameAndImageMenuItem"
LEAVE_CHAT_MENUITEM = "leaveChatMenuItem"
GIF_POPUP_BUTTON = "chatView_gifPopupButton"
ENABLE_GIF_BUTTON = "gifPopup_enableGifButton"
GIF_MOUSEAREA = "gifPopup_gifMouseArea"
@ -84,6 +87,14 @@ class ChatMessagesHistory(Enum):
class Emoji(Enum):
EMOJI_SUGGESTIONS_FIRST_ELEMENT = "emojiSuggestions_first_inputListRectangle"
class GroupChatEditPopup(Enum):
GROUP_CHAT_EDIT_NAME = "groupChatEdit_name"
GROUP_CHAT_EDIT_COLOR_REPEATER = "groupChatEdit_colorRepeater"
GROUP_CHAT_EDIT_IMAGE = "groupChatEdit_image"
GROUP_CHAT_EDIT_SAVE = "groupChatEdit_save"
GROUP_CHAT_EDIT_MAIN = "groupChatEdit_main"
GROUP_CHAT_CROP_WORKFLOW_ITEM = "groupChatEdit_workflowItem"
GROUP_CHAT_CROPPER_ACCEPT_BUTTON = "groupChatEdit_cropperAcceptButton"
class StatusChatScreen:
@ -112,7 +123,46 @@ class StatusChatScreen:
def clear_history(self):
click_obj_by_name(ChatComponents.MORE_OPTIONS_BUTTON.value)
click_obj_by_name(ChatComponents.CLEAR_HISTORY_MENUITEM.value)
def open_group_chat_edit_popup(self):
time.sleep(2)
hover_and_click_object_by_name(ChatComponents.MORE_OPTIONS_BUTTON.value)
time.sleep(2)
hover_and_click_object_by_name(ChatComponents.EDIT_NAME_AND_IMAGE_MENUITEM.value)
def leave_chat(self):
time.sleep(2)
hover_and_click_object_by_name(ChatComponents.MORE_OPTIONS_BUTTON.value)
time.sleep(2)
hover_and_click_object_by_name(ChatComponents.LEAVE_CHAT_MENUITEM.value)
def group_chat_edit_name(self, name):
setText(GroupChatEditPopup.GROUP_CHAT_EDIT_NAME.value, name)
def group_chat_edit_save(self):
# save may be disabled, eg. if color from scenario is already set
obj = get_obj(GroupChatEditPopup.GROUP_CHAT_EDIT_SAVE.value)
if (is_visible_and_enabled(obj)):
click_obj_by_name(GroupChatEditPopup.GROUP_CHAT_EDIT_SAVE.value)
else:
press_escape(GroupChatEditPopup.GROUP_CHAT_EDIT_MAIN.value)
def group_chat_edit_color(self, newColor: str):
colorList = get_obj(GroupChatEditPopup.GROUP_CHAT_EDIT_COLOR_REPEATER.value)
for index in range(colorList.count):
color = colorList.itemAt(index)
if(color.radioButtonColor == newColor):
click_obj(colorList.itemAt(index))
def group_chat_edit_image(self, fixtures_root: str):
self._group_chat_input_image("file:///"+ fixtures_root + "images/ui-test-image0.jpg")
def _group_chat_input_image(self, groupChatUrl: str):
parentObject = get_obj(GroupChatEditPopup.GROUP_CHAT_EDIT_IMAGE.value)
workflow = parentObject.cropWorkflow
workflow.cropImage(groupChatUrl)
click_obj_by_name(GroupChatEditPopup.GROUP_CHAT_CROPPER_ACCEPT_BUTTON.value)
# Verifications region:
def verify_last_message_is_not_loaded(self):
[loaded, _] = is_loaded_visible_and_enabled(ChatComponents.LAST_MESSAGE_TEXT.value)
@ -175,6 +225,14 @@ class StatusChatScreen:
def verify_chat_title(self, title: str):
info_btn = get_obj(ChatComponents.TOOLBAR_INFO_BUTTON.value)
verify_text(str(info_btn.title), title)
def verify_chat_color(self, color: str):
info_btn = get_obj(ChatComponents.TOOLBAR_INFO_BUTTON.value)
verify_text(str(info_btn.asset.color.name), str(color.lower()))
def verify_chat_image(self, path: str):
fullPath = path + "images/ui-test-image0.jpg"
imagePresent(fullPath, True, 95, 25, 150, True)
def verify_members_added(self, members):
self.verify_total_members_is_displayed_in_toolbar(members)
@ -196,13 +254,13 @@ class StatusChatScreen:
def verify_added_members_message_is_displayed_in_history(self, members):
chat_membersAdded_text_obj = self.get_message_at_index(ChatMessagesHistory.HAS_ADDED_TEXT.value)
for member in members[0:]:
verify_text_contains(str(chat_membersAdded_text_obj.message), member[0])
verify_text_contains(str(chat_membersAdded_text_obj.messageText), member[0])
# NOTE: It is expecting a specific log order and will succeed only just after the chat is created and no messages have been sent.
# TODO: Improvement --> Iterate through the complete history, check all messages and verify the `createdTxt` is displayed.
def verify_chat_created_message_is_displayed_in_history(self, createdTxt: str):
chat_createChat_text_obj = self.get_message_at_index(ChatMessagesHistory.CHAT_CREATED_TEXT.value)
verify_text_contains(str(chat_createChat_text_obj.message), createdTxt)
verify_text_contains(str(chat_createChat_text_obj.messageText), createdTxt)
def reply_to_message_at_index(self, index: int, message: str):
message_object_to_reply_to = self.get_message_at_index(index)
@ -344,4 +402,3 @@ class StatusChatScreen:
click_obj(chat)
return
verify(False, "Chat switched")

View File

@ -20,6 +20,7 @@ class SLoginComponents(Enum):
PASSWORD_INPUT = "loginView_passwordInput"
SUBMIT_BTN = "loginView_submitBtn"
CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn"
CURRENT_USERNAME_LABEL = "loginView_currentUserNameLabel"
ERR_MSG_LABEL = "loginView_errMsgLabel"
@ -43,9 +44,15 @@ class StatusLoginScreen():
self.enter_password(password)
def select_account(self, account):
if self.is_account_selected(account):
return
self.open_accounts_selector_popup()
accounts_popup = self.get_accounts_selector_popup()
accounts_popup.select_account(account)
def is_account_selected(self, account):
obj = get_obj(SLoginComponents.CURRENT_USERNAME_LABEL.value)
return obj.text == account
def enter_password(self, password):
click_obj_by_name(SLoginComponents.PASSWORD_INPUT.value)

View File

@ -13,6 +13,7 @@ import time
from enum import Enum
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from utils.ObjectAccess import *
import time
class MainScreenComponents(Enum):
@ -23,7 +24,7 @@ class MainScreenComponents(Enum):
SETTINGS_BUTTON = "navBarListView_Settings_navbar_StatusNavBarTabButton"
WALLET_BUTTON = "wallet_navbar_wallet_icon_StatusIcon"
START_CHAT_BTN = "mainWindow_startChat"
CHAT_LIST = "chatList_Repeater"
CHAT_LIST = "chatList"
MARK_AS_READ_BUTTON = "mark_as_Read_StatusMenuItemDelegate"
COMMUNITY_NAVBAR_BUTTONS = "navBarListView_All_Community_Buttons"
MODULE_WARNING_BANNER = "moduleWarning_Banner"
@ -32,6 +33,7 @@ class MainScreenComponents(Enum):
USERSTATUSMENU_INACTIVE_ACTION = "userContextmenu_InActiveButton"
USERSTATUSMENU_AUTOMATIC_ACTION = "userContextmenu_AutomaticButton"
USERSTATUSMENU_OPEN_PROFILE_POPUP = "userContextMenu_ViewMyProfileAction"
class ProfilePopup(Enum):
USER_IMAGE = "ProfileHeader_userImage"
DISPLAY_NAME = "ProfileHeader_displayName"
@ -91,12 +93,16 @@ class StatusMainScreen:
if loaded:
click_obj(chat_button)
verify(loaded, "Trying to get chat: " + chatName)
def verify_chat_does_not_exist(self, chatName: str):
[loaded, chat_button] = self._find_chat(chatName)
verify_false(loaded, "Chat "+chatName+ " exists")
def _find_chat(self, chatName: str):
[loaded, chat_lists] = is_loaded(MainScreenComponents.CHAT_LIST.value)
if loaded:
for index in range(chat_lists.count):
chat = chat_lists.itemAt(index)
for index in range(chat_lists.statusChatListItems.count):
chat = chat_lists.statusChatListItems.itemAt(index)
if(chat.objectName == chatName):
return True, chat
return False, None

View File

@ -26,6 +26,7 @@ def clear_directory(dir: str):
def copy_directory(src: str, dst: str):
if os.path.isdir(src) and os.path.isdir(dst):
try:
distutils.dir_util._path_created = {} # clear dir_util cache
distutils.dir_util.copy_tree(src, dst)
except OSError:
os.remove(dst)

View File

@ -26,6 +26,7 @@ modal_Close_Button = {"container": statusDesktop_mainWindow_overlay, "objectName
# Main Window - chat related:
mainWindow_public_chat_icon_StatusIcon = {"container": statusDesktop_mainWindow, "objectName": "public-chat-icon", "source": "qrc:/StatusQ/src/assets/img/icons/public-chat.svg", "type": "StatusIcon", "visible": True}
chatList_Repeater = {"container": statusDesktop_mainWindow, "objectName": "chatListItems", "type": "Repeater"}
chatList = {"container": statusDesktop_mainWindow, "objectName": "ContactsColumnView_chatList", "type": "StatusChatList"}
mainWindow_startChat = {"checkable": True, "container": statusDesktop_mainWindow, "objectName": "startChatButton", "type": "StatusIconTabButton"}
join_public_chat_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Join public chat", "type": "StatusMenuItemDelegate", "unnamed": 1, "visible": True}

View File

@ -3,6 +3,7 @@ from scripts.global_names import *
# Main:
loginView_passwordInput = {"container": statusDesktop_mainWindow, "objectName": "loginPasswordInput", "type": "StyledTextField"}
loginView_changeAccountBtn = {"container": statusDesktop_mainWindow, "objectName": "loginChangeAccountButton", "type": "StatusFlatRoundButton"}
loginView_currentUserNameLabel = {"container": statusDesktop_mainWindow, "objectName": "currentUserNameLabel", "type": "StatusBaseText"}
loginView_submitBtn = {"container": statusDesktop_mainWindow, "type": "StatusRoundButton", "visible": True}
loginView_main = {"container": statusDesktop_mainWindow, "type": "LoginView", "visible": True}
loginView_errMsgLabel = {"container": statusDesktop_mainWindow, "objectName": "loginPassworkInputValidationErrorText", "type": "StatusBaseText", "visible": True}

View File

@ -33,6 +33,7 @@ def step(context, username):
@Then("the user lands on the signed in app")
def step(context):
_mainScreen
time.sleep(2)
@When("The user inputs the seed phrase |any|")

View File

@ -23,12 +23,23 @@ chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overl
emojiSuggestions_first_inputListRectangle ={"container": statusDesktop_mainWindow_overlay, "objectName": "inputListRectangle_0", "type": "Rectangle"}
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"}
chatView_ChatToolbarMoreOptionsButton = {"container": statusDesktop_mainWindow, "objectName": "chatToolbarMoreOptionsButton", "type": "StatusFlatRoundButton", "visible": True}
chatInput_Root = {"container": statusDesktop_mainWindow, "objectName": "statusChatInput", "type": "Rectangle", "visible": True}
chatView_gifPopupButton = {"container": statusDesktop_mainWindow, "objectName": "gifPopupButton", "type": "StatusFlatRoundButton", "visible": True}
# More options menu
clearHistoryMenuItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "clearHistoryMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
editNameAndImageMenuItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "editNameAndImageMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
leaveChatMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItemDelegate", "visible": True}
# group chat edit popup
groupChatEdit_main = {"container": statusDesktop_mainWindow_overlay, "objectName": "groupChatEdit_main", "type": "StatusDialog", "visible": True}
groupChatEdit_name = {"container": statusDesktop_mainWindow_overlay, "objectName": "groupChatEdit_name", "type": "TextEdit", "visible": True}
groupChatEdit_save= {"container": statusDesktop_mainWindow_overlay, "objectName": "groupChatEdit_save", "type": "StatusButton", "visible": True}
groupChatEdit_colorRepeater = {"container": statusDesktop_mainWindow, "type": "Repeater", "objectName": "statusColorRepeater", "visible": True}
groupChatEdit_workflowItem= {"container": statusDesktop_mainWindow, "type": "Item", "objectName": "imageCropWorkflow"}
groupChatEdit_cropperAcceptButton = {"container": statusDesktop_mainWindow, "type": "StatusButton", "objectName": "imageCropperAcceptButton"}
groupChatEdit_image = {"container": statusDesktop_mainWindow_overlay, "objectName": "groupChatEdit_image", "type": "EditCroppedImagePanel"}
# Gif popup:
gifPopup_enableGifButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "enableGifsButton", "type": "StatusButton"}

View File

@ -36,11 +36,31 @@ def step(context,displayName,message):
@When("the user clears chat history")
def step(context):
_statusChat.clear_history()
@When("the user opens the edit group chat popup")
def step(context):
_statusChat.open_group_chat_edit_popup()
@When("the user types \"|any|\"")
def step(context, message):
_statusChat.type_message_in_chat_input(message)
@When("the user changes the group name to |any|")
def step(context, groupName):
_statusChat.group_chat_edit_name(groupName)
@When("the user changes the group color to |any|")
def step(context, groupColor):
_statusChat.group_chat_edit_color(groupColor)
@When("the user changes the group image")
def step(context):
_statusChat.group_chat_edit_image(context.userData["fixtures_root"])
@When("the user saves changes")
def step(context):
_statusChat.group_chat_edit_save()
@When("the user pressed enter")
def step(context):
_statusChat.press_enter_in_chat_input()
@ -63,7 +83,7 @@ def step(contenxt):
@Then("the user is able to send chat message \"|any|\"")
def step(context, message):
_statusChat.send_message(message)
_statusChat.send_message(message)
@When("the user sends the chat message |any|")
def step(context, message):
@ -93,6 +113,14 @@ def step(context, createdTxt):
@Then("the chat title is |any|")
def step(context, title):
_statusChat.verify_chat_title(title)
@Then("the chat color is |any|")
def step(context, color):
_statusChat.verify_chat_color(color)
@Then("the chat image is changed")
def step(context):
_statusChat.verify_chat_image(context.userData["fixtures_root"])
@Then("the group chat contains the following members")
def step(context):
@ -144,7 +172,7 @@ def step(context, emoji_short_name, message):
@Then("the emoji |any| is displayed in the last message")
def step(context, emoji):
_statusChat.verify_last_message_sent(emoji)
_statusChat.verify_last_message_sent(emoji)
@Then("the message |any| is displayed in the last message")
def step(context, message):
@ -178,3 +206,11 @@ def step(context):
@When("user switches to |any| chat")
def step(context, chatName):
_statusChat.switch_to_chat(chatName)
@When("the user leaves current chat")
def step(context):
_statusChat.leave_chat()
@Then("chat |any| does not exist")
def step(context, chatName):
_statusMain.verify_chat_does_not_exist(chatName)

View File

@ -4,23 +4,23 @@ Feature: Status Desktop Group Chat
Background:
Given the user starts the application with a specific data folder ../../../fixtures/group_chat
Given the user starts the application with a specific data folder ../../../fixtures/group_chat
When the user tester123 logs in with password TesTEr16843/!@00
Then the user lands on the signed in app
@mayfail
Scenario: As an admin user I want to create a group chat with my contacts and the invited users can send messages
When the user tester123 logs in with password TesTEr16843/!@00
Then the user lands on the signed in app
When the user creates a group chat adding users
| Athletic |
| Nervous |
Then the group chat is created
And the group chat history contains "created the group" message
And the chat title is Athletic&Nervous
And the group chat contains the following members
| Nervous |
Then the group chat is created
And the group chat history contains "created the group" message
And the chat title is Athletic&Nervous
And the group chat contains the following members
| Athletic |
| Nervous |
And the group chat is up to chat sending "Admin user message sent" message
And the group chat is up to chat sending "Admin user message sent" message
# Invited user 1
When the user restarts the app
@ -36,4 +36,28 @@ Feature: Status Desktop Group Chat
When the user clicks on Athletic&Nervous chat
Then the group chat is up to chat sending "Invited user 2 message sent!!" message
# TODO: Add cleanup scenario. Leave, one by one, the chat
# TODO: Add cleanup scenario. Leave, one by one, the chat
Scenario: As an admin user I want to change group chat's name, color and image
When the user creates a group chat adding users
| Athletic |
| Nervous |
Then the group chat is created
When the user opens the edit group chat popup
And the user changes the group name to Fat&Lazy
And the user saves changes
Then the chat title is Fat&Lazy
When the user opens the edit group chat popup
And the user changes the group color to #7CDA00
And the user saves changes
Then the chat color is #7CDA00
When the user opens the edit group chat popup
And the user changes the group image
And the user saves changes
Then the chat image is changed
When the user leaves current chat
Then chat Fat&Lazy does not exist

View File

@ -15,6 +15,7 @@ import StatusQ.Popups.Dialog 0.1
StatusDialog {
id: root
objectName: "groupChatEdit_main"
property string activeGroupImageData
property string activeGroupColor
@ -52,6 +53,7 @@ StatusDialog {
StatusInput {
id: groupName
input.edit.objectName: "groupChatEdit_name"
Layout.alignment: Qt.AlignHCenter
label: qsTr("Name the group")
charLimit: d.nameCharLimit
@ -66,7 +68,7 @@ StatusDialog {
EditCroppedImagePanel {
id: imageEditor
objectName: "groupChatEdit_image"
Layout.preferredWidth: 128
Layout.preferredHeight: Layout.preferredWidth / aspectRatio
Layout.alignment: Qt.AlignHCenter
@ -121,6 +123,7 @@ StatusDialog {
StatusColorSelectorGrid {
id: colorSelectionGrid
objectName: "groupChatEdit_color"
Layout.alignment: Qt.AlignHCenter
diameter: 40
selectorDiameter: 16
@ -138,6 +141,7 @@ StatusDialog {
rightButtons: ObjectModel {
StatusButton {
id: saveBtn
objectName: "groupChatEdit_save"
text: qsTr("Save changes")
enabled: groupName.text.trim().length > 0 &&
((groupName.text != root.activeGroupName) ||

View File

@ -77,6 +77,7 @@ StatusPopupMenu {
}
StatusMenuItem {
objectName: "editNameAndImageMenuItem"
text: qsTr("Edit name and image")
icon.name: "edit_pencil"
enabled: root.chatType === Constants.chatType.privateGroupChat

View File

@ -147,6 +147,7 @@ Item {
StatusChatList {
id: channelList
objectName: "ContactsColumnView_chatList"
width: scroll.availableWidth
model: SortFilterProxyModel {
sourceModel: root.chatSectionModule.model

View File

@ -202,6 +202,7 @@ Item {
StatusBaseText {
id: usernameText
objectName: "currentUserNameLabel"
text: root.startupStore.selectedLoginAccount.username
font.pixelSize: 17
anchors.left: userImage.right

View File

@ -35,6 +35,8 @@ Item {
property bool userSelectedImage: false
readonly property bool nothingToShow: state === d.noImageState
readonly property alias cropWorkflow : imageCropWorkflow
function chooseImageToCrop() {
imageCropWorkflow.chooseImageToCrop()
}