From 45f016efb9f1fb440fc4d64d9c049cd826cf1de4 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Wed, 22 May 2024 17:09:58 +0700 Subject: [PATCH] test: add contact from community channel test added --- test/e2e/gui/components/profile_popup.py | 24 +++ .../settings/send_contact_request_popup.py | 19 +++ test/e2e/gui/objects_map/names.py | 4 + test/e2e/gui/screens/community.py | 9 + ...communities_adding_contact_from_channel.py | 154 ++++++++++++++++++ 5 files changed, 210 insertions(+) create mode 100644 test/e2e/tests/communities/test_communities_adding_contact_from_channel.py diff --git a/test/e2e/gui/components/profile_popup.py b/test/e2e/gui/components/profile_popup.py index 3ffa4b1be7..ce22dd21af 100644 --- a/test/e2e/gui/components/profile_popup.py +++ b/test/e2e/gui/components/profile_popup.py @@ -1,9 +1,11 @@ import allure import pyperclip +import configs import constants import driver from gui.components.base_popup import BasePopup +from gui.components.settings.send_contact_request_popup import SendContactRequestFromProfile from gui.elements.button import Button from gui.elements.object import QObject from gui.elements.text_label import TextLabel @@ -74,3 +76,25 @@ class ProfilePopup(BasePopup): def edit_profile(self): self._edit_profile_button.click() return ProfileSettingsView() + + @allure.step('Wait until appears {0}') + def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + self._emoji_hash.wait_until_appears(timeout_msec) + return self + + +class ProfilePopupFromMembers(ProfilePopup): + + def __init__(self): + super(ProfilePopupFromMembers, self).__init__() + self._send_request_button = Button(names.send_contact_request_StatusButton) + self._request_id_request_button = Button(names.request_ID_verification_StatusFlatButton) + + @allure.step('Click send request button') + def send_request(self): + self._send_request_button.click() + return SendContactRequestFromProfile().wait_until_appears() + + @allure.step('Get request id button visibility state') + def is_request_id_button_visible(self): + return self._request_id_request_button.is_visible diff --git a/test/e2e/gui/components/settings/send_contact_request_popup.py b/test/e2e/gui/components/settings/send_contact_request_popup.py index 6a35d44df5..0496aa90e7 100644 --- a/test/e2e/gui/components/settings/send_contact_request_popup.py +++ b/test/e2e/gui/components/settings/send_contact_request_popup.py @@ -1,5 +1,6 @@ import allure +import configs from gui.components.base_popup import BasePopup from gui.elements.button import Button from gui.elements.text_edit import TextEdit @@ -20,3 +21,21 @@ class SendContactRequest(BasePopup): self._message_text_edit.text = message self._send_button.click() self.wait_until_hidden() + + +class SendContactRequestFromProfile(BasePopup): + + def __init__(self): + super().__init__() + self._message_text_edit = TextEdit(names.profileSendContactRequestModal_sayWhoYouAreInput_TextEdit) + self._send_button = Button(names.send_contact_request_StatusButton_2) + + @allure.step('Wait until appears {0}') + def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + self._message_text_edit.wait_until_appears(timeout_msec) + return self + + @allure.step('Send contact request') + def send(self, message: str): + self._message_text_edit.text = message + self._send_button.click() diff --git a/test/e2e/gui/objects_map/names.py b/test/e2e/gui/objects_map/names.py index fef98841a4..13ec1c9054 100644 --- a/test/e2e/gui/objects_map/names.py +++ b/test/e2e/gui/objects_map/names.py @@ -93,6 +93,8 @@ profileDialog_userEmojiHash_EmojiHash = {"container": statusDesktop_mainWindow_o edit_TextEdit = {"container": statusDesktop_mainWindow_overlay, "id": "edit", "type": "TextEdit", "unnamed": 1, "visible": True} https_status_app_StatusBaseText = {"container": edit_TextEdit, "type": "StatusBaseText", "unnamed": 1, "visible": True} copy_icon_CopyButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "copy-icon", "type": "CopyButton", "visible": True} +request_ID_verification_StatusFlatButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "requestIDVerification_StatusItem", "type": "StatusFlatButton", "visible": True} +send_contact_request_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "profileDialog_sendContactRequestButton", "type": "StatusButton", "visible": True} # Welcome Status Popup betaConsent_StatusModal = {"container": statusDesktop_mainWindow_overlay, "objectName": "desktopBetaStatusModal", "type": "StatusModal", "visible": True} @@ -178,6 +180,8 @@ o_StatusPinMessageDetails = {"container": statusDesktop_mainWindow_overlay, "typ sendContactRequestModal_ChatKey_Input_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "SendContactRequestModal_ChatKey_Input", "type": "TextEdit", "visible": True} sendContactRequestModal_SayWhoYouAre_Input_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "SendContactRequestModal_SayWhoYouAre_Input", "type": "TextEdit", "visible": True} send_Contact_Request_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "SendContactRequestModal_Send_Button", "type": "StatusButton", "visible": True} +send_contact_request_StatusButton_2 = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "ProfileSendContactRequestModal_sendContactRequestButton", "type": "StatusButton", "visible": True} +profileSendContactRequestModal_sayWhoYouAreInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileSendContactRequestModal_sayWhoYouAreInput", "type": "TextEdit", "visible": True} """ Common """ diff --git a/test/e2e/gui/screens/community.py b/test/e2e/gui/screens/community.py index c867c06ec0..6ff9e4fb5c 100644 --- a/test/e2e/gui/screens/community.py +++ b/test/e2e/gui/screens/community.py @@ -13,6 +13,7 @@ from gui.components.community.community_channel_popups import EditChannelPopup, from gui.components.community.welcome_community import WelcomeCommunityPopup from gui.components.context_menu import ContextMenu from gui.components.delete_popup import DeletePopup, DeleteCategoryPopup +from gui.components.profile_popup import ProfilePopupFromMembers from gui.elements.button import Button from gui.elements.list import List from gui.elements.object import QObject @@ -424,6 +425,14 @@ class Members(QObject): def members(self) -> typing.List[str]: return [str(member.statusListItemTitle.text) for member in driver.findAllObjects(self._member_item.real_name)] + @allure.step('Click member by name') + def click_member(self, member_name: str): + for member in driver.findAllObjects(self._member_item.real_name): + if getattr(member, 'title', '') == member_name: + driver.mouseClick(member) + break + return ProfilePopupFromMembers().wait_until_appears() + @allure.step('Verify member is offline by index') def member_is_offline(self, index: int) -> bool: self._member_item.real_name['index'] = index diff --git a/test/e2e/tests/communities/test_communities_adding_contact_from_channel.py b/test/e2e/tests/communities/test_communities_adding_contact_from_channel.py new file mode 100644 index 0000000000..555698e5c3 --- /dev/null +++ b/test/e2e/tests/communities/test_communities_adding_contact_from_channel.py @@ -0,0 +1,154 @@ +from copy import deepcopy +from datetime import datetime + +import allure +import pytest +from allure_commons._allure import step + +import driver +from gui.components.profile_popup import ProfilePopupFromMembers +from gui.main_window import MainWindow +from . import marks +import configs +import constants +from constants import UserAccount + +pytestmark = marks + + +@allure.testcase('', + '') +@pytest.mark.case() +def test_add_contact_from_community_channel_chat(multiple_instances): + user_one: UserAccount = constants.user_account_one + user_two: UserAccount = constants.user_account_two + user_three: UserAccount = constants.user_account_three + community_params = deepcopy(constants.community_params) + community_params['name'] = f'{datetime.now():%d%m%Y_%H%M%S}' + main_screen = MainWindow() + + with multiple_instances() as aut_one, multiple_instances() as aut_two, multiple_instances() as aut_three: + with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'): + for aut, account in zip([aut_one, aut_two, aut_three], [user_one, user_two, user_three]): + aut.attach() + main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare() + main_screen.authorize_user(account) + main_screen.hide() + + with step(f'User {user_two.name}, get chat key'): + aut_two.attach() + main_screen.prepare() + profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() + chat_key = profile_popup.copy_chat_key + profile_popup.close() + main_screen.hide() + + with step(f'User {user_one.name}, send contact request to {user_two.name}'): + aut_one.attach() + main_screen.prepare() + settings = main_screen.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contact_request_popup = contacts_settings.open_contact_request_form() + contact_request_popup.send(chat_key, f'Hello {user_two.name}') + main_screen.hide() + + with step(f'User {user_two.name}, accept contact request from {user_one.name}'): + aut_two.attach() + main_screen.prepare() + settings = main_screen.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contacts_settings.accept_contact_request(user_one.name) + main_screen.hide() + + with step(f'User {user_three.name}, get chat key'): + aut_three.attach() + main_screen.prepare() + profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() + chat_key = profile_popup.copy_chat_key + profile_popup.close() + main_screen.hide() + + with step(f'User {user_two.name}, send contact request to {user_three.name}'): + aut_two.attach() + main_screen.prepare() + settings = main_screen.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contact_request_popup = contacts_settings.open_contact_request_form() + contact_request_popup.send(chat_key, f'Hello {user_three.name}') + main_screen.hide() + + with step(f'User {user_three.name}, accept contact request from {user_two.name}'): + aut_three.attach() + main_screen.prepare() + settings = main_screen.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contacts_settings.accept_contact_request(user_two.name) + main_screen.hide() + + with step(f'User {user_two.name}, create community and invite {user_one.name} and {user_three.name}'): + aut_two.attach() + main_screen.prepare() + with step('Enable creation of community option'): + settings = main_screen.left_panel.open_settings() + settings.left_panel.open_advanced_settings().enable_creation_of_communities() + main_screen.create_community(community_params['name'], community_params['description'], + community_params['intro'], community_params['outro'], + community_params['logo']['fp'], community_params['banner']['fp']) + main_screen.left_panel.invite_people_in_community([user_one.name], 'Message', community_params['name']) + main_screen.left_panel.invite_people_in_community([user_three.name], 'Message', community_params['name']) + main_screen.hide() + + with step(f'User {user_three.name}, accept invitation from {user_two.name}'): + aut_three.attach() + main_screen.prepare() + messages_view = main_screen.left_panel.open_messages_screen() + chat = messages_view.left_panel.click_chat_by_name(user_two.name) + community_screen = chat.accept_community_invite(community_params['name'], 0) + + with step(f'User {user_three.name}, verify welcome community popup'): + welcome_popup = community_screen.left_panel.open_welcome_community_popup() + assert community_params['name'] in welcome_popup.title + assert community_params['intro'] == welcome_popup.intro + welcome_popup.join().authenticate(user_three.password) + assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Join community button not hidden' + main_screen.hide() + + with step(f'User {user_one.name}, accept invitation from {user_two.name}'): + aut_one.attach() + main_screen.prepare() + messages_view = main_screen.left_panel.open_messages_screen() + chat = messages_view.left_panel.click_chat_by_name(user_two.name) + community_screen = chat.accept_community_invite(community_params['name'], 0) + + with step(f'User {user_one.name}, verify welcome community popup'): + welcome_popup = community_screen.left_panel.open_welcome_community_popup() + assert community_params['name'] in welcome_popup.title + assert community_params['intro'] == welcome_popup.intro + welcome_popup.join().authenticate(user_one.password) + assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Join community button not hidden' + + with step(f'User {user_one.name}, send contact request to {user_three.name} from channel'): + profile_popup = community_screen.right_panel.click_member(user_three.name) + profile_popup.send_request().send(f'Hello {user_three.name}') + ProfilePopupFromMembers().wait_until_appears() + main_screen.hide() + + with step(f'User {user_three.name}, accept contact request from {user_one.name}'): + aut_three.attach() + main_screen.prepare() + settings = main_screen.left_panel.open_settings() + messaging_settings = settings.left_panel.open_messaging_settings() + contacts_settings = messaging_settings.open_contacts_settings() + contacts_settings.accept_contact_request(user_one.name) + main_screen.hide() + + with step(f'User {user_one.name} verify that request ID button appeared in send request popup'): + aut_one.attach() + main_screen.prepare() + profile_popup.is_request_id_button_visible()