test: reply to own message, clearing history

This commit is contained in:
Valentina Novgorodtceva 2024-04-11 17:04:00 +07:00
parent 146a337c4e
commit 4895e8e6e3
5 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,23 @@
import allure
import configs
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.objects_map import names
class ClearChatHistoryPopup(BasePopup):
def __init__(self):
super().__init__()
self._clear_button = Button(names.clear_StatusButton)
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self._clear_button.wait_until_appears(timeout_msec)
return self
@allure.step("Confirm leaving group")
def confirm_clearing_chat(self):
self._clear_button.click()
self._clear_button.wait_until_hidden()

View File

@ -53,6 +53,9 @@ add_remove_from_group_StatusMenuItem = {"checkable": False, "container": mainWin
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}
mark_as_Read_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItem", "visible": True}
clear_History_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "clearHistoryMenuItem", "type": "StatusMenuItem", "visible": True}
close_Chat_StatusMenuItem = {"checkable": False, "container": mainWindow_Overlay, "enabled": True, "objectName": "deleteOrLeaveMenuItem", "type": "StatusMenuItem", "visible": True}
# User List Panel
mainWindow_UserListPanel = {"container": mainWindow_chatView_ChatView, "type": "UserListPanel", "unnamed": 1, "visible": True}
@ -69,10 +72,11 @@ chatMessageViewDelegate_deletedMessage_RowLayout = {"container": chatLogView_cha
chatMessageViewDelegate_StatusMessageQuickActions = {"container": chatLogView_chatMessageViewDelegate_MessageView, "type": "StatusMessageQuickActions", "unnamed": 1, "visible": True}
chatMessageViewDelegate_pin_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "pin-icon", "type": "StatusIcon", "visible": True}
chatMessageViewDelegate_unpin_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "unpin-icon", "type": "StatusIcon", "visible": True}
chatMessageViewDelegate_replyToMessageButton_StatusFlatRoundButton = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton", "visible": True}
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}
chatMessageViewDelegate_reply_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "reply-icon", "type": "StatusIcon", "visible": True}
mainWindow_replyArea_StatusChatInputReplyArea = {"container": statusDesktop_mainWindow, "id": "replyArea", "type": "StatusChatInputReplyArea", "unnamed": 1, "visible": True}

View File

@ -380,6 +380,9 @@ save_changes_StatusButton = {"checkable": False, "container": statusDesktop_main
# Leave group popup
leave_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "leaveGroupConfirmationDialogLeaveButton", "type": "StatusButton", "visible": True}
# Clear chat history popup
clear_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "clearChatConfirmationDialogClearButton", "type": "StatusButton", "visible": True}
# Create Keycard account with new seed phrase popup
cancel_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "cancelButton", "type": "StatusButton", "visible": True}
image_KeycardImage = {"container": statusDesktop_mainWindow_overlay, "id": "image", "type": "KeycardImage", "unnamed": 1, "visible": True}

View File

@ -11,6 +11,7 @@ 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.clear_chat_history_popup import ClearChatHistoryPopup
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
@ -139,6 +140,8 @@ class Message:
self.time = str(child.text)
case 'chatText':
self.text = str(child.text)
case 'replyCorner':
self.reply_corner = QObject(real_name=driver.objectMap.realName(child))
case 'delegate':
self.delegate_button = Button(real_name=driver.objectMap.realName(child))
@ -259,6 +262,7 @@ class ChatMessagesView(QObject):
self._edit_menu_item = QObject(messaging_names.edit_name_and_image_StatusMenuItem)
self._leave_group_item = QObject(messaging_names.leave_group_StatusMenuItem)
self._add_remove_item = QObject(messaging_names.add_remove_from_group_StatusMenuItem)
self._clear_history_item = QObject(messaging_names.clear_History_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)
@ -334,6 +338,14 @@ class ChatMessagesView(QObject):
tool_bar.confirm_action_in_toolbar()
time.sleep(1)
@allure.step('Choose clear history option')
def clear_history(self):
time.sleep(2)
self.open_more_options()
time.sleep(2)
self._clear_history_item.click()
ClearChatHistoryPopup().wait_until_appears().confirm_clearing_chat()
class MessageQuickActions(QObject):
def __init__(self):
@ -344,8 +356,11 @@ class MessageQuickActions(QObject):
self._edit_button = Button(messaging_names.chatMessageViewDelegate_editMessageButton_StatusFlatRoundButton)
self._delete_button = Button(
messaging_names.chatMessageViewDelegate_chatDeleteMessageButton_StatusFlatRoundButton)
self._reply_button = Button(messaging_names.chatMessageViewDelegate_reply_icon_StatusIcon)
self._edit_message_field = TextEdit(messaging_names.edit_inputScrollView_messageInputField_TextArea)
self._reply_area = QObject(messaging_names.mainWindow_replyArea_StatusChatInputReplyArea)
self._save_text_button = Button(messaging_names.chatMessageViewDelegate_Save_StatusButton)
self._message_input_area = TextEdit(messaging_names.inputScrollView_messageInputField_TextArea)
@allure.step('Click pin button')
def pin_message(self):
@ -366,6 +381,14 @@ class MessageQuickActions(QObject):
self._delete_button.click()
DeleteMessagePopup().delete()
@allure.step('Reply to own message')
def reply_own_message(self, text: str):
self._reply_button.click()
assert self._reply_area.exists
self._message_input_area.type_text(text)
for i in range(2):
driver.nativeType('<Return>')
@allure.step('Delete button is visible')
def is_delete_button_visible(self) -> bool:
return self._delete_button.is_visible

View File

@ -7,7 +7,7 @@ import pytest
from allure_commons._allure import step
import driver
from gui.screens.messages import MessagesScreen, ToolBar, ChatMessagesView
from gui.screens.messages import MessagesScreen, ToolBar, ChatMessagesView, ChatView
from tests.settings.settings_messaging import marks
import configs.testpath
@ -120,6 +120,14 @@ def test_1x1_chat(multiple_instances):
for message_item in message_items:
assert driver.waitFor(lambda: '😎' in message_item, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
with step(f'User {user_one.name}, reply to own message and verify that message displayed as a reply'):
chat_message_reply = \
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
message.hover_message().reply_own_message(chat_message_reply)
chat = main_window.left_panel.open_messages_screen().left_panel.click_chat_by_name(user_two.name)
message = chat.find_message_by_text(chat_message_reply, 0)
assert message.reply_corner.exists
with step(f'User {user_one.name}, delete own message and verify it was deleted'):
message = messages_screen.left_panel.click_chat_by_name(user_two.name).find_message_by_text(chat_message1, 2)
message.hover_message().delete_message()