test(contact): add a test that sends a contact request from the chat

Fixes #6883
This commit is contained in:
Jonathan Rainville 2022-12-26 16:53:47 -05:00
parent 16af9dfae6
commit 67e0df17e1
22 changed files with 164 additions and 12 deletions

View File

@ -124,6 +124,11 @@ def click_obj_by_name(objName: str):
obj = squish.waitForObject(getattr(names, objName))
squish.mouseClick(obj, squish.Qt.LeftButton)
# It executes the click action into the given object at particular coordinates:
def click_obj_by_name_at_coordinates(objName: str, x: int, y: int):
obj = squish.waitForObject(getattr(names, objName))
squish.mouseClick(obj, x, y, squish.Qt.LeftButton)
def click_obj_by_attr(attr: str):
obj = squish.waitForObject(attr)
squish.mouseClick(obj, squish.Qt.LeftButton)

View File

@ -62,6 +62,12 @@ class ContactsViewScreen(Enum):
CONTACT_REQUEST_SEND_BUTTON: str = "contactRequest_Send_Button"
CONTACT_REQUEST_PENDING_REQUEST_TAB_BUTTON: str = "contactRequest_PendingRequests_Button"
SENT_REQUESTS_CONTACT_PANEL_LIST_VIEW: str = "sentRequests_contactListPanel_ListView"
RECEIVED_REQUESTS_CONTACT_PANEL_LIST_VIEW: str = "receivedRequests_contactListPanel_ListView"
class ProfilePopupScreen(Enum):
PROFILE_POPUP_SEND_CONTACT_REQUEST_BUTTON = "ProfilePopup_SendContactRequestButton"
SAY_WHO_YOU_ARE_INPUT: str = "ProfilePopup_SayWhoYouAre_TextEdit"
SEND_CONTACT_REQUEST_BUTTON: str = "ProfilePopup_SendContactRequest_Button"
class WalletSettingsScreen(Enum):
GENERATED_ACCOUNTS: str = "settings_Wallet_MainView_GeneratedAccounts"
@ -166,6 +172,9 @@ class SettingsScreen:
def open_messaging_settings(self):
click_obj_by_name(SidebarComponents.MESSAGING_ITEM.value)
def open_contacts_settings(self):
click_obj_by_name(MessagingOptionScreen.CONTACTS_BTN.value)
# if link preview is activated do nothing
def activate_link_preview_if_dectivated(self):
click_obj_by_name(SidebarComponents.MESSAGING_ITEM.value)
@ -415,9 +424,8 @@ class SettingsScreen:
click_obj_by_name(ChangePasswordMenu.CHANGE_PASSWORD_SUBMIT_BUTTON.value)
click_obj_by_name(ChangePasswordMenu.CHANGE_PASSWORD_SUCCESS_MENU_SIGN_OUT_QUIT_BUTTON.value)
def add_contact_by_chat_key(self, chat_key: str, who_you_are: str):
click_obj_by_name(MessagingOptionScreen.CONTACTS_BTN.value)
click_obj_by_name(ContactsViewScreen.CONTACT_REQUEST_CHAT_KEY_BTN.value)
type(ContactsViewScreen.CONTACT_REQUEST_CHAT_KEY_INPUT.value, chat_key)
@ -425,6 +433,12 @@ class SettingsScreen:
click_obj_by_name(ContactsViewScreen.CONTACT_REQUEST_SEND_BUTTON.value)
def send_contact_request_via_profile_popup(self, who_you_are: str):
click_obj_by_name(ProfilePopupScreen.PROFILE_POPUP_SEND_CONTACT_REQUEST_BUTTON.value)
type(ProfilePopupScreen.SAY_WHO_YOU_ARE_INPUT.value, who_you_are)
click_obj_by_name(ProfilePopupScreen.SEND_CONTACT_REQUEST_BUTTON.value)
def verify_contact_request(self, chat_key: str):
click_obj_by_name(ContactsViewScreen.CONTACT_REQUEST_PENDING_REQUEST_TAB_BUTTON.value)
contact_list = get_obj(ContactsViewScreen.SENT_REQUESTS_CONTACT_PANEL_LIST_VIEW.value)
@ -436,5 +450,15 @@ class SettingsScreen:
return
contact_keys_tr = ", ".join(contact_keys)
verify_failure(f'The list of pending contacts contains "{contact_keys_tr}" but we wanted the key"{chat_key}"')
def verify_there_is_a_sent_contact_request(self):
click_obj_by_name(ContactsViewScreen.CONTACT_REQUEST_PENDING_REQUEST_TAB_BUTTON.value)
contact_list = get_obj(ContactsViewScreen.SENT_REQUESTS_CONTACT_PANEL_LIST_VIEW.value)
verify_equal(contact_list.count, 1, "Checking if there is exactly one pending contact request")
def verify_there_is_a_received_contact_request(self):
click_obj_by_name(ContactsViewScreen.CONTACT_REQUEST_PENDING_REQUEST_TAB_BUTTON.value)
contact_list = get_obj(ContactsViewScreen.RECEIVED_REQUESTS_CONTACT_PANEL_LIST_VIEW.value)
verify_equal(contact_list.count, 1, "Checking if there is exactly one pending contact request")

View File

@ -44,6 +44,7 @@ class ChatComponents(Enum):
CHAT_LOG = "chatView_log"
LAST_MESSAGE_TEXT = "chatView_lastChatText_Text"
LAST_MESSAGE = "chatView_chatLogView_lastMsg_MessageView"
MESSAGE_DISPLAY_NAME = "StatusMessageHeader_DisplayName"
MEMBERS_LISTVIEW = "chatView_chatMembers_ListView"
CONFIRM_DELETE_MESSAGE_BUTTON = "chatButtonsPanelConfirmDeleteMessageButton_StatusButton"
SUGGESTIONS_BOX = "chatView_SuggestionBoxPanel"
@ -94,6 +95,9 @@ class ChatMessageHoverMenu(Enum):
REPLY_TO_BUTTON = "replyToMessageButton"
EDIT_BUTTON = "editMessageButton"
DELETE_BUTTON = "chatDeleteMessageButton"
class ProfileMenu(Enum):
VIEW_PROFILE_MENU_ITEM = "viewProfile_MenuItem"
class Emoji(Enum):
EMOJI_SUGGESTIONS_FIRST_ELEMENT = "emojiSuggestions_first_inputListRectangle"
@ -200,6 +204,14 @@ class StatusChatScreen:
move_mouse_over_object(found_reply_to_button)
click_obj(found_reply_to_button)
self.send_message(message)
def open_user_profile_from_message_at_index(self, index: int):
message_object = self.get_message_at_index(index)
verify(not is_null(message_object), "Message to click on is loaded")
message_display_name = get_children_with_object_name(message_object, ChatComponents.MESSAGE_DISPLAY_NAME.value)[0]
verify(not is_null(message_display_name), "Message display name found")
right_click_obj(message_display_name)
click_obj_by_name(ProfileMenu.VIEW_PROFILE_MENU_ITEM.value)
def edit_message_at_index(self, index: int, message: str):
message_object_to_edit = wait_and_get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(int(index))

View File

@ -19,6 +19,7 @@ import time
class MainScreenComponents(Enum):
MAIN_WINDOW = "statusDesktop_mainWindow"
POPUP_OVERLAY = "statusDesktop_mainWindow_overlay"
PUBLIC_CHAT_ICON = "mainWindow_public_chat_icon_StatusIcon"
CHAT_NAVBAR_ICON = "navBarListView_Chat_navbar_StatusNavBarTabButton"
COMMUNITY_PORTAL_BUTTON = "navBarListView_Communities_Portal_navbar_StatusNavBarTabButton"
@ -229,3 +230,7 @@ class StatusMainScreen:
def navigate_to_edit_profile(self):
click_obj_by_name(ProfilePopup.EDIT_PROFILE_BUTTON.value)
def close_popup(self):
# Click in the corner of the overlay to close the popup
click_obj_by_name_at_coordinates(MainScreenComponents.POPUP_OVERLAY.value, 1, 1)

View File

@ -26,6 +26,8 @@ class AgreementPopUp(Enum):
class SignUpComponents(Enum):
NEW_TO_STATUS: str = "mainWindow_I_am_new_to_Status_StatusBaseText"
GENERATE_NEW_KEYS: str = "keysMainView_PrimaryAction_Button"
ADD_NEW_USER_MENU_ITEM: str = "accountsView_addNewUser_MenuItem"
CHANGE_ACCOUNT_BTN = "loginView_changeAccountBtn"
USERNAME_INPUT: str = "onboarding_DiplayName_Input"
DETAILS_NEXT_BUTTON: str = "onboarding_DetailsView_NextButton"
WELCOME_TO_STATUS: str = "mainWindow_Welcome_to_Status_StyledText"
@ -79,7 +81,15 @@ class StatusWelcomeScreen:
self.agree_terms_and_conditions()
time.sleep(1)
click_obj_by_name(SignUpComponents.GENERATE_NEW_KEYS.value)
def generate_new_key(self):
self.open_accounts_selector_popup()
click_obj_by_name(SignUpComponents.ADD_NEW_USER_MENU_ITEM.value)
click_obj_by_name(SignUpComponents.GENERATE_NEW_KEYS.value)
def open_accounts_selector_popup(self):
return click_obj_by_name(SignUpComponents.CHANGE_ACCOUNT_BTN.value)
def agree_terms_conditions_and_navigate_to_import_seed_phrase(self):
self.agree_terms_and_conditions()
click_obj_by_name(SeedPhraseComponents.IMPORT_A_SEED_TEXT.value)

View File

@ -18,9 +18,9 @@ splashScreen = {"container": statusDesktop_mainWindow, "objectName": "splashScre
mainWindow_StatusToolBar = {"container": statusDesktop_mainWindow, "objectName": "statusToolBar", "type": "StatusToolBar", "visible": True}
main_toolBar_back_button = {"container": mainWindow_StatusToolBar, "objectName": "toolBarBackButton", "type": "StatusFlatButton", "visible": True}
mainWindow_emptyChatPanelImage = {"container": statusDesktop_mainWindow, "objectName": "emptyChatPanelImage", "type": "Image", "visible": True}
viewProfile_MenuItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "viewProfileMenuItem", "type": "StatusMenuItem", "visible": True}
mainWindow_ContactsColumn_Messages_Headline = {"container": statusDesktop_mainWindow, "objectName": "ContactsColumnView_MessagesHeadline", "type": "StatusNavigationPanelHeadline"}
# main right panel
mainWindow_RighPanel= {"container": statusDesktop_mainWindow, "type": "ColumnLayout", "objectName": "mainRightView", "visible": True}
@ -53,4 +53,5 @@ chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDe
# My Profile Popup
ProfileHeader_userImage = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileHeader_userImage", "type": "UserImage", "visible": True}
ProfilePopup_displayName = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileDialog_displayName", "type": "StatusBaseText", "visible": True}
ProfilePopup_editButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "editProfileButton", "type": "StatusButton", "visible": True}
ProfilePopup_editButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "editProfileButton", "type": "StatusButton", "visible": True}
ProfilePopup_SendContactRequestButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "profileDialog_sendContactRequestButton", "type": "StatusButton", "visible": True}

View File

@ -8,4 +8,5 @@ loginView_submitBtn = {"container": statusDesktop_mainWindow, "type": "StatusRou
loginView_main = {"container": statusDesktop_mainWindow, "type": "LoginView", "visible": True}
loginView_errMsgLabel = {"container": statusDesktop_mainWindow, "objectName": "loginPassworkInputValidationErrorText", "type": "StatusBaseText", "visible": True}
accountsView_accountListPanel = {"container": statusDesktop_mainWindow, "objectName": "LoginView_AccountsRepeater", "type": "Repeater", "visible": True}
accountsView_addNewUser_MenuItem = {"container": statusDesktop_mainWindow, "objectName": "LoginView_addNewUserItem", "type": "AccountMenuItemPanel", "visible": True}
loginView_userImage = {"container": statusDesktop_mainWindow, "objectName": "loginViewUserImage", "type": "UserImage", "visible": True}

View File

@ -112,6 +112,10 @@ contactRequest_Send_Button = {"container": statusDesktop_mainWindow, "objectName
contactRequest_PendingRequests_Button = {"container": statusDesktop_mainWindow, "objectName": "ContactsView_PendingRequest_Button", "type": "StatusTabButton"}
sentRequests_ContactsListPanel = {"container": settingsContentBase_ScrollView, "objectName": "sentRequests_ContactsListPanel", "type": "ContactsListPanel"}
sentRequests_contactListPanel_ListView = {"container": sentRequests_ContactsListPanel, "objectName": "ContactListPanel_ListView", "type": "StatusListView"}
receivedRequests_ContactsListPanel = {"container": settingsContentBase_ScrollView, "objectName": "receivedRequests_ContactsListPanel", "type": "ContactsListPanel"}
receivedRequests_contactListPanel_ListView = {"container": receivedRequests_ContactsListPanel, "objectName": "ContactListPanel_ListView", "type": "StatusListView"}
ProfilePopup_SayWhoYouAre_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileSendContactRequestModal_sayWhoYouAreInput", "type": "TextEdit"}
ProfilePopup_SendContactRequest_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileSendContactRequestModal_sendContactRequestButton", "type": "StatusButton"}
# Communities Settings:
settings_Communities_MainView_LeaveCommunityButtons = {"container": statusDesktop_mainWindow, "objectName":"CommunitiesListPanel_leaveCommunityPopupButton", "type": "StatusBaseButton", "visible": True}

View File

@ -68,6 +68,10 @@ def a_first_time_user_lands_on_and_generates_new_key(context):
a_first_time_user_lands_on(context)
welcome_screen = StatusWelcomeScreen()
welcome_screen.agree_terms_conditions_and_generate_new_key()
def a_user_lands_on_and_generates_new_key(context):
welcome_screen = StatusWelcomeScreen()
welcome_screen.generate_new_key()
def a_first_time_user_lands_on_and_navigates_to_import_seed_phrase(context):
filesMngr.erase_directory(context.userData[_status_data_folder])
@ -79,9 +83,13 @@ def the_user_inputs_username(username: str):
welcome_screen = StatusWelcomeScreen()
welcome_screen.input_username(username)
def the_user_signs_up(user: str, password: str):
def the_user_signs_up(user: str, password: str):
welcome_screen = StatusWelcomeScreen()
welcome_screen.input_username_and_password_and_finalize_sign_up(user, password)
def the_user_signs_again_up(user: str, password: str):
welcome_screen = StatusWelcomeScreen()
welcome_screen.input_username_and_password_again_and_finalize_sign_up(user, password)
def the_user_lands_on_the_signed_in_app():
main_screen = StatusMainScreen()

View File

@ -1,4 +1,5 @@
import steps.commonInitSteps as init_steps
import steps.commonInitSteps as init_steps
from screens.StatusMainScreen import StatusMainScreen
from screens.SettingsScreen import SettingsScreen
@ -78,6 +79,10 @@ def step(context: any):
@When("the user opens the messaging settings")
def step(context: any):
the_user_opens_the_messaging_settings()
@When("the user opens the contacts settings")
def step(context: any):
the_user_opens_the_contact_settings()
@When("the user activates image unfurling")
def step(context: any):
@ -179,6 +184,10 @@ def step(context: any, oldPassword: str, newPassword: str):
@When("the user sends a contact request to the chat key \"|any|\" with the reason \"|any|\"")
def step(context: any, chat_key: str, reason: str):
_settingsScreen.add_contact_by_chat_key(chat_key, reason)
@When("the user sends a contact request with the reason \"|any|\"")
def step(context: any, reason: str):
_settingsScreen.send_contact_request_via_profile_popup(reason)
@When("the user opens own profile popup")
def step(context: any):
@ -188,6 +197,10 @@ def step(context: any):
def step(context: any):
_statusMain.navigate_to_edit_profile()
@When("the user closes the popup")
def step(context: any):
_statusMain.close_popup()
#########################
### VERIFICATIONS region:
#########################
@ -248,6 +261,14 @@ def step(context: any):
@Then("the contact request for chat key \"|any|\" is present in the pending requests tab")
def step(context, chat_key: str):
_settingsScreen.verify_contact_request(chat_key)
@Then("a contact request is present in the sent pending requests tab")
def step(context):
_settingsScreen.verify_there_is_a_sent_contact_request()
@Then("a contact request is present in the received pending requests tab")
def step(context):
_settingsScreen.verify_there_is_a_received_contact_request()
###########################################################################
### COMMON methods used in different steps given/when/then region:
@ -259,6 +280,9 @@ def the_user_opens_app_settings_screen():
def the_user_opens_the_messaging_settings():
_settingsScreen.open_messaging_settings()
def the_user_opens_the_contact_settings():
_settingsScreen.open_contacts_settings()
def the_user_activates_wallet():
wallet_init_steps.the_user_activates_wallet()

View File

@ -79,6 +79,11 @@ def step(context: any, obj: str):
def step(context, room):
the_user_joins_chat_room(room)
# TODO remove when we have a reliable local mailserver
@When("the user waits |any| seconds")
def step(context, amount):
time.sleep(2)
@When("the user joins chats")
def step(context):
the_user_joins_chats(context)

View File

@ -96,11 +96,15 @@ def step(context):
@When("the user sends a chat message \"|any|\"")
def step(context, message):
the_user_sends_a_chat_message(message)
@When("the user replies to the message at index |any| with \"|any|\"")
def step(context, message_index, message):
_statusChat.reply_to_message_at_index(message_index, message)
@When("the user opens the user profile from the message at index |any|")
def step(context, message_index):
_statusChat.open_user_profile_from_message_at_index(message_index)
@When("the user edits the message at index |any| and changes it to \"|any|\"" )
def step(context, message_index, message):
_statusChat.edit_message_at_index(message_index, message)

View File

@ -11,7 +11,7 @@ _mainScreen = StatusMainScreen()
@Given("A first time user lands on the status desktop and generates new key")
def step(context):
init_steps.a_first_time_user_lands_on_and_generates_new_key(context)
init_steps.a_first_time_user_lands_on_and_generates_new_key(context)
@Given("A first time user lands on the status desktop and navigates to import seed phrase")
def step(context):
@ -48,9 +48,17 @@ def step(context, username):
#########################
### ACTIONS region:
########################
@When("the user lands on the status desktop and generates new key")
def step(context):
init_steps.a_user_lands_on_and_generates_new_key(context)
@When("the user signs up with username \"|any|\" and password \"|any|\"")
def step(context, username, password):
init_steps.the_user_signs_up(username, password)
@When("the user signs up again with username \"|any|\" and password \"|any|\"")
def step(context, username, password):
init_steps.the_user_signs_again_up(username, password)
@When("the user inputs username \"|any|\"")
def step(context, username):

View File

@ -11,6 +11,41 @@ Feature: Status Desktop Contacts Flows
Scenario: The user can add a contact with a chat key
When the user opens the messaging settings
And the user opens the contacts settings
And the user sends a contact request to the chat key "zQ3shQihZMmciZWUrjvsY6kUoaqSKp9DFSjMPRkkKGty3XCKZ" with the reason "I am a fellow tester"
Then the contact request for chat key "zQ3shQihZMmciZWUrjvsY6kUoaqSKp9DFSjMPRkkKGty3XCKZ" is present in the pending requests tab
# TODO for future improvements: log into the other account and check that we received the request (will require some cleanup)
# TODO for future improvements: log into the other account and check that we received the request (will require some cleanup)
@relyon-mailserver
Scenario: The user can add a contact from the chat
# User 1 sends a message in the channel
When the user opens the chat section
And the user joins chat room "test-automation"
And the user sends a chat message "I would like new friends"
Then the last chat message contains "I would like new friends"
# User 2 goes to the channel and sends a request from the profile popup
Given the user restarts the app
When the user lands on the status desktop and generates new key
And the user signs up with username "tester2" and password "TesTEr16843/!@00"
And the user lands on the signed in app
And the user joins chat room "test-automation"
# TODO remove when we have a reliable local mailserver
And the user waits 2 seconds
Then the last chat message contains "I would like new friends"
When the user opens the user profile from the message at index 0
And the user sends a contact request with the reason "I am a fellow tester"
And the user closes the popup
And the user opens app settings screen
And the user opens the messaging settings
And the user opens the contacts settings
Then a contact request is present in the sent pending requests tab
# Log back in with User 1 to see if we have the request
Given the user restarts the app
When the user "tester123" logs in with password "TesTEr16843/!@00"
And the user lands on the signed in app
And the user opens app settings screen
And the user opens the messaging settings
And the user opens the contacts settings
Then a contact request is present in the received pending requests tab

View File

@ -1,7 +1,7 @@
source(findFile('scripts', 'python/bdd.py'))
setupHooks('../../global_shared/scripts/bdd_hooks.py')
collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps/', '../../suite_onboarding/shared/steps/')
collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps/', '../../suite_onboarding/shared/steps/', '../../suite_messaging/shared/steps/')
def main():
testSettings.throwOnFailure = True

View File

@ -41,6 +41,7 @@ Item {
spacing: 4
StatusBaseText {
id: primaryDisplayName
objectName: "StatusMessageHeader_DisplayName"
verticalAlignment: Text.AlignVCenter
Layout.bottomMargin: 2 // offset for the underline to stay vertically centered
font.weight: Font.Medium

View File

@ -303,6 +303,7 @@ Item {
}
AccountMenuItemPanel {
objectName: "LoginView_addNewUserItem"
label: qsTr("Add new user")
asset.name: "add"
onClicked: {

View File

@ -155,7 +155,6 @@ StatusModal {
rightButtons: [
StatusButton {
id: btnCreateEdit
enabled: d.validChatKey && messageInput.valid
objectName: "SendContactRequestModal_Send_Button"
text: qsTr("Send Contact Request")

View File

@ -185,6 +185,7 @@ SettingsContentBase {
}
ContactsListPanel {
id: receivedRequests
objectName: "receivedRequests_ContactsListPanel"
Layout.fillWidth: true
title: qsTr("Received")
searchString: searchBox.text

View File

@ -3,6 +3,7 @@ import QtQuick 2.14
import StatusQ.Popups 0.1
StatusAction {
objectName: "viewProfileMenuItem"
text: qsTr("View Profile")
icon.name: "profile"
}

View File

@ -65,6 +65,7 @@ StatusModal {
StatusInput {
id: messageInput
input.edit.objectName: "ProfileSendContactRequestModal_sayWhoYouAreInput"
Layout.fillWidth: true
charLimit: d.maxMsgLength
placeholderText: root.challengeText
@ -82,6 +83,7 @@ StatusModal {
}
rightButtons: StatusButton {
objectName: "ProfileSendContactRequestModal_sendContactRequestButton"
enabled: messageInput.valid
text: root.buttonText
onClicked: {

View File

@ -167,6 +167,7 @@ Pane {
Component {
id: btnSendContactRequestComponent
StatusButton {
objectName: "profileDialog_sendContactRequestButton"
size: StatusButton.Size.Small
text: qsTr("Send Contact Request")
onClicked: {