2023-09-22 08:44:29 +00:00
|
|
|
import time
|
|
|
|
import typing
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_edit import TextEdit
|
2023-10-09 17:04:29 +00:00
|
|
|
from .base_popup import BasePopup
|
2024-02-13 09:04:24 +00:00
|
|
|
from ..objects_map import names
|
2023-09-22 08:44:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SocialLinksPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(SocialLinksPopup, self).__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._add_social_link_list_item = QObject(names.socialLink_StatusListItem)
|
|
|
|
self._social_link_text_field = TextEdit(names.edit_TextEdit)
|
|
|
|
self._back_button = Button(names.social_links_back_StatusBackButton)
|
|
|
|
self._add_button = Button(names.social_links_add_StatusBackButton)
|
2023-09-22 08:44:29 +00:00
|
|
|
|
|
|
|
@allure.step('Get social link')
|
2024-03-05 07:22:02 +00:00
|
|
|
def _get_list_item(self, index: int) -> QObject:
|
|
|
|
self._add_social_link_list_item.real_name['index'] = index
|
2023-09-22 08:44:29 +00:00
|
|
|
return self._add_social_link_list_item
|
|
|
|
|
|
|
|
@allure.step('Get social link field')
|
|
|
|
def _get_text_field(self, occurrence: int) -> QObject:
|
|
|
|
key = 'occurrence'
|
|
|
|
if occurrence:
|
|
|
|
self._social_link_text_field.real_name[key] = occurrence + 1
|
|
|
|
else:
|
|
|
|
if key in self._social_link_text_field.real_name:
|
|
|
|
del self._social_link_text_field.real_name[key]
|
|
|
|
return self._social_link_text_field
|
|
|
|
|
|
|
|
@allure.step('Add link to link field')
|
2024-03-05 07:22:02 +00:00
|
|
|
def add_link(self, index: int, links: typing.List[str]):
|
|
|
|
self._get_list_item(index).click()
|
2023-09-22 08:44:29 +00:00
|
|
|
time.sleep(0.5)
|
|
|
|
for occurrence, link in enumerate(links):
|
|
|
|
self._get_text_field(occurrence).text = link
|
|
|
|
self._add_button.click()
|
|
|
|
self.wait_until_hidden()
|