77import configs
88import driver
99from driver .objects_access import walk_children
10+ from driver .toplevel_window import set_focus
1011from gui .components .activity_center import ActivityCenter
1112from gui .components .context_menu import ContextMenu
1213from gui .components .delete_popup import DeleteMessagePopup
1516from gui .components .messaging .close_chat_popup import CloseChatPopup
1617from gui .components .messaging .edit_group_name_and_image_popup import EditGroupNameAndImagePopup
1718from gui .components .messaging .leave_group_popup import LeaveGroupPopup
19+ from gui .components .messaging .link_preview_options_popup import LinkPreviewOptionsPopup
1820from gui .elements .button import Button
1921from gui .elements .list import List
2022from 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
184202class 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 ()
0 commit comments