Актуализация тестов работы с пользователями в соответствии с последними изменениями UI
parent
57d8a0466d
commit
e926b04a14
|
|
@ -212,16 +212,16 @@ class EditUserModalWindow(ModalWindowComponent):
|
||||||
if "blocking_checked" in fields:
|
if "blocking_checked" in fields:
|
||||||
checkbox = self.get_content_item("blocking_checkbox")
|
checkbox = self.get_content_item("blocking_checkbox")
|
||||||
if user_data["blocking_checked"]:
|
if user_data["blocking_checked"]:
|
||||||
checkbox.check()
|
checkbox.check(force=True)
|
||||||
else:
|
else:
|
||||||
checkbox.uncheck()
|
checkbox.uncheck(force=True)
|
||||||
|
|
||||||
if "push_notification_checked" in fields:
|
if "push_notification_checked" in fields:
|
||||||
checkbox = self.get_content_item("push_notification_checkbox")
|
checkbox = self.get_content_item("push_notification_checkbox")
|
||||||
if user_data["push_notification_checked"]:
|
if user_data["push_notification_checked"]:
|
||||||
checkbox.check()
|
checkbox.check(force=True)
|
||||||
else:
|
else:
|
||||||
checkbox.uncheck()
|
checkbox.uncheck(force=True)
|
||||||
|
|
||||||
save_button = self.get_button_by_name("save")
|
save_button = self.get_button_by_name("save")
|
||||||
save_button.click()
|
save_button.click()
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,18 @@ class UsersTab(BasePage):
|
||||||
assert False, f"Modal window with title '{title}' not found"
|
assert False, f"Modal window with title '{title}' not found"
|
||||||
return modal_window
|
return modal_window
|
||||||
|
|
||||||
|
def get_rows_count(self) -> int:
|
||||||
|
"""Возвращает количество строк в таблице пользователей (без заголовка).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: Количество строк с данными.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
AssertionError: Если таблица пуста.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.users_table.get_rows_count(TableLocators.TABLE_WORK_AREA)
|
||||||
|
|
||||||
def open_add_user_window(self) -> None:
|
def open_add_user_window(self) -> None:
|
||||||
"""Открывает окно добавления пользователя.
|
"""Открывает окно добавления пользователя.
|
||||||
|
|
||||||
|
|
@ -396,6 +408,21 @@ class UsersTab(BasePage):
|
||||||
if verify:
|
if verify:
|
||||||
self.verify_users_table_content(table_content)
|
self.verify_users_table_content(table_content)
|
||||||
|
|
||||||
|
def check_users_table_row_highlighting(self, row_index: int) -> None:
|
||||||
|
"""Проверяет выделение указанной строки таблицы.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
row_index: Индекс проверяемой строки.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
AssertionError: Если строка не выделена.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.users_table.check_row_highlighting(
|
||||||
|
TableLocators.TABLE_WORK_AREA,
|
||||||
|
row_index
|
||||||
|
)
|
||||||
|
|
||||||
def should_be_toolbar(self) -> None:
|
def should_be_toolbar(self) -> None:
|
||||||
"""Проверяет наличие тулбара.
|
"""Проверяет наличие тулбара.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ class TestUsersTabEditUser:
|
||||||
ut = UsersTab(browser)
|
ut = UsersTab(browser)
|
||||||
|
|
||||||
# Удаляем тестовых пользователей
|
# Удаляем тестовых пользователей
|
||||||
test_users = ["TestUser", "TestUserAutoOperator", "TestUserAutoAdmin"]
|
test_users = ["TestUser", "TestUserAutoOperator", "TestUserAutoAdmin",
|
||||||
|
"TestUserTestOperator", "TestUserToBlock"]
|
||||||
|
|
||||||
for user_name in test_users:
|
for user_name in test_users:
|
||||||
# Проверяем существует ли пользователь и удаляем его
|
# Проверяем существует ли пользователь и удаляем его
|
||||||
|
|
@ -216,3 +217,85 @@ class TestUsersTabEditUser:
|
||||||
mp.click_subpanel_item("Пользователи")
|
mp.click_subpanel_item("Пользователи")
|
||||||
mp.click_subpanel_item("Пользователи")
|
mp.click_subpanel_item("Пользователи")
|
||||||
ut.should_not_be_user_in_table(user_data["name"], new_user_data["role"])
|
ut.should_not_be_user_in_table(user_data["name"], new_user_data["role"])
|
||||||
|
|
||||||
|
def test_edit_user_name(self, browser: Page, cleanup_users: None) -> None:
|
||||||
|
"""Проверяет изменение имени пользователя.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
cleanup_users: Фикстура для автоматического удаления пользователя после теста.
|
||||||
|
"""
|
||||||
|
|
||||||
|
user_data: Dict[str, str] = {"name": "TestUserAutoOperator", "role": "Оператор", "password": "1232456789abcd"}
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
ut = UsersTab(browser)
|
||||||
|
browser.wait_for_timeout(500)
|
||||||
|
|
||||||
|
ut.open_add_user_window()
|
||||||
|
ut.add_new_user(user_data)
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
ut.open_edit_user_page_by_user(user_data["name"], user_data["role"])
|
||||||
|
new_user_data = {"name": "TestUserTestOperator"}
|
||||||
|
ut.edit_user(user_data["name"], new_user_data)
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
ut.should_be_user_in_table(new_user_data["name"], user_data["role"])
|
||||||
|
ut.open_edit_user_page_by_user(new_user_data["name"], user_data["role"])
|
||||||
|
ut.delete_user(new_user_data["name"])
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
ut.should_not_be_user_in_table(new_user_data["name"], user_data["role"])
|
||||||
|
|
||||||
|
# @pytest.mark.develop
|
||||||
|
def test_block_user(self, browser: Page, cleanup_users: None) -> None:
|
||||||
|
"""Проверяет возможность блокировки пользователя.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
cleanup_users: Фикстура для автоматического удаления пользователя после теста.
|
||||||
|
"""
|
||||||
|
|
||||||
|
user_data: Dict[str, str] = {"name": "TestUserToBlock", "role": "Администратор", "password": "123456789abcd"}
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
ut = UsersTab(browser)
|
||||||
|
browser.wait_for_timeout(500)
|
||||||
|
|
||||||
|
ut.open_add_user_window()
|
||||||
|
ut.add_new_user(user_data)
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
lp_to_check = LoginPage(browser)
|
||||||
|
lp_to_check.do_login(username=user_data["name"], password=user_data["password"])
|
||||||
|
mp_to_check = MainPage(browser)
|
||||||
|
mp_to_check.do_logout()
|
||||||
|
|
||||||
|
admin_lp = LoginPage(browser)
|
||||||
|
admin_lp.do_login()
|
||||||
|
admin_mp = MainPage(browser)
|
||||||
|
admin_mp.should_be_navigation_panel()
|
||||||
|
admin_mp.click_main_navigation_panel_item("Настройки")
|
||||||
|
admin_mp.click_subpanel_item("Пользователи")
|
||||||
|
admin_ut = UsersTab(browser)
|
||||||
|
admin_ut.open_edit_user_page_by_user(user_data["name"], user_data["role"])
|
||||||
|
new_user_data = {"blocking_checked": True}
|
||||||
|
admin_ut.edit_user(user_data["name"], new_user_data)
|
||||||
|
admin_mp.do_logout()
|
||||||
|
|
||||||
|
lp_to_check_blocked = LoginPage(browser)
|
||||||
|
lp_to_check_blocked.do_unsuccessful_login(username=user_data["name"], password=user_data["password"])
|
||||||
|
|
||||||
|
admin_lp_1 = LoginPage(browser)
|
||||||
|
admin_lp_1.do_login()
|
||||||
|
admin_mp_1 = MainPage(browser)
|
||||||
|
admin_mp_1.should_be_navigation_panel()
|
||||||
|
admin_mp_1.click_main_navigation_panel_item("Настройки")
|
||||||
|
admin_mp_1.click_subpanel_item("Пользователи")
|
||||||
|
admin_ut_1 = UsersTab(browser)
|
||||||
|
admin_ut_1.open_edit_user_page_by_user(user_data["name"], user_data["role"])
|
||||||
|
admin_ut_1.delete_user(user_data["name"])
|
||||||
|
admin_mp_1.click_subpanel_item("Пользователи")
|
||||||
|
admin_mp_1.click_subpanel_item("Пользователи")
|
||||||
|
admin_ut_1.should_not_be_user_in_table(user_data["name"], user_data["role"])
|
||||||
|
|
|
||||||
|
|
@ -59,3 +59,23 @@ class TestUsersTab:
|
||||||
|
|
||||||
ut = UsersTab(browser)
|
ut = UsersTab(browser)
|
||||||
ut.should_be_toolbar_buttons()
|
ut.should_be_toolbar_buttons()
|
||||||
|
|
||||||
|
def test_users_tab_check_row_highlighting(self, browser: Page) -> None:
|
||||||
|
"""Проверяет выделение цветом указанной строки таблицы.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ut = UsersTab(browser)
|
||||||
|
|
||||||
|
# Проверка наличия таблицы пользователей
|
||||||
|
ut.should_be_users_table()
|
||||||
|
|
||||||
|
# Получение количества строк в таблице
|
||||||
|
rows_count = ut.get_rows_count()
|
||||||
|
|
||||||
|
# Проверка выделения строк
|
||||||
|
ut.check_users_table_row_highlighting(0)
|
||||||
|
ut.check_users_table_row_highlighting(int(rows_count / 2))
|
||||||
|
ut.check_users_table_row_highlighting(rows_count - 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue