Актуализация тестов проверки создания и редактирования пользователей

nsubbot 2025-12-10 09:38:56 +03:00
parent 483a56fd15
commit f81615a37c
6 changed files with 86 additions and 100 deletions

View File

@ -28,13 +28,22 @@ class EventPanelComponent(BaseComponent):
self.states_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_STATES), "states_tab") self.states_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_STATES), "states_tab")
self.actions_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_ACTIONS), "actions_tab") self.actions_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_ACTIONS), "actions_tab")
self.events_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_EVENTS), "events_tab") self.events_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_EVENTS), "events_tab")
self.maintenance_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_MAINTENANCE), "maintenance_tab") self.maintenance_tab = TabButton(page,
self.page.locator(EventPanelLocators.TAB_MAINTENANCE), "maintenance_tab")
self.system_log_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_SYSTEM_LOG), "system_log_tab") self.system_log_tab = TabButton(page, self.page.locator(EventPanelLocators.TAB_SYSTEM_LOG), "system_log_tab")
self.unknown_reason_button = TooltipButton(page, self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(0), "unknown_reason_button") self.unknown_reason_button = TooltipButton(page,
self.warning_button = TooltipButton(page, self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(1), "warning_button") self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(0),
self.damage_button = TooltipButton(page, self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(2), "damage_button") "unknown_reason_button")
self.failure_button = TooltipButton(page, self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(3), "failure_button") self.warning_button = TooltipButton(page,
self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(1),
"warning_button")
self.damage_button = TooltipButton(page,
self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(2),
"damage_button")
self.failure_button = TooltipButton(page,
self.page.locator(EventPanelLocators.BUTTONS_EVENT).nth(3),
"failure_button")
buttons_service_locators = self.page.locator(EventPanelLocators.BUTTONS_SERVICE).get_by_role("button").all() buttons_service_locators = self.page.locator(EventPanelLocators.BUTTONS_SERVICE).get_by_role("button").all()
self.search_button = Button(page, buttons_service_locators[0], "search_button") self.search_button = Button(page, buttons_service_locators[0], "search_button")
@ -53,7 +62,7 @@ class EventPanelComponent(BaseComponent):
button_locator = self.page.locator(EventPanelLocators.TAB_EXPAND_BUTTONS).\ button_locator = self.page.locator(EventPanelLocators.TAB_EXPAND_BUTTONS).\
get_by_role("button").filter(has_text='expand_more') get_by_role("button").filter(has_text='expand_more')
button_locator.click() button_locator.click(force=True)
def click_system_log_tab(self) -> SystemLogEventsContainer: def click_system_log_tab(self) -> SystemLogEventsContainer:
"""Выполняет нажатие tab-кнопки Системный журнал.""" """Выполняет нажатие tab-кнопки Системный журнал."""
@ -68,7 +77,7 @@ class EventPanelComponent(BaseComponent):
"""Выполняет нажатие кнопки пользователя.""" """Выполняет нажатие кнопки пользователя."""
self.should_be_user_button() self.should_be_user_button()
self.user_button.click() self.user_button.click(force=True)
user_card = UserCard(self.page) user_card = UserCard(self.page)
return user_card return user_card
@ -155,8 +164,10 @@ class EventPanelComponent(BaseComponent):
self.states_tab.check_have_text('Состояния', "Tab button with text Состояния is missing on event panel") self.states_tab.check_have_text('Состояния', "Tab button with text Состояния is missing on event panel")
self.actions_tab.check_have_text('Действия',"Tab button with text Действия is missing on event panel") self.actions_tab.check_have_text('Действия',"Tab button with text Действия is missing on event panel")
self.events_tab.check_have_text('События', "Tab button with text События is missing on event panel") self.events_tab.check_have_text('События', "Tab button with text События is missing on event panel")
self.maintenance_tab.check_have_text('Обслуживание', "Tab button with text Обслуживание is missing on event panel") self.maintenance_tab.check_have_text('Обслуживание',
self.system_log_tab.check_have_text('Системный журнал', "Tab button with text Системный журнал is missing on event panel") "Tab button with text Обслуживание is missing on event panel")
self.system_log_tab.check_have_text('Системный журнал',
"Tab button with text Системный журнал is missing on event panel")
def should_be_event_buttons(self) -> None: def should_be_event_buttons(self) -> None:
"""Проверяет наличие блока кнопок-счетчиков событий.""" """Проверяет наличие блока кнопок-счетчиков событий."""

View File

@ -39,7 +39,6 @@ class AddLocalUserModalWindow(ModalWindowComponent):
# Локаторы элементов формы # Локаторы элементов формы
text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
label_locator = ModalWindowLocators.LABEL_INPUT_FORM_USER_DATA
# Настройка заголовка и кнопки закрытия тулбара # Настройка заголовка и кнопки закрытия тулбара
self.window_title = "Добавить нового пользователя" self.window_title = "Добавить нового пользователя"
@ -52,42 +51,30 @@ class AddLocalUserModalWindow(ModalWindowComponent):
self.add_toolbar_title(self.window_title) self.add_toolbar_title(self.window_title)
self.add_toolbar_button(locator_button_toolbar_close, "close") self.add_toolbar_button(locator_button_toolbar_close, "close")
# Добавление элементов формы по порядку расположения в окне
checkbox_1 = Checkbox(
page,
self.page.locator(input_form_locator).get_by_role("checkbox").nth(0),
"active_directory"
)
self.add_content_item("active_directory_checkbox", checkbox_1)
label_1 = Text(
page,
self.page.locator(label_locator).nth(0),
"active_directory_checkbox_label"
)
self.add_content_item("active_directory_checkbox_label", label_1)
# Поле Имя # Поле Имя
loc = f"{input_form_locator}/div[2]/{text_field_locator}" loc = f"{input_form_locator}/div[1]/{text_field_locator}"
name_input = TextInput(page, self.page.locator(loc), "name_input") name_input = TextInput(page, self.page.locator(loc), "name_input")
self.add_content_item("name_input", name_input) self.add_content_item("name_input", name_input)
# Чекбокс "Блокировка" - индекс 1
checkbox_2 = Checkbox(
page,
self.page.locator(input_form_locator).get_by_role("checkbox").nth(1),
"blocking"
)
self.add_content_item("blocking_checkbox", checkbox_2)
# Метка "Блокировка" - индекс 1 # Метка "Блокировка"
label_2 = Text( label_blocking_locator = self.page.locator(input_form_locator). \
locator("//label").get_by_text("Блокировка")
label_blocking = Text(
page, page,
self.page.locator(label_locator).nth(1), label_blocking_locator,
"blocking_checkbox_label" "blocking_checkbox_label"
) )
self.add_content_item("blocking_checkbox_label", label_2)
self.add_content_item("blocking_checkbox_label", label_blocking)
# Чекбокс "Блокировка"
checkbox_blocking = Checkbox(
page,
label_blocking_locator.locator("../..").get_by_role("checkbox"),
"blocking"
)
self.add_content_item("blocking_checkbox", checkbox_blocking)
# Поле Роль # Поле Роль
role_loc = self.page.locator(input_form_locator).get_by_role("combobox").nth(0) role_loc = self.page.locator(input_form_locator).get_by_role("combobox").nth(0)
@ -96,41 +83,42 @@ class AddLocalUserModalWindow(ModalWindowComponent):
self.add_content_item("roles_list", DropdownList(page)) self.add_content_item("roles_list", DropdownList(page))
# Поле Пароль # Поле Пароль
loc = f"{input_form_locator}/div[5]/{text_field_locator}" loc = f"{input_form_locator}/div[4]/{text_field_locator}"
password_input = TextInput(page, self.page.locator(loc), "password_input") password_input = TextInput(page, self.page.locator(loc), "password_input")
self.add_content_item("password_input", password_input) self.add_content_item("password_input", password_input)
# Поле Комментарий # Поле Комментарий
loc = f"{input_form_locator}/div[6]/{text_field_locator}" loc = f"{input_form_locator}/div[5]/{text_field_locator}"
commentary_input = TextInput(page, self.page.locator(loc), "commentary_input") commentary_input = TextInput(page, self.page.locator(loc), "commentary_input")
self.add_content_item("commentary_input", commentary_input) self.add_content_item("commentary_input", commentary_input)
# Поле E-mail # Поле E-mail
loc = f"{input_form_locator}/div[7]/{text_field_locator}" loc = f"{input_form_locator}/div[6]/{text_field_locator}"
email_input = TextInput(page, self.page.locator(loc), "email_input") email_input = TextInput(page, self.page.locator(loc), "email_input")
self.add_content_item("email_input", email_input) self.add_content_item("email_input", email_input)
# Поле Номер для СМС # Поле Номер для СМС
loc = f"{input_form_locator}/div[8]/{text_field_locator}" loc = f"{input_form_locator}/div[7]/{text_field_locator}"
phone_input = TextInput(page, self.page.locator(loc), "phone_input") phone_input = TextInput(page, self.page.locator(loc), "phone_input")
self.add_content_item("phone_input", phone_input) self.add_content_item("phone_input", phone_input)
# Чекбокс "Подписка на Push-уведомления" - индекс 2 # Метка "Подписка на Push-уведомления"
checkbox_3 = Checkbox( label_push_locator = self.page.locator(input_form_locator). \
locator("//label").get_by_text("Подписка на Push-уведомления")
label_push = Text(
page, page,
self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA) label_push_locator,
.get_by_role("checkbox").nth(2),
"push_notification"
)
self.add_content_item("push_notification_checkbox", checkbox_3)
# Метка "Подписка на Push-уведомления" - индекс 2
label_3 = Text(
page,
self.page.locator(label_locator).nth(2),
"push_notification_checkbox_label" "push_notification_checkbox_label"
) )
self.add_content_item("push_notification_checkbox_label", label_3) self.add_content_item("push_notification_checkbox_label", label_push)
# Чекбокс "Подписка на Push-уведомления" - индекс 2
checkbox_push = Checkbox(
page,
label_push_locator.locator("../..").get_by_role("checkbox"),
"push_notification"
)
self.add_content_item("push_notification_checkbox", checkbox_push)
# Добавление кнопок действий # Добавление кнопок действий
locator_button_add = self.page.get_by_role("button", name="Добавить") locator_button_add = self.page.get_by_role("button", name="Добавить")
@ -143,16 +131,6 @@ class AddLocalUserModalWindow(ModalWindowComponent):
self.new_user_confirm = ConfirmComponent(page, " Отмена ", " Добавить ") self.new_user_confirm = ConfirmComponent(page, " Отмена ", " Добавить ")
# Действия: # Действия:
def check_active_directory_checkbox(self):
"""Включает чек-бокс Active Directory."""
self.get_content_item("active_directory_checkbox").check(force=True)
def uncheck_active_directory_checkbox(self):
"""Выключает чек-бокс Active Directory."""
self.get_content_item("active_directory_checkbox").uncheck(force=True)
def check_blocking_checkbox(self): def check_blocking_checkbox(self):
"""Включает чек-бокс Блокировка.""" """Включает чек-бокс Блокировка."""
@ -255,13 +233,6 @@ class AddLocalUserModalWindow(ModalWindowComponent):
self.check_by_window_title() self.check_by_window_title()
is_checked = self.get_content_item("active_directory_checkbox").is_checked()
if is_checked:
assert False, (
"The checkbox 'Active Directory' should not be checked for "
"the add local user window"
)
self.check_toolbar_button_visibility("close") self.check_toolbar_button_visibility("close")
self.check_toolbar_button_tooltip("close", "Закрыть") self.check_toolbar_button_tooltip("close", "Закрыть")
@ -271,12 +242,7 @@ class AddLocalUserModalWindow(ModalWindowComponent):
for name in self.content_items: for name in self.content_items:
item = self.get_content_item(name) item = self.get_content_item(name)
if name == "active_directory_checkbox_label": if name == "blocking_checkbox_label":
item.check_have_text(
"Active Directory",
"Label 'Active Directory' is missing"
)
elif name == "blocking_checkbox_label":
item.check_have_text( item.check_have_text(
"Блокировка", "Блокировка",
"Label 'Блокировка' is missing" "Label 'Блокировка' is missing"

View File

@ -43,11 +43,14 @@ class BaseElement:
return "base element" return "base element"
# Действия: # Действия:
def click(self) -> None: def click(self, force=False) -> None:
"""Выполняет клик по элементу.""" """Выполняет клик по элементу."""
logger.info(f"Clicking {self.type_of} '{self.name}'") logger.info(f"Clicking {self.type_of} '{self.name}'")
self.locator.click() if force:
self.locator.click(force=True)
else:
self.locator.click()
def get_text(self, index: int) -> str: def get_text(self, index: int) -> str:
"""Возвращает текст элемента по указанному индексу.""" """Возвращает текст элемента по указанному индексу."""

View File

@ -87,11 +87,12 @@ class UsersTab(BasePage):
add_user_window = self.get_modal_window("add_local_user") add_user_window = self.get_modal_window("add_local_user")
auth_type = user_data.get("auth_type") # skip as unsupported
if auth_type == "active_directory": # auth_type = user_data.get("auth_type")
add_user_window.check_active_directory_checkbox() # if auth_type == "active_directory":
self.add_modal_window("add_AD_user", "") # add_user_window.check_active_directory_checkbox()
add_user_window = self.get_modal_window("add_AD_user") # self.add_modal_window("add_AD_user", "")
# add_user_window = self.get_modal_window("add_AD_user")
add_user_window.new_user(user_data) add_user_window.new_user(user_data)

View File

@ -88,7 +88,7 @@ class TestCurrentSessionsTab:
ut.open_edit_user_page_by_user(user_name, "Администратор") ut.open_edit_user_page_by_user(user_name, "Администратор")
ut.delete_user(user_name) ut.delete_user(user_name)
# @pytest.mark.develop @pytest.mark.develop
def test_sessions_tab_content(self, browser: Page) -> None: def test_sessions_tab_content(self, browser: Page) -> None:
"""Тест содержимого вкладки 'Сеансы'. """Тест содержимого вкладки 'Сеансы'.

View File

@ -4,7 +4,6 @@
работы с пользователями системы. работы с пользователями системы.
""" """
import pytest import pytest
from typing import Dict from typing import Dict
from playwright.sync_api import Page from playwright.sync_api import Page
from pages.users_tab import UsersTab from pages.users_tab import UsersTab
@ -83,9 +82,13 @@ class TestUsersTabAddUser:
ut.open_add_user_window() ut.open_add_user_window()
ut.check_add_user_window_content() ut.check_add_user_window_content()
ut.transform_to_add_AD_user_window()
ut.check_add_AD_user_window_content() # skip as unsupported
ut.close_add_AD_user_window() # ut.transform_to_add_AD_user_window()
# ut.check_add_AD_user_window_content()
# ut.close_add_AD_user_window()
ut.close_add_user_window()
# @pytest.mark.develop # @pytest.mark.develop
def test_add_user_window_close_buttons(self, browser: Page) -> None: def test_add_user_window_close_buttons(self, browser: Page) -> None:
@ -104,13 +107,14 @@ class TestUsersTabAddUser:
ut.open_add_user_window() ut.open_add_user_window()
ut.close_add_user_window() ut.close_add_user_window()
ut.open_add_user_window() # skip as unsupported
ut.transform_to_add_AD_user_window() # ut.open_add_user_window()
ut.close_add_AD_user_window_by_toolbar_button() # ut.transform_to_add_AD_user_window()
# ut.close_add_AD_user_window_by_toolbar_button()
ut.open_add_user_window() # ut.open_add_user_window()
ut.transform_to_add_AD_user_window() # ut.transform_to_add_AD_user_window()
ut.close_add_AD_user_window() # ut.close_add_AD_user_window()
# @pytest.mark.develop # @pytest.mark.develop
def test_add_local_user(self, browser: Page, cleanup_users: None) -> None: def test_add_local_user(self, browser: Page, cleanup_users: None) -> None:
@ -125,6 +129,7 @@ class TestUsersTabAddUser:
self._add_user(browser, user_data) self._add_user(browser, user_data)
# @pytest.mark.develop # @pytest.mark.develop
@pytest.mark.skip(reason="This test is temporarily disabled as test unsupported feature")
def test_add_AD_user(self, browser: Page, cleanup_users: None) -> None: def test_add_AD_user(self, browser: Page, cleanup_users: None) -> None:
"""Проверяет добавление пользователя Active Directory. """Проверяет добавление пользователя Active Directory.