test: 1-1 chat, send reply, send emoji, edit, delete and cannot delete other member message

This commit is contained in:
Valentina Novgorodtceva 2024-03-19 17:17:28 +07:00 committed by Anastasiya
parent bdc666f6c4
commit 6581c0d908
7 changed files with 289 additions and 7 deletions

View File

@ -0,0 +1,95 @@
import time
import typing
import allure
import configs.timeouts
import driver
from driver.objects_access import walk_children
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.list import List
from gui.elements.object import QObject
from gui.elements.scroll import Scroll
from gui.objects_map import names
from scripts.tools.image import Image
class ContactRequest:
def __init__(self, obj):
self.object = obj
self.contact_request: typing.Optional[Image] = None
self._accept_button: typing.Optional[Button] = None
self._decline_button: typing.Optional[Button] = None
self._notification_request_state: typing.Optional[Image] = None
self.init_ui()
def __repr__(self):
return self.contact_request
def init_ui(self):
for child in walk_children(self.object):
if str(getattr(child, 'objectName', '')) == 'checkmark-circle-icon':
self._accept_button = Button(real_name=driver.objectMap.realName(child))
elif str(getattr(child, 'objectName', '')) == 'close-circle-icon':
self._decline_button = Button(real_name=driver.objectMap.realName(child))
elif str(getattr(child, 'objectName', '')) == 'StatusMessageHeader_DisplayName':
self.contact_request = str(child.text)
elif str(getattr(child, 'id', '')) == 'textItem':
self._notification_request_state = str(child.text)
@allure.step('Accept request')
def accept(self):
assert self._accept_button is not None, 'Button not found'
self._accept_button.click()
@allure.step('Decline request')
def decline(self):
assert self._decline_button is not None, 'Button not found'
self._decline_button.click()
class ActivityCenter(BasePopup):
def __init__(self):
super(ActivityCenter, self).__init__()
self._activity_center_button = Scroll(names.activityCenterStatusFlatButton)
self._notification_contact_request = QObject(names.o_ActivityNotificationContactRequest)
self._activity_center_panel = QObject(names.activityCenterTopBar_ActivityCenterPopupTopBarPanel)
self._contact_request_list = List(names.contacts_StatusListView)
@property
@allure.step('Get contact items')
def contact_items(self) -> typing.List[ContactRequest]:
return [ContactRequest(item) for item in self._contact_request_list.items]
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self._activity_center_panel.wait_until_appears(timeout_msec)
return self
@allure.step('Click activity center button')
def click_activity_center_button(self, text: str):
for button in driver.findAllObjects(self._activity_center_button.real_name):
if str(getattr(button, 'text', '')) == str(text):
driver.mouseClick(button)
break
return self
@allure.step('Find contact request')
def find_contact_request_in_list(
self, contact: str, timeout_sec: int = configs.timeouts.MESSAGING_TIMEOUT_SEC):
started_at = time.monotonic()
request = None
while request is None:
requests = self.contact_items
for _request in requests:
if _request.contact_request == contact:
request = _request
assert time.monotonic() - started_at < timeout_sec, f'Contact: {contact} not found in {requests}'
return request
@allure.step('Accept contact request')
def accept_contact_request(self, request):
return request.accept()

View File

@ -34,3 +34,9 @@ class DeletePermissionPopup(DeletePopup):
def __init__(self):
super().__init__()
self._delete_button = Button(names.confirm_permission_delete_StatusButton)
class DeleteMessagePopup(DeletePopup):
def __init__(self):
super().__init__()
self._delete_button = Button(names.confirm_delete_message_StatusButton)

View File

@ -160,7 +160,6 @@ communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox = {"checkable": Tr
communityEditPanelScrollView_editCommunityIntroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityIntroInput", "type": "TextEdit", "visible": True}
communityEditPanelScrollView_editCommunityOutroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityOutroInput", "type": "TextEdit", "visible": True}
editPermissionView_Update_permission_StatusButton = {"checkable": False, "container": mainWindow_editPermissionView_EditPermissionView, "objectName": "settingsDirtyToastMessageSaveButton", "type": "StatusButton", "visible": True}
croppedImageEditLogo = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community logo", "type": "EditCroppedImagePanel", "visible": True}
croppedImageEditBanner = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community banner", "type": "EditCroppedImagePanel", "visible": True}

View File

@ -18,6 +18,7 @@ mainWindow_statusToolBar_StatusToolBar = {"container": mainWindow_chatView_ChatV
statusToolBar_Confirm_StatusButton = {"checkable": False, "container": mainWindow_statusToolBar_StatusToolBar, "objectName": "inlineSelectorConfirmButton", "type": "StatusButton", "visible": True}
statusToolBar_Cancel_StatusButton = {"checkable": False, "container": mainWindow_statusToolBar_StatusToolBar, "type": "StatusButton", "unnamed": 1, "visible": True}
statusToolBar_StatusTagItem = {"container": mainWindow_statusToolBar_StatusToolBar, "type": "StatusTagItem", "visible": True}
statusToolBar_notificationButton_StatusActivityCenterButton = {"container": statusDesktop_mainWindow, "objectName": "activityCenterNotificationsButton", "type": "StatusActivityCenterButton", "visible": True}
# Chat View
mainWindow_ChatColumnView = {"container": mainWindow_chatView_ChatView, "type": "ChatColumnView", "unnamed": 1, "visible": True}
@ -50,6 +51,7 @@ tiny_pin_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_Mes
add_remove_from_group_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "type": "StatusMenuItem", "unnamed": 1, "visible": True}
mainWindow_inputScrollView_StatusScrollView = {"container": statusDesktop_mainWindow, "id": "inputScrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True}
inputScrollView_messageInputField_TextArea = {"container": mainWindow_inputScrollView_StatusScrollView, "objectName": "messageInputField", "type": "TextArea", "visible": True}
mainWindow_statusChatInputEmojiButton_StatusFlatRoundButton = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputEmojiButton", "type": "StatusFlatRoundButton", "visible": True}
# User List Panel
mainWindow_UserListPanel = {"container": mainWindow_chatView_ChatView, "type": "UserListPanel", "unnamed": 1, "visible": True}
@ -68,3 +70,6 @@ chatMessageViewDelegate_replyToMessageButton_StatusFlatRoundButton = {"container
chatMessageViewDelegate_editMessageButton_StatusFlatRoundButton = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "editMessageButton", "type": "StatusFlatRoundButton", "visible": True}
chatMessageViewDelegate_markAsUnreadButton_StatusFlatRoundButton = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "markAsUnreadButton", "type": "StatusFlatRoundButton", "visible": True}
chatMessageViewDelegate_chatDeleteMessageButton_StatusFlatRoundButton = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "chatDeleteMessageButton", "type": "StatusFlatRoundButton", "visible": True}
chatMessageViewDelegate_inputScrollView_StatusScrollView = {"container": chatLogView_chatMessageViewDelegate_MessageView, "id": "inputScrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True}
edit_inputScrollView_messageInputField_TextArea = {"container": chatMessageViewDelegate_inputScrollView_StatusScrollView, "objectName": "messageInputField", "type": "TextArea", "visible": True}
chatMessageViewDelegate_Save_StatusButton = {"checkable": False, "container": chatLogView_chatMessageViewDelegate_MessageView, "id": "saveBtn", "type": "StatusButton", "unnamed": 1, "visible": True}

View File

@ -237,6 +237,7 @@ o_StatusDialogBackground = {"container": statusDesktop_mainWindow_overlay, "type
delete_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton", "visible": True}
confirm_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "confirmDeleteCategoryButton", "type": "StatusButton", "visible": True}
confirm_permission_delete_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "confirmButton", "type": "StatusButton", "unnamed": 1, "visible": True}
confirm_delete_message_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "text": "Confirm", "type": "StatusButton", "visible": True}
# Authenticate Popup
keycardSharedPopupContent_KeycardPopupContent = {"container": statusDesktop_mainWindow_overlay, "objectName": "KeycardSharedPopupContent", "type": "KeycardPopupContent", "visible": True}
@ -437,6 +438,13 @@ close_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_
# Build showcase popup
build_your_showcase_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "buildShowcaseButton", "type": "StatusButton", "visible": True}
# Activity center
activityCenterStatusFlatButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "activityCenterButton", "type": "StatusFlatButton", "visible": True}
checkmark_circle_icon_StatusIcon = {"container": statusDesktop_mainWindow_overlay, "objectName": "checkmark-circle-icon", "type": "StatusIcon", "visible": True}
o_ActivityNotificationContactRequest = {"container": statusDesktop_mainWindow_overlay, "type": "ActivityNotificationContactRequest", "unnamed": 1, "visible": True}
activityCenterTopBar_ActivityCenterPopupTopBarPanel = {"container": statusDesktop_mainWindow_overlay, "id": "activityCenterTopBar", "type": "ActivityCenterPopupTopBarPanel", "unnamed": 1, "visible": True}
contacts_StatusListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "unnamed": 1, "visible": True}
# OS NAMES
# Open Files Dialog
chooseAnImageALogo_QQuickWindow = {"title": RegularExpression("Choose.*"), "type": "QQuickWindow", "unnamed": 1, "visible": True}

View File

@ -7,7 +7,10 @@ import allure
import configs
import driver
from driver.objects_access import walk_children
from gui.components.activity_center import ActivityCenter
from gui.components.context_menu import ContextMenu
from gui.components.delete_popup import DeleteMessagePopup
from gui.components.emoji_popup import EmojiPopup
from gui.components.messaging.edit_group_name_and_image_popup import EditGroupNameAndImagePopup
from gui.components.messaging.leave_group_popup import LeaveGroupPopup
from gui.elements.button import Button
@ -69,10 +72,12 @@ class ToolBar(QObject):
def __init__(self):
super().__init__(messaging_names.mainWindow_statusToolBar_StatusToolBar)
self.pinned_message_tooltip = QObject(communities_names.statusToolBar_StatusChatInfo_pinText_TruncatedTextWithTooltip)
self.pinned_message_tooltip = QObject(
communities_names.statusToolBar_StatusChatInfo_pinText_TruncatedTextWithTooltip)
self.confirm_button = Button(messaging_names.statusToolBar_Confirm_StatusButton)
self.status_button = Button(messaging_names.statusToolBar_Cancel_StatusButton)
self.contact_tag = QObject(messaging_names.statusToolBar_StatusTagItem)
self.notifications_button = Button(messaging_names.statusToolBar_notificationButton_StatusActivityCenterButton)
@property
@allure.step('Get visibility of pin message tooltip')
@ -92,6 +97,11 @@ class ToolBar(QObject):
driver.mouseClick(child)
break
@allure.step('Open activity center')
def open_activity_center(self):
self.notifications_button.click()
return ActivityCenter().wait_until_appears()
class Message:
@ -165,7 +175,7 @@ class ChatView(QObject):
self._message_list_item = QObject(messaging_names.chatLogView_chatMessageViewDelegate_MessageView)
@allure.step('Get messages')
def messages(self, index: bool) -> typing.List[Message]:
def messages(self, index: int) -> typing.List[Message]:
_messages = []
# message_list_item has different indexes if we run multiple instances, so we pass index
self._message_list_item.real_name['index'] = index
@ -174,7 +184,7 @@ class ChatView(QObject):
_messages.append(Message(item))
return _messages
def find_message_by_text(self, message_text: str, index: bool):
def find_message_by_text(self, message_text: str, index: int):
message = None
started_at = time.monotonic()
while message is None:
@ -240,6 +250,7 @@ class ChatMessagesView(QObject):
self._add_remove_item = QObject(messaging_names.add_remove_from_group_StatusMenuItem)
self._message_input_area = QObject(messaging_names.inputScrollView_messageInputField_TextArea)
self._message_field = TextEdit(messaging_names.inputScrollView_Message_PlaceholderText)
self._emoji_button = Button(messaging_names.mainWindow_statusChatInputEmojiButton_StatusFlatRoundButton)
@property
@allure.step('Get group name')
@ -258,12 +269,14 @@ class ChatMessagesView(QObject):
@property
@allure.step('Get gray text from message area')
def gray_text_from_message_area(self) -> str:
return driver.waitForObjectExists(self._message_input_area.real_name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC).placeholderText
return driver.waitForObjectExists(self._message_input_area.real_name,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC).placeholderText
@property
@allure.step('Get enabled state of message area')
def is_message_area_enabled(self) -> bool:
return driver.waitForObjectExists(self._message_input_area.real_name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC).enabled
return driver.waitForObjectExists(self._message_input_area.real_name,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC).enabled
@allure.step('Click more options button')
def open_more_options(self):
@ -291,6 +304,13 @@ class ChatMessagesView(QObject):
for i in range(2):
driver.nativeType('<Return>')
@allure.step('Send emoji to chat')
def send_emoji_to_chat(self, emoji: str):
self._emoji_button.click()
EmojiPopup().wait_until_appears().select(emoji)
for i in range(2):
driver.nativeType('<Return>')
@allure.step('Remove member from chat')
def remove_member_from_chat(self, member):
time.sleep(2)
@ -307,12 +327,33 @@ class ChatMessagesView(QObject):
class MessageQuickActions(QObject):
def __init__(self):
super().__init__(messaging_names.chatMessageViewDelegate_StatusMessageQuickActions)
self._pin_button = Button(messaging_names.chatMessageViewDelegate_MessageView_toggleMessagePin_StatusFlatRoundButton)
self._pin_button = Button(
messaging_names.chatMessageViewDelegate_MessageView_toggleMessagePin_StatusFlatRoundButton)
self._edit_button = Button(messaging_names.chatMessageViewDelegate_editMessageButton_StatusFlatRoundButton)
self._delete_button = Button(
messaging_names.chatMessageViewDelegate_chatDeleteMessageButton_StatusFlatRoundButton)
self._edit_message_field = TextEdit(messaging_names.edit_inputScrollView_messageInputField_TextArea)
self._save_text_button = Button(messaging_names.chatMessageViewDelegate_Save_StatusButton)
@allure.step('Toggle pin button')
def toggle_pin(self):
self._pin_button.click()
@allure.step('Edit message and save changes')
def edit_message(self, text: str):
self._edit_button.click()
self._edit_message_field.type_text(text)
self._save_text_button.click()
@allure.step('Delete message')
def delete_message(self):
self._delete_button.click()
DeleteMessagePopup().delete()
@allure.step('Delete button is visible')
def is_delete_button_visible(self) -> bool:
return self._delete_button.is_visible
class Members(QObject):

View File

@ -0,0 +1,128 @@
import time
import allure
import pytest
from allure_commons._allure import step
import driver
from gui.components.activity_center import ContactRequest
from gui.screens.messages import MessagesScreen, ToolBar, ChatMessagesView
from . import marks
import configs.testpath
import constants
from constants import UserAccount
from constants.messaging import Messaging
from gui.main_window import MainWindow
pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703011', 'Add a contact with a chat key')
@pytest.mark.case(703011)
@pytest.mark.parametrize('user_data_one, user_data_two', [
(configs.testpath.TEST_USER_DATA / 'user_account_one', configs.testpath.TEST_USER_DATA / 'user_account_two')
])
def test_1x1_chat(multiple_instance, user_data_one, user_data_two):
user_one: UserAccount = constants.user_account_one
user_two: UserAccount = constants.user_account_two
main_window = MainWindow()
messages_screen = MessagesScreen()
emoji = 'sunglasses'
with (multiple_instance() as aut_one, multiple_instance() as aut_two):
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], [user_one, user_two]):
aut.attach()
main_window.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
main_window.authorize_user(account)
main_window.hide()
with step(f'User {user_two.name}, get chat key'):
aut_two.attach()
main_window.prepare()
profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
chat_key = profile_popup.copy_chat_key
profile_popup.close()
main_window.hide()
with step(f'User {user_one.name}, send contact request to {user_two.name}'):
aut_one.attach()
main_window.prepare()
settings = main_window.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}')
with step(f'User {user_two.name}, accept contact request from {user_one.name} via activity center'):
aut_two.attach()
main_window.prepare()
activity_center = ToolBar().open_activity_center()
request = activity_center.find_contact_request_in_list(user_one.name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
activity_center.click_activity_center_button(
'Contact requests').accept_contact_request(request)
main_window.hide()
with step(f'User {user_one.name} send another message to {user_two.name}, edit it and verify it was changed'):
aut_one.attach()
main_window.prepare()
chat = main_window.left_panel.open_messages_screen().left_panel.open_chat(user_two.name)
ChatMessagesView().send_message_to_group_chat('How are you')
message = chat.find_message_by_text(f'How are you', 0)
additional_text = '?'
time.sleep(5)
message_actions = message.hover_message()
message_actions.edit_message(additional_text)
message_objects = messages_screen.chat.messages(0)
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert 'How are you?' in message_item
main_window.hide()
with step(f'User {user_two.name} opens 1x1 chat with {user_one.name}'):
aut_two.attach()
main_window.prepare()
messages_screen.left_panel.open_chat(user_one.name)
with step(f'User {user_two.name} send reply to {user_one.name}'):
ChatMessagesView().send_message_to_group_chat('Hello squisher')
messages_screen.group_chat.send_message_to_group_chat('Hello squisher')
message_objects = messages_screen.chat.messages(1)
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert 'Hello squisher' in message_item
for message_item in message_items:
assert 'How are you?' in message_item
with step(f'User {user_two.name} send emoji to {user_one.name}'):
messages_screen.group_chat.send_emoji_to_chat(emoji)
message_objects = messages_screen.chat.messages(0)
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert '😎' in message_item
main_window.hide()
with step(f'User {user_one.name}, received reply from {user_two.name}'):
aut_one.attach()
main_window.prepare()
message_objects = messages_screen.chat.messages(1)
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert 'Hello squisher' in message_item
with step(f'User {user_one.name}, received emoji from {user_two.name}'):
time.sleep(2)
message_objects = messages_screen.chat.messages(0)
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert '😎' in message_item
with step(f'User {user_one.name}, delete own message and verify it was deleted'):
message = messages_screen.left_panel.open_chat(user_two.name).find_message_by_text('How are you?', 3)
message.hover_message().delete_message()
with step(f'User {user_one.name}, cannot delete {user_two.name} message'):
message = messages_screen.left_panel.open_chat(user_two.name).find_message_by_text('Hello squisher', 2)
assert not message.hover_message().is_delete_button_visible()
main_window.hide()