test: pin and unpin message test added

This commit is contained in:
Valentina Novgorodtceva 2024-01-24 20:53:26 +07:00 committed by Valentina1133
parent 30eba15010
commit 0b2bcd2999
6 changed files with 134 additions and 3 deletions

View File

@ -52,4 +52,4 @@ boundaries = {
class ColorCodes(Enum):
GREEN = '#4ebc60'
BLUE = '#2a4af5'
ORANGE = '#ff9f0f'

View File

@ -43,6 +43,7 @@ statusToolBar_statusSmartIdenticonLetter_StatusLetterIdenticon = {"container": m
statusToolBar_statusChatInfoButtonNameText_TruncatedTextWithTooltip = {"container": mainWindow_statusToolBar_StatusToolBar, "objectName": "statusChatInfoButtonNameText", "type": "TruncatedTextWithTooltip", "visible": True}
statusToolBar_TruncatedTextWithTooltip = {"container": mainWindow_statusToolBar_StatusToolBar, "type": "TruncatedTextWithTooltip", "unnamed": 1, "visible": True}
statusToolBar_chatInfoBtnInHeader_StatusChatInfoButton = {"checkable": False, "container": mainWindow_statusToolBar_StatusToolBar, "objectName": "chatInfoBtnInHeader", "type": "StatusChatInfoButton", "visible": True}
statusToolBar_StatusChatInfo_pinText_TruncatedTextWithTooltip = {"container": mainWindow_statusToolBar_StatusToolBar, "objectName": "StatusChatInfo_pinText", "type": "TruncatedTextWithTooltip", "visible": True}
# Chat
mainWindow_ChatMessagesView = {"container": mainWindow_StatusWindow, "type": "ChatMessagesView", "unnamed": 1, "visible": True}

View File

@ -41,6 +41,7 @@ mainWindow_inputScrollView_StatusScrollView = {"container": statusDesktop_mainWi
inputScrollView_Message_PlaceholderText = {"container": mainWindow_inputScrollView_StatusScrollView, "text": "Message", "type": "PlaceholderText", "unnamed": 1, "visible": True}
mainWindow_scrollView_StatusScrollView = {"container": mainWindow_StatusWindow, "id": "scrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True}
scrollView_StatusChatListItem = {"container": mainWindow_scrollView_StatusScrollView, "type": "StatusChatListItem", "visible": True}
tiny_pin_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "tiny/pin-icon", "type": "StatusIcon"}
# User List Panel
mainWindow_UserListPanel = {"container": mainWindow_chatView_ChatView, "type": "UserListPanel", "unnamed": 1, "visible": True}
@ -50,3 +51,12 @@ userListPanel_StatusMemberListItem = {"container": mainWindow_UserListPanel, "ty
mainWindow_userListPanel_StatusListView = {"container": statusDesktop_mainWindow, "objectName": "userListPanel", "type": "StatusListView", "visible": True}
groupUserListPanel_StatusMemberListItem = {"container": mainWindow_userListPanel_StatusListView, "type": "StatusMemberListItem", "unnamed": 1, "visible": True}
# Message quick actions
mainWindow_chatLogView_StatusListView = {"container": statusDesktop_mainWindow, "objectName": "chatLogView", "type": "StatusListView", "visible": True}
chatLogView_chatMessageViewDelegate_MessageView = {"container": mainWindow_chatLogView_StatusListView, "index": 0, "objectName": "chatMessageViewDelegate", "type": "MessageView", "visible": True}
chatMessageViewDelegate_StatusMessageQuickActions = {"container": chatLogView_chatMessageViewDelegate_MessageView, "type": "StatusMessageQuickActions", "unnamed": 1, "visible": True}
chatMessageViewDelegate_MessageView_toggleMessagePin_StatusFlatRoundButton = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "MessageView_toggleMessagePin", "type": "StatusFlatRoundButton", "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}

View File

@ -213,6 +213,12 @@ class EditCommunityView(QObject):
self._scroll.vertical_scroll_to(self._outro_text_edit)
self._outro_text_edit.text = value
@property
@allure.step('Get pin message checkbox state')
def pin_message_checkbox_state(self) -> bool:
self._scroll.vertical_scroll_to(self._pin_messages_checkbox)
return self._pin_messages_checkbox.object.checked
@allure.step('Edit community')
def edit(self, kwargs):
for key in list(kwargs):
@ -421,7 +427,8 @@ class PermissionsSettingsView(QObject):
@allure.step('Get title of inCommunity tag')
def get_in_community_in_channel_tags_titles(self) -> typing.List[str]:
in_community_in_channel_tags = [str(tag.title) for tag in driver.findAllObjects(self._in_community_in_channel_tag.real_name)]
in_community_in_channel_tags = [str(tag.title) for tag in
driver.findAllObjects(self._in_community_in_channel_tag.real_name)]
return in_community_in_channel_tags
@allure.step('Set state of who holds checkbox')

View File

@ -68,6 +68,10 @@ class ToolBar(QObject):
def __init__(self):
super().__init__('mainWindow_statusToolBar_StatusToolBar')
self.pinned_message_tooltip = QObject('statusToolBar_StatusChatInfo_pinText_TruncatedTextWithTooltip')
def is_pin_message_tooltip_visible(self) -> bool:
return self.pinned_message_tooltip.is_visible
class Message:
@ -110,6 +114,30 @@ class Message:
self.delegate_button.click()
return CommunityScreen().wait_until_appears()
@allure.step('Hover message')
def hover_message(self):
self.delegate_button.hover()
return MessageQuickActions()
@allure.step('Get color of message background')
def get_message_color(self) -> str:
return self.delegate_button.object.background.color.name
@property
@allure.step('Get user name in pinned message details')
def user_name_in_pinned_message(self) -> str:
return str(self.delegate_button.object.pinnedBy)
@property
@allure.step('Get info text in pinned message details')
def pinned_info_text(self) -> str:
return str(self.delegate_button.object.pinnedMsgInfoText)
@property
@allure.step('Get message pinned state')
def message_is_pinned(self) -> bool:
return self.delegate_button.object.isPinned
class ChatView(QObject):
@ -126,6 +154,18 @@ class ChatView(QObject):
_messages.append(Message(item))
return _messages
def find_message_by_text(self, message_text):
message = None
started_at = time.monotonic()
while message is None:
for _message in self.messages:
if message_text in _message.text:
message = _message
break
if time.monotonic() - started_at > configs.timeouts.MESSAGING_TIMEOUT_SEC:
raise LookupError(f'Message not found')
return message
@allure.step('Accept community invitation')
def accept_community_invite(self, community: str) -> 'CommunityScreen':
message = None
@ -216,7 +256,18 @@ class ChatMessagesView(QObject):
@allure.step('Send message to group chat')
def send_message_to_group_chat(self, message: str):
self._message_field.type_text(message)
driver.nativeType('<Return>')
for i in range(2):
driver.nativeType('<Return>')
class MessageQuickActions(QObject):
def __init__(self):
super().__init__('chatMessageViewDelegate_StatusMessageQuickActions')
self._pin_button = Button('chatMessageViewDelegate_MessageView_toggleMessagePin_StatusFlatRoundButton')
@allure.step('Toggle pin button')
def toggle_pin(self):
self._pin_button.click()
class Members(QObject):

View File

@ -0,0 +1,62 @@
from datetime import datetime
import allure
import pytest
from allure_commons._allure import step
import configs
import constants
from constants import ColorCodes
from gui.main_window import MainWindow
from gui.screens.community_settings import CommunitySettingsScreen
from gui.screens.messages import MessagesScreen
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703255',
'Edit chat - Add pinned message (when any member can pin is disabled)')
@pytest.mark.case(703255, 703256)
@pytest.mark.parametrize('user_data', [configs.testpath.TEST_USER_DATA / 'squisher'])
@pytest.mark.parametrize('user_account', [constants.user.user_account_one])
@pytest.mark.parametrize('community_params', [
{
'name': f'Name_{datetime.now():%H%M%S}',
'description': f'Description_{datetime.now():%H%M%S}',
'color': '#ff7d46',
},
])
def test_pin_and_unpin_message_in_community(main_screen: MainWindow, community_params, user_account):
with step('Create community'):
main_screen.create_community(constants.community_params)
with step('Go to edit community and check that pin message checkbox is not checked'):
community_screen = main_screen.left_panel.select_community(constants.community_params['name'])
community_setting = community_screen.left_panel.open_community_settings()
edit_community_form = community_setting.left_panel.open_overview().open_edit_community_view()
assert not edit_community_form.pin_message_checkbox_state
with step('Go back to community and send message in general channel'):
CommunitySettingsScreen().left_panel.back_to_community()
messages_screen = MessagesScreen()
message_text = "Hi"
messages_screen.group_chat.send_message_to_group_chat(message_text)
message_objects = messages_screen.chat.messages
message_items = [message.text for message in message_objects]
for message_item in message_items:
assert message_text in message_item
with step('Hover message and pin it'):
message = messages_screen.chat.find_message_by_text(message_text)
message.hover_message().toggle_pin()
with step('Verify that the message was pinned'):
assert message.message_is_pinned
assert message.pinned_info_text + message.user_name_in_pinned_message == 'Pinned by' + user_account.name
assert message.get_message_color() == ColorCodes.ORANGE.value
with step('Hover message and unpin it'):
message.hover_message().toggle_pin()
with step('Verify that the message was unpinned'):
assert not message.message_is_pinned
assert message.user_name_in_pinned_message == ''
assert messages_screen.tool_bar.is_pin_message_tooltip_visible