status-desktop/test/e2e/gui/screens/settings_profile.py

121 lines
4.5 KiB
Python
Raw Normal View History

import allure
import configs.timeouts
import driver
from driver.objects_access import walk_children
from gui.components.settings.build_your_showcase_popup import BuildShowcasePopup
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
from gui.objects_map import settings_names, names
class ProfileSettingsView(QObject):
def __init__(self):
super().__init__(settings_names.mainWindow_MyProfileView)
2024-07-10 05:00:53 +00:00
self._scroll_view = Scroll(settings_names.settingsContentBase_ScrollView)
self._display_name_text_field = TextEdit(settings_names.displayName_TextEdit)
self._save_button = Button(names.mainWindow_Save_changes_StatusButton)
self._bio_text_field = TextEdit(settings_names.bio_TextEdit)
self._add_more_links_label = TextLabel(settings_names.addMoreSocialLinks)
self._links_list = QObject(names.linksView)
self._web_tab_button = Button(settings_names.profileTabBar_Web_StatusTabButton)
self._identity_tab_button = Button(settings_names.profileTabBar_Identity_StatusTabButton)
@property
@allure.step('Get display name')
def get_display_name(self) -> str:
2024-02-08 09:28:36 +00:00
self._identity_tab_button.click()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
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()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
self._display_name_text_field.text = value
@property
@allure.step('Get bio')
def get_bio(self) -> str:
2024-02-08 09:28:36 +00:00
self._identity_tab_button.click()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
return self._bio_text_field.text
@allure.step('Set bio')
def set_bio(self, value: str):
2024-02-08 09:28:36 +00:00
self._identity_tab_button.click()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
self._bio_text_field.text = value
@property
@allure.step('Get social links')
def get_social_links(self) -> dict:
2024-02-08 09:28:36 +00:00
self._web_tab_button.click()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
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')
def set_social_links(self, links):
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]],
}
2024-03-05 07:22:02 +00:00
for index, link in links.items():
social_links_popup = self.open_social_links_popup()
2024-03-05 07:22:02 +00:00
social_links_popup.add_link(index, link)
@allure.step('Verify social links')
def verify_social_links(self, links):
2024-02-08 09:28:36 +00:00
self._web_tab_button.click()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
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]
actual_links = self.get_social_links
2024-03-05 07:22:02 +00:00
assert actual_links['X (Twitter)'] == twitter
assert actual_links['Personal'] == personal_site
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
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()
if BuildShowcasePopup().is_visible:
BuildShowcasePopup().close()
self._add_more_links_label.click()
return SocialLinksPopup().wait_until_appears()