Добавлен компонент Карточка пользователя
parent
d111fc69ed
commit
25710114c2
|
|
@ -6,7 +6,7 @@ from locators.event_panel_locators import EventPanelLocators
|
|||
from elements.tooltip_button_element import TooltipButton
|
||||
from elements.tab_button_element import TabButton
|
||||
from elements.button_element import Button
|
||||
from components.card_component import CardComponent
|
||||
from components_derived.user_card import UserCard
|
||||
from components.base_component import BaseComponent
|
||||
|
||||
logger = get_logger("EVENT_PANEL")
|
||||
|
|
@ -39,7 +39,7 @@ class EventPanelComponent(BaseComponent):
|
|||
self.search_button = Button(page, buttons_service_locators[0], "search_button")
|
||||
self.user_button = Button(page, buttons_service_locators[1], "user_button")
|
||||
|
||||
self.user_card = CardComponent(page)
|
||||
self.user_card = UserCard(page)
|
||||
|
||||
# Действия:
|
||||
def click_expand_less_button(self) -> None:
|
||||
|
|
@ -56,11 +56,16 @@ class EventPanelComponent(BaseComponent):
|
|||
get_by_role("button").filter(has_text='expand_more')
|
||||
button_locator.click()
|
||||
|
||||
def do_logout(self) -> None:
|
||||
"""Выполняет выход из системы."""
|
||||
def click_user_button(self) -> None:
|
||||
"""Выполняет нажатие кнопки пользователя."""
|
||||
|
||||
self.should_be_user_button()
|
||||
self.user_button.click()
|
||||
|
||||
def do_logout(self) -> None:
|
||||
"""Выполняет выход из системы."""
|
||||
|
||||
self.click_user_button()
|
||||
self.user_card.click_logout_button()
|
||||
|
||||
def get_event_tooltip_texts(self) -> []:
|
||||
|
|
@ -123,6 +128,11 @@ class EventPanelComponent(BaseComponent):
|
|||
return False
|
||||
return True
|
||||
|
||||
def check_user_card_content(self):
|
||||
"""Проверяет наличие и корректность элементов карточки пользователя."""
|
||||
|
||||
self.user_card.check_content()
|
||||
|
||||
def should_be_user_button(self) -> None:
|
||||
"""Проверяет наличие кнопки пользователя."""
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
"""Модуль компонента карточки пользователя.
|
||||
|
||||
Содержит класс для работы с карточкой пользователя через Playwright.
|
||||
"""
|
||||
|
||||
from playwright.sync_api import Page
|
||||
from tools.logger import get_logger
|
||||
from locators.user_card_locators import UserCardLocators
|
||||
from elements.text_element import Text
|
||||
from elements.button_element import Button
|
||||
from data.roles_dict import roles_dict
|
||||
from data.environment import host
|
||||
from components.base_component import BaseComponent
|
||||
|
||||
logger = get_logger("USER_CARD")
|
||||
|
||||
|
||||
class UserCard(BaseComponent):
|
||||
"""Компонент карточка.
|
||||
|
||||
Предоставляет методы для взаимодействия с элементами карточки.
|
||||
"""
|
||||
|
||||
def __init__(self, page: Page):
|
||||
"""Инициализирует компонент карточки.
|
||||
|
||||
Args:
|
||||
page: Экземпляр страницы Playwright.
|
||||
"""
|
||||
|
||||
super().__init__(page)
|
||||
|
||||
card_locator = page.locator(UserCardLocators.CARD_USER)
|
||||
|
||||
self.current_user_name = Text(page,
|
||||
card_locator.locator("xpath=/div/div[2]"),
|
||||
"current user name")
|
||||
self.current_user_role = Text(page,
|
||||
card_locator.locator("xpath=/div/div[3]"),
|
||||
"current user role")
|
||||
self.login_time = Text(page,
|
||||
card_locator.locator("xpath=/div/div[4]"),
|
||||
"login time")
|
||||
self.session_time = Text(page,
|
||||
card_locator.locator("xpath=/div/div[5]"),
|
||||
"current user name")
|
||||
self.logout_button = Button(
|
||||
page,
|
||||
page.get_by_role("button", name="Выйти"),
|
||||
"logout button"
|
||||
)
|
||||
self.change_password_button = Button(
|
||||
page,
|
||||
page.get_by_role("button", name="Изменить пароль"),
|
||||
"change password button"
|
||||
)
|
||||
self.settings_button = Button(
|
||||
page,
|
||||
page.get_by_role("button", name="Настройки"),
|
||||
"settings button"
|
||||
)
|
||||
|
||||
# Действия:
|
||||
def click_logout_button(self):
|
||||
"""Нажимает кнопку выхода из системы.
|
||||
|
||||
Выполняет клик по кнопке 'Выйти' в карточке пользователя.
|
||||
"""
|
||||
|
||||
self.logout_button.click()
|
||||
|
||||
# Проверки:
|
||||
def check_content(self):
|
||||
"""Проверяет наличие и корректность элементов карточки пользователя."""
|
||||
|
||||
current_user_credential = host.get_current_user_credential()
|
||||
|
||||
name = current_user_credential["login"]
|
||||
text_to_check = f"Имя пользователя: {name}"
|
||||
self.current_user_name.check_have_text(text_to_check,
|
||||
f"Expected text {text_to_check} is missing in user card")
|
||||
|
||||
role = roles_dict.get(current_user_credential["role"])
|
||||
if role is None:
|
||||
assert False, "Unknown user role in current user credential"
|
||||
text_to_check = f"Роль: {role}"
|
||||
self.current_user_role.check_have_text(text_to_check,
|
||||
f"Expected text {text_to_check} is missing in user card")
|
||||
|
||||
login_time_str = self.login_time.get_text(0)
|
||||
assert login_time_str.find("Время входа:")!= -1, \
|
||||
"Expected text 'Время входа:' is missing in user card"
|
||||
session_time_str = self.session_time.get_text(0)
|
||||
assert session_time_str.find("Время сессии:")!= -1, \
|
||||
"Expected text 'Время сессии:' is missing in user card"
|
||||
|
||||
self.logout_button.check_visibility("Logout button is missing on user card")
|
||||
self.change_password_button.check_visibility("Change password button is missing on user card")
|
||||
self.settings_button.check_visibility("Settings button is missing on user card")
|
||||
|
|
@ -110,5 +110,10 @@ class Environment:
|
|||
|
||||
return self.current_user_credential.get("$id")
|
||||
|
||||
def get_current_user_credential(self) -> {}:
|
||||
"""Возвращает учетные данные текущего пользователя."""
|
||||
|
||||
return self.current_user_credential
|
||||
|
||||
|
||||
host: Environment = Environment()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
"""Модуль user_card_locators содержит локаторы элементов карточки текущего пользователя.
|
||||
|
||||
Класс UserCardLocators предоставляет XPath локаторы для взаимодействия
|
||||
с элементами карточки текущего пользователя.
|
||||
"""
|
||||
|
||||
class UserCardLocators:
|
||||
"""Локаторы элементов карточки текущего пользователя.
|
||||
|
||||
Содержит XPath локаторы для:
|
||||
CARD_USER (str): карточки текущего пользователя.
|
||||
"""
|
||||
|
||||
CARD_USER = "//div[@class='v-card__text']"
|
||||
|
||||
|
|
@ -61,6 +61,11 @@ class MainPage(BasePage):
|
|||
|
||||
self.event_panel.click_expand_more_button()
|
||||
|
||||
def click_user_button(self) -> None:
|
||||
"""Выполняет нажатие кнопки пользователя."""
|
||||
|
||||
self.event_panel.click_user_button()
|
||||
|
||||
def do_logout(self) -> None:
|
||||
"""Выполняет выход из системы."""
|
||||
|
||||
|
|
@ -158,3 +163,8 @@ class MainPage(BasePage):
|
|||
NavigationPanelLocators.PANEL_MAIN,
|
||||
item_name
|
||||
)
|
||||
|
||||
def check_user_card_content(self):
|
||||
"""Проверяет наличие и корректность элементов карточки пользователя."""
|
||||
|
||||
self.event_panel.check_user_card_content()
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@
|
|||
import re
|
||||
from playwright.sync_api import Page
|
||||
from locators.table_locators import TableLocators
|
||||
from derived_components.modal_edit_user import EditUserModalWindow
|
||||
from derived_components.modal_add_local_user import AddLocalUserModalWindow
|
||||
from derived_components.modal_add_AD_user import AddADUserModalWindow
|
||||
from components_derived.modal_edit_user import EditUserModalWindow
|
||||
from components_derived.modal_add_local_user import AddLocalUserModalWindow
|
||||
from components_derived.modal_add_AD_user import AddADUserModalWindow
|
||||
from data.roles_dict import roles_dict
|
||||
from components.toolbar_component import ToolbarComponent
|
||||
from components.table_component import TableComponent
|
||||
from components.modal_window_component import ModalWindowComponent
|
||||
from components.alert_component import AlertComponent
|
||||
from pages.base_page import BasePage
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class TestEventPanel:
|
|||
if button_counter != counter:
|
||||
assert False, f"Expected tooltip value {counter} is not equal button value {button_counter} for event button {event}"
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_event_panel_expand_buttons(self, browser: Page) -> None:
|
||||
"""Проверяет состояние и количество кнопок расширения рабочей области панели событий.
|
||||
|
||||
|
|
@ -117,3 +116,19 @@ class TestEventPanel:
|
|||
"Expand less button should be present"
|
||||
assert mp.check_expand_more_button(), \
|
||||
"Expand more button should be absent"
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_user_card_content(self, browser: Page) -> None:
|
||||
"""Проверяет наличие и корректность элементов карточки пользователя.
|
||||
|
||||
Args:
|
||||
browser: Экземпляр страницы Playwright.
|
||||
"""
|
||||
|
||||
lp = LoginPage(browser)
|
||||
lp.do_login()
|
||||
|
||||
mp = MainPage(browser)
|
||||
|
||||
mp.click_user_button()
|
||||
mp.check_user_card_content()
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class TestUsersTab:
|
|||
ut = UsersTab(browser)
|
||||
ut.should_be_toolbar_buttons()
|
||||
|
||||
# pytest.mark.develop
|
||||
# @pytest.mark.develop
|
||||
def test_add_user_window_content(self, browser: Page) -> None:
|
||||
"""Проверяет содержимое окна добавления пользователя.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue