Skip to content

Commit

Permalink
test(contact): add a test that sends a contact request from the chat
Browse files Browse the repository at this point in the history
Fixes #6883
  • Loading branch information
jrainville committed Jan 5, 2023
1 parent 16af9df commit 4048792
Show file tree
Hide file tree
Showing 22 changed files with 164 additions and 12 deletions.
5 changes: 5 additions & 0 deletions test/ui-test/src/drivers/SquishDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 26 additions & 2 deletions test/ui-test/src/screens/SettingsScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -166,6 +172,9 @@ def verify_address(self, address: str):
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)
Expand Down Expand Up @@ -415,16 +424,21 @@ def change_user_password(self, oldPassword: str, newPassword: str):

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)
type(ContactsViewScreen.CONTACT_REQUEST_SAY_WHO_YOU_ARE_INPUT.value, who_you_are)

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)
Expand All @@ -436,5 +450,15 @@ def verify_contact_request(self, chat_key: str):
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")


12 changes: 12 additions & 0 deletions test/ui-test/src/screens/StatusChatScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -200,6 +204,14 @@ def reply_to_message_at_index(self, index: int, message: str):
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))
Expand Down
5 changes: 5 additions & 0 deletions test/ui-test/src/screens/StatusMainScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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"
Expand Down Expand Up @@ -229,3 +230,7 @@ def profile_settings_image_is_updated(self):

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)
12 changes: 11 additions & 1 deletion test/ui-test/src/screens/StatusWelcomeScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -79,7 +81,15 @@ def agree_terms_conditions_and_generate_new_key(self):
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)
Expand Down
5 changes: 3 additions & 2 deletions test/ui-test/testSuites/global_shared/scripts/global_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
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}

Expand Down Expand Up @@ -53,4 +53,5 @@
# 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}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
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}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class SettingsSubsection(Enum):
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}
Expand Down
10 changes: 9 additions & 1 deletion test/ui-test/testSuites/global_shared/steps/commonInitSteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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()
Expand Down
24 changes: 24 additions & 0 deletions test/ui-test/testSuites/global_shared/steps/settingsSteps.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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:
#########################
Expand Down Expand Up @@ -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:
Expand All @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions test/ui-test/testSuites/global_shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@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):
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 4048792

Please sign in to comment.