Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit a051412

Browse files
committed
test: link preview tests added
1 parent b11c233 commit a051412

File tree

8 files changed

+257
-1
lines changed

8 files changed

+257
-1
lines changed

constants/links.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Links for link preview tests
2+
external_link = 'https://github.com/status-im/status-desktop/issues/12018'
3+
link_to_status_community = 'https://status.app/c/G4IAAMSIuU08Lm3oHzSz695ImidijVBxyoFDGEiSYAvADsk9ZVOKYlT2b-lHStyz1MqqkK2Xa4FwoUiq3LBgWsYI_ht6hWXCyLu0TGAk0dGu8IyQWtDSdIXOQ3hWscLjkTo5Vg5-eyUuV8jOVv7khJ_uTofT_TijN-sB#zQ3shZeEJqTC1xhGUjxuS4rtHSrhJ8vUYp64v6qWkLpvdy9L9'
4+
status_user_profile_link = 'https://status.app/u/iwWACgoKCHNxdWlzaGVyAw==#zQ3shvMPZSyaUbjBjaNpNP1bPGsGpQDp59dZ4Gmz7UEy5o791'

constants/messaging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ class Messaging(Enum):
1010
YOU_NEED_TO_BE_A_MEMBER = 'You need to be a member of this group to send messages'
1111
ID_VERIFICATION_REQUEST_SENT = 'ID verification request sent'
1212
ID_VERIFICATION_REPLY_SENT = 'ID verification reply sent'
13+
SHOW_PREVIEWS_TITLE = 'Show link previews?'
14+
SHOW_PREVIEWS_TEXT = 'A preview of your link will be shown here before you send it'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import allure
2+
3+
import configs
4+
from gui.components.base_popup import BasePopup
5+
from gui.elements.button import Button
6+
from gui.elements.object import QObject
7+
from gui.objects_map import names
8+
9+
10+
class LinkPreviewOptionsPopup(BasePopup):
11+
12+
def __init__(self):
13+
super().__init__()
14+
self._show_for_this_message_item = QObject(names.show_for_this_message_StatusMenuItem)
15+
self._always_show_item = QObject(names.always_show_previews_StatusMenuItem)
16+
self._never_show_item = QObject(names.never_show_previews_StatusMenuItem)
17+
18+
@allure.step('Wait until appears {0}')
19+
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
20+
self._show_for_this_message_item.wait_until_appears(timeout_msec)
21+
return self
22+
23+
@allure.step('Wait until hidden {0}')
24+
def wait_until_hidden(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
25+
self._show_for_this_message_item.wait_until_hidden(timeout_msec)
26+
return self
27+
28+
@allure.step('Verify all preview items are present')
29+
def are_all_options_visible(self):
30+
assert self._show_for_this_message_item.is_visible
31+
assert self._always_show_item.is_visible
32+
assert self._never_show_item.is_visible

gui/objects_map/messaging_names.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,14 @@
8080
chatMessageViewDelegate_Save_StatusButton = {"checkable": False, "container": chatLogView_chatMessageViewDelegate_MessageView, "id": "saveBtn", "type": "StatusButton", "unnamed": 1, "visible": True}
8181
chatMessageViewDelegate_reply_icon_StatusIcon = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "reply-icon", "type": "StatusIcon", "visible": True}
8282
mainWindow_replyArea_StatusChatInputReplyArea = {"container": statusDesktop_mainWindow, "id": "replyArea", "type": "StatusChatInputReplyArea", "unnamed": 1, "visible": True}
83+
84+
# Message link preview
85+
mainWindow_optionsComboBox_ComboBox = {"container": statusDesktop_mainWindow, "id": "optionsComboBox", "type": "ComboBox", "unnamed": 1, "visible": True}
86+
mainWindow_settingsCard_LinkPreviewSettingsCard = {"container": statusDesktop_mainWindow, "id": "settingsCard", "type": "LinkPreviewSettingsCard", "unnamed": 1, "visible": True}
87+
mainWindow_closeLinkPreviewButton_StatusFlatRoundButton = {"container": statusDesktop_mainWindow, "objectName": "closeLinkPreviewButton", "type": "StatusFlatRoundButton", "visible": True}
88+
mainWindow_linkPreviewTitleText_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "linkPreviewTitleText", "type": "StatusBaseText", "visible": True}
89+
mainWindow_linkPreviewSubtitleText_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "linkPreviewSubtitleText", "type": "StatusBaseText", "visible": True}
90+
mainWindow_titleText_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "titleText", "type": "StatusBaseText", "visible": True}
91+
mainWindow_subtitleText_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "subtitleText", "type": "StatusBaseText", "visible": True}
92+
linkPreviewTitle_StatusBaseText = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "linkPreviewTitle", "type": "StatusBaseText", "visible": True}
93+
linkPreviewEmojiHash_EmojiHash = {"container": chatLogView_chatMessageViewDelegate_MessageView, "objectName": "linkPreviewEmojiHash", "type": "EmojiHash", "visible": True}

gui/objects_map/names.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@
472472
# Rename keypair popup
473473
save_changes_rename_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "saveRenameKeypairChangesButton", "type": "StatusButton", "visible": True}
474474

475+
# Link preview options popup
476+
show_for_this_message_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Show for this message", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
477+
always_show_previews_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Always show previews", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
478+
never_show_previews_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Never show previews", "type": "StatusMenuItem", "unnamed": 1, "visible": True}
479+
475480
# OS NAMES
476481
# Open Files Dialog
477482
chooseAnImageALogo_QQuickWindow = {"title": RegularExpression("Choose.*"), "type": "QQuickWindow", "unnamed": 1, "visible": True}
@@ -511,6 +516,10 @@
511516
# Messaging View
512517
mainWindow_MessagingView = {"container": statusDesktop_mainWindow, "type": "MessagingView", "unnamed": 1, "visible": True}
513518
contactsListItem_btn_StatusContactRequestsIndicatorListItem = {"container": mainWindow_MessagingView, "objectName": "MessagingView_ContactsListItem_btn", "type": "StatusContactRequestsIndicatorListItem", "visible": True}
519+
settingsContentBase_ScrollView = {"container": statusDesktop_mainWindow, "objectName": "settingsContentBaseScrollView", "type": "StatusScrollView", "visible": True}
520+
always_ask_radioButton_StatusRadioButton = {"container": settingsContentBase_ScrollView, "objectName": "MessagingView_AlwaysAsk_RadioButton", "type": "SettingsRadioButton", "visible": True}
521+
always_show_radioButton_StatusRadioButton = {"container": settingsContentBase_ScrollView, "objectName": "MessagingView_AlwaysShow_RadioButton", "type": "SettingsRadioButton", "visible": True}
522+
never_show_radioButton_StatusRadioButton = {"container": settingsContentBase_ScrollView, "objectName": "MessagingView_NeverShow_RadioButton", "type": "SettingsRadioButton", "visible": True}
514523

515524
# Contacts View
516525
mainWindow_ContactsView = {"container": statusDesktop_mainWindow, "type": "ContactsView", "unnamed": 1, "visible": True}

gui/screens/messages.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import configs
88
import driver
99
from driver.objects_access import walk_children
10+
from driver.toplevel_window import set_focus
1011
from gui.components.activity_center import ActivityCenter
1112
from gui.components.context_menu import ContextMenu
1213
from gui.components.delete_popup import DeleteMessagePopup
@@ -15,6 +16,7 @@
1516
from gui.components.messaging.close_chat_popup import CloseChatPopup
1617
from gui.components.messaging.edit_group_name_and_image_popup import EditGroupNameAndImagePopup
1718
from gui.components.messaging.leave_group_popup import LeaveGroupPopup
19+
from gui.components.messaging.link_preview_options_popup import LinkPreviewOptionsPopup
1820
from gui.elements.button import Button
1921
from gui.elements.list import List
2022
from gui.elements.object import QObject
@@ -124,6 +126,10 @@ def __init__(self, obj):
124126
self.from_user: typing.Optional[str] = None
125127
self.text: typing.Optional[str] = None
126128
self.delegate_button: typing.Optional[Button] = None
129+
self.reply_corner: typing.Optional[QObject] = None
130+
self.link_preview: typing.Optional[QObject] = None
131+
self.link_preview_title_object: typing.Optional[QObject] = None
132+
self.link_preview_emoji_hash: typing.Optional[str] = None
127133
self.community_invitation: dict = {}
128134
self.init_ui()
129135

@@ -135,6 +141,10 @@ def init_ui(self):
135141
self.community_invitation['name'] = str(child.text)
136142
elif getattr(child, 'id', '') == 'description':
137143
self.community_invitation['description'] = str(child.text)
144+
elif getattr(child, 'id', '') == 'titleLayout':
145+
self.link_preview_title_object = child
146+
elif getattr(child, 'objectName', '') == 'linkPreviewEmojiHash':
147+
self.link_preview_emoji_hash = str(child.publicKey)
138148
else:
139149
match getattr(child, 'id', ''):
140150
case 'profileImage':
@@ -149,6 +159,8 @@ def init_ui(self):
149159
self.reply_corner = QObject(real_name=driver.objectMap.realName(child))
150160
case 'delegate':
151161
self.delegate_button = Button(real_name=driver.objectMap.realName(child))
162+
case 'linksMessageView':
163+
self.link_preview = QObject(real_name=driver.objectMap.realName(child))
152164

153165
@allure.step('Open community invitation')
154166
def open_community_invitation(self):
@@ -180,6 +192,12 @@ def pinned_info_text(self) -> str:
180192
def message_is_pinned(self) -> bool:
181193
return self.delegate_button.object.isPinned
182194

195+
@allure.step('Get title of link preview')
196+
def get_link_preview_title(self) -> str:
197+
for child in walk_children(self.link_preview_title_object):
198+
if getattr(child, 'objectName', '') == 'linkPreviewTitle':
199+
return str(child.text)
200+
183201

184202
class ChatView(QObject):
185203

@@ -273,6 +291,13 @@ def __init__(self):
273291
self._message_input_area = QObject(messaging_names.inputScrollView_messageInputField_TextArea)
274292
self._message_field = TextEdit(messaging_names.inputScrollView_Message_PlaceholderText)
275293
self._emoji_button = Button(messaging_names.mainWindow_statusChatInputEmojiButton_StatusFlatRoundButton)
294+
self._link_preview_title = QObject(messaging_names.mainWindow_linkPreviewTitleText_StatusBaseText)
295+
self._link_preview_preview_subtitle = QObject(messaging_names.mainWindow_linkPreviewSubtitleText_StatusBaseText)
296+
self._link_preview_show_preview = QObject(messaging_names.mainWindow_titleText_StatusBaseText)
297+
self._link_preview_show_description = QObject(messaging_names.mainWindow_subtitleText_StatusBaseText)
298+
self._link_preview_card = QObject(messaging_names.mainWindow_settingsCard_LinkPreviewSettingsCard)
299+
self._options_combobox = QObject(messaging_names.mainWindow_optionsComboBox_ComboBox)
300+
self._close_preview_button = QObject(messaging_names.mainWindow_closeLinkPreviewButton_StatusFlatRoundButton)
276301

277302
@property
278303
@allure.step('Get group name')
@@ -322,10 +347,50 @@ def leave_group(self):
322347

323348
@allure.step('Send message to group chat')
324349
def send_message_to_group_chat(self, message: str):
350+
self.type_message(message)
351+
self.confirm_sending_message()
352+
353+
@allure.step('Type text to message field')
354+
def type_message(self, message: str):
325355
self._message_field.type_text(message)
356+
357+
@allure.step('Confirm sending message')
358+
def confirm_sending_message(self):
359+
self._message_input_area.click()
326360
for i in range(2):
327361
driver.nativeType('<Return>')
328362

363+
@allure.step('Click options combobox')
364+
def click_options(self):
365+
self._options_combobox.click()
366+
return LinkPreviewOptionsPopup().wait_until_appears()
367+
368+
@allure.step('Close link preview popup by clicking preview bubble area')
369+
def close_link_preview_popup(self):
370+
self._link_preview_card.click()
371+
LinkPreviewOptionsPopup().wait_until_hidden()
372+
return self
373+
374+
@allure.step('Get text of title of link preview bubble')
375+
def get_link_preview_bubble_title(self) -> str:
376+
return str(self._link_preview_title.object.text)
377+
378+
@allure.step('Get text of description of link preview bubble')
379+
def get_link_preview_bubble_description(self) -> str:
380+
return str(self._link_preview_preview_subtitle.object.text)
381+
382+
@allure.step('Get text of title of show link preview bubble')
383+
def get_show_link_preview_bubble_title(self) -> str:
384+
return str(self._link_preview_show_preview.object.text)
385+
386+
@allure.step('Get text of description of show link preview bubble')
387+
def get_show_link_preview_bubble_description(self) -> str:
388+
return str(self._link_preview_show_description.object.text)
389+
390+
@allure.step('Get close button visibility state')
391+
def does_close_button_exist(self) -> bool:
392+
return self._close_preview_button.is_visible
393+
329394
@allure.step('Send emoji to chat')
330395
def send_emoji_to_chat(self, emoji: str):
331396
self._emoji_button.click()

gui/screens/settings_messaging.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ class MessagingSettingsView(QObject):
2222
def __init__(self):
2323
super().__init__(names.mainWindow_MessagingView)
2424
self._contacts_button = Button(names.contactsListItem_btn_StatusContactRequestsIndicatorListItem)
25+
self._always_ask_button = Button(names.always_ask_radioButton_StatusRadioButton)
26+
self._always_show_button = Button(names.always_show_radioButton_StatusRadioButton)
27+
self._never_ask_button = Button(names.never_show_radioButton_StatusRadioButton)
2528

2629
@allure.step('Open contacts settings')
2730
def open_contacts_settings(self) -> 'ContactsSettingsView':
2831
self._contacts_button.click()
2932
return ContactsSettingsView()
3033

34+
@allure.step('Choose always show previews from website links preview options')
35+
def click_always_show(self):
36+
self._always_show_button.click()
37+
3138

3239
class ContactItem:
3340

@@ -101,7 +108,8 @@ def __init__(self):
101108
self._verify_identity_item = QObject(names.verify_Identity_StatusMenuItem)
102109
self._respond_to_id_request_item = QObject(names.respond_to_ID_Request_StatusMenuItem)
103110
self._view_profile_item = QObject(names.view_Profile_StatusMenuItem)
104-
self._respond_to_id_request_button = Button(names.settingsContentBaseScrollView_Respond_to_ID_Request_StatusFlatButton)
111+
self._respond_to_id_request_button = Button(
112+
names.settingsContentBaseScrollView_Respond_to_ID_Request_StatusFlatButton)
105113

106114
@property
107115
@allure.step('Get contact items')

0 commit comments

Comments
 (0)