2023-10-13 15:55:44 +00:00
|
|
|
import allure
|
|
|
|
|
|
|
|
import configs.timeouts
|
|
|
|
import driver
|
|
|
|
from driver.objects_access import walk_children
|
2024-02-27 08:30:54 +00:00
|
|
|
from gui.components.settings.build_your_showcase_popup import BuildShowcasePopup
|
2023-10-13 15:55:44 +00:00
|
|
|
from gui.components.social_links_popup import SocialLinksPopup
|
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.scroll import Scroll
|
|
|
|
from gui.elements.text_edit import TextEdit
|
|
|
|
from gui.elements.text_label import TextLabel
|
2024-07-09 10:05:39 +00:00
|
|
|
from gui.objects_map import settings_names, names
|
2023-10-13 15:55:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProfileSettingsView(QObject):
|
|
|
|
|
|
|
|
def __init__(self):
|
2024-07-09 10:05:39 +00:00
|
|
|
super().__init__(settings_names.mainWindow_MyProfileView)
|
2024-07-10 05:00:53 +00:00
|
|
|
self._scroll_view = Scroll(settings_names.settingsContentBase_ScrollView)
|
2024-07-09 10:05:39 +00:00
|
|
|
self._display_name_text_field = TextEdit(settings_names.displayName_TextEdit)
|
2024-02-14 10:04:51 +00:00
|
|
|
self._save_button = Button(names.mainWindow_Save_changes_StatusButton)
|
2024-07-09 10:05:39 +00:00
|
|
|
self._bio_text_field = TextEdit(settings_names.bio_TextEdit)
|
|
|
|
self._add_more_links_label = TextLabel(settings_names.addMoreSocialLinks)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._links_list = QObject(names.linksView)
|
2024-07-09 10:05:39 +00:00
|
|
|
self._web_tab_button = Button(settings_names.profileTabBar_Web_StatusTabButton)
|
|
|
|
self._identity_tab_button = Button(settings_names.profileTabBar_Identity_StatusTabButton)
|
2023-10-13 15:55:44 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get display name')
|
2024-03-07 10:48:41 +00:00
|
|
|
def get_display_name(self) -> str:
|
2024-02-08 09:28:36 +00:00
|
|
|
self._identity_tab_button.click()
|
2023-10-13 15:55:44 +00:00
|
|
|
return self._display_name_text_field.text
|
|
|
|
|
|
|
|
@allure.step('Set user name')
|
|
|
|
def set_name(self, value: str):
|
2024-02-08 09:28:36 +00:00
|
|
|
self._identity_tab_button.click()
|
2023-10-13 15:55:44 +00:00
|
|
|
self._display_name_text_field.text = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get bio')
|
2024-03-07 10:48:41 +00:00
|
|
|
def get_bio(self) -> str:
|
2024-02-08 09:28:36 +00:00
|
|
|
self._identity_tab_button.click()
|
2023-10-13 15:55:44 +00:00
|
|
|
return self._bio_text_field.text
|
|
|
|
|
|
|
|
@allure.step('Set bio')
|
2024-03-07 10:48:41 +00:00
|
|
|
def set_bio(self, value: str):
|
2024-02-08 09:28:36 +00:00
|
|
|
self._identity_tab_button.click()
|
2023-10-13 15:55:44 +00:00
|
|
|
self._bio_text_field.text = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get social links')
|
2024-03-07 10:48:41 +00:00
|
|
|
def get_social_links(self) -> dict:
|
2024-02-08 09:28:36 +00:00
|
|
|
self._web_tab_button.click()
|
2024-02-27 08:30:54 +00:00
|
|
|
if BuildShowcasePopup().is_visible:
|
|
|
|
BuildShowcasePopup().close()
|
2023-10-13 15:55:44 +00:00
|
|
|
links = {}
|
|
|
|
for link_name in walk_children(
|
|
|
|
driver.waitForObjectExists(self._links_list.real_name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)):
|
|
|
|
if getattr(link_name, 'id', '') == 'draggableDelegate':
|
|
|
|
for link_value in walk_children(link_name):
|
|
|
|
if getattr(link_value, 'id', '') == 'textMouseArea':
|
|
|
|
links[str(link_name.title)] = str(driver.object.parent(link_value).text)
|
|
|
|
return links
|
|
|
|
|
|
|
|
@allure.step('Set social links')
|
2024-03-07 10:48:41 +00:00
|
|
|
def set_social_links(self, links):
|
2023-10-13 15:55:44 +00:00
|
|
|
links = {
|
2024-03-05 07:22:02 +00:00
|
|
|
0: [links[0]],
|
|
|
|
1: [links[1]],
|
|
|
|
2: [links[2]],
|
|
|
|
3: [links[3]],
|
|
|
|
4: [links[4]],
|
|
|
|
5: [links[5]],
|
|
|
|
6: [links[6], links[7]],
|
2023-10-13 15:55:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-05 07:22:02 +00:00
|
|
|
for index, link in links.items():
|
2023-10-13 15:55:44 +00:00
|
|
|
social_links_popup = self.open_social_links_popup()
|
2024-03-05 07:22:02 +00:00
|
|
|
social_links_popup.add_link(index, link)
|
2023-10-13 15:55:44 +00:00
|
|
|
|
|
|
|
@allure.step('Verify social links')
|
|
|
|
def verify_social_links(self, links):
|
2024-02-08 09:28:36 +00:00
|
|
|
self._web_tab_button.click()
|
2024-02-27 08:30:54 +00:00
|
|
|
if BuildShowcasePopup().is_visible:
|
|
|
|
BuildShowcasePopup().close()
|
2023-10-13 15:55:44 +00:00
|
|
|
twitter = links[0]
|
|
|
|
personal_site = links[1]
|
|
|
|
github = links[2]
|
|
|
|
youtube = links[3]
|
|
|
|
discord = links[4]
|
|
|
|
telegram = links[5]
|
|
|
|
custom_link_text = links[6]
|
|
|
|
custom_link = links[7]
|
|
|
|
|
2024-03-07 10:48:41 +00:00
|
|
|
actual_links = self.get_social_links
|
2023-10-13 15:55:44 +00:00
|
|
|
|
2024-03-05 07:22:02 +00:00
|
|
|
assert actual_links['X (Twitter)'] == twitter
|
|
|
|
assert actual_links['Personal'] == personal_site
|
2023-10-13 15:55:44 +00:00
|
|
|
assert actual_links['Github'] == github
|
2024-03-05 07:22:02 +00:00
|
|
|
assert actual_links['YouTube'] == youtube
|
|
|
|
assert actual_links['Discord'] == discord
|
|
|
|
assert actual_links['Telegram'] == telegram
|
2023-10-13 15:55:44 +00:00
|
|
|
assert actual_links[custom_link_text] == custom_link
|
|
|
|
|
|
|
|
@allure.step('Open social links form')
|
|
|
|
def open_social_links_popup(self):
|
2024-02-08 09:28:36 +00:00
|
|
|
self._web_tab_button.click()
|
2024-02-27 08:30:54 +00:00
|
|
|
if BuildShowcasePopup().is_visible:
|
|
|
|
BuildShowcasePopup().close()
|
2023-10-13 15:55:44 +00:00
|
|
|
self._add_more_links_label.click()
|
|
|
|
return SocialLinksPopup().wait_until_appears()
|