Кнопка расширения/сжатия рабочей области страницы добавлена в панель навигации
parent
7612138c50
commit
6d36491d79
|
|
@ -1,72 +0,0 @@
|
|||
"""Модуль expand_button_component содержит класс для работы с кнопкой расширения/уменьшения рабочей области вкладки
|
||||
на странице."""
|
||||
|
||||
from playwright.sync_api import Page
|
||||
from tools.logger import get_logger
|
||||
from elements.button_element import Button
|
||||
from components.base_component import BaseComponent
|
||||
|
||||
logger = get_logger("EXPAND_BUTTON")
|
||||
|
||||
|
||||
class ExpandButton(BaseComponent):
|
||||
"""Класс для работы с кнопкой расширения/сжатия рабочей области вкладки на странице.
|
||||
|
||||
"""
|
||||
def __init__(self, page: Page):
|
||||
"""Инициализирует компонент.
|
||||
|
||||
Args:
|
||||
page: Экземпляр страницы Playwright.
|
||||
"""
|
||||
|
||||
super().__init__(page)
|
||||
|
||||
self.expand_work_area_button_locator = page.get_by_role("button").filter(has_text="navigate_")
|
||||
self.expand_work_area_button = Button(page,
|
||||
self.expand_work_area_button_locator,
|
||||
"expand_work_area_button")
|
||||
|
||||
# Действия:
|
||||
def expand(self) -> None:
|
||||
"""Нажатие кнопки для расширения рабочей области вкладки"""
|
||||
|
||||
can_do_expand = self.is_in_expand_state()
|
||||
|
||||
if can_do_expand:
|
||||
self.expand_work_area_button.click()
|
||||
else:
|
||||
assert False, "Work area already expanded"
|
||||
|
||||
def reduce(self) -> None:
|
||||
"""Нажатие кнопки для сжатия рабочей области вкладки"""
|
||||
|
||||
can_do_expand = self.is_in_expand_state()
|
||||
|
||||
if can_do_expand:
|
||||
assert False, "Work area already reduced"
|
||||
else:
|
||||
self.expand_work_area_button.click()
|
||||
|
||||
# Проверки:
|
||||
def is_in_expand_state(self) -> bool:
|
||||
"""Проверяет состояние кнопки, способность ее увеличить размер рабочей области вкладки"""
|
||||
|
||||
button_state = self.expand_work_area_button_locator.text_content()
|
||||
if button_state.find("before") != -1:
|
||||
return True
|
||||
elif button_state.find("next") != -1:
|
||||
return False
|
||||
else:
|
||||
assert False, f"Got unexpected button state {button_state}"
|
||||
|
||||
def should_be_button(self) -> None:
|
||||
"""Проверяет наличие кнопки расширения/сжатия рабочей области вкладки.
|
||||
|
||||
Raises:
|
||||
AssertionError: Если кнопка отсутствует.
|
||||
"""
|
||||
|
||||
self.expand_work_area_button.check_visibility(
|
||||
"Expand work area button is missing on page"
|
||||
)
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
from playwright.sync_api import Page, Locator
|
||||
from tools.logger import get_logger
|
||||
from locators.navigation_panel_locators import NavigationPanelLocators
|
||||
from elements.button_element import Button
|
||||
from components.base_component import BaseComponent
|
||||
|
||||
logger = get_logger("NAVIGATION_PANEL")
|
||||
|
|
@ -20,6 +21,14 @@ class NavigationPanelComponent(BaseComponent):
|
|||
|
||||
super().__init__(page)
|
||||
|
||||
# кнопки расширения/сжатия рабочей области вкладки на странице
|
||||
self.expand_workarea_button = Button(page,
|
||||
page.locator(NavigationPanelLocators.BUTTON_EXPAND_WORKAREA),
|
||||
"expand_workarea_button")
|
||||
self.reduce_workarea_button = Button(page,
|
||||
page.locator(NavigationPanelLocators.BUTTON_REDUCE_WORKAREA),
|
||||
"reduce_workarea_button")
|
||||
|
||||
# Действия:
|
||||
def click_item(self, locator: str | Locator, item_name: str) -> None:
|
||||
"""Кликает по элементу с указанным текстом.
|
||||
|
|
@ -224,6 +233,22 @@ class NavigationPanelComponent(BaseComponent):
|
|||
root_locator = self.get_locator(node_root_locator)
|
||||
traverse_tree(self.page, root_locator, level=level, debug=debug)
|
||||
|
||||
def expand_workarea(self) -> None:
|
||||
"""Нажатие кнопки для расширения рабочей области страницы"""
|
||||
|
||||
if self.page.locator(NavigationPanelLocators.BUTTON_EXPAND_WORKAREA).count() > 0:
|
||||
self.expand_workarea_button.click()
|
||||
else:
|
||||
assert False, "Workarea already expanded"
|
||||
|
||||
def reduce_workarea(self) -> None:
|
||||
"""Нажатие кнопки для сжатия рабочей области страницы"""
|
||||
|
||||
if self.page.locator(NavigationPanelLocators.BUTTON_REDUCE_WORKAREA).count() > 0:
|
||||
self.reduce_workarea_button.click()
|
||||
else:
|
||||
assert False, "Workarea already reduced"
|
||||
|
||||
# Проверки:
|
||||
def check_item_visibility(self, locator: str | Locator, item_name: str) -> None:
|
||||
"""Проверяет видимость элемента с указанным текстом.
|
||||
|
|
@ -268,3 +293,31 @@ class NavigationPanelComponent(BaseComponent):
|
|||
return False
|
||||
|
||||
return element_locator.is_visible()
|
||||
|
||||
def should_be_expand_workarea_button(self) -> None:
|
||||
"""Проверяет наличие кнопки расширения рабочей области страницы.
|
||||
|
||||
Raises:
|
||||
AssertionError: Если кнопка отсутствует.
|
||||
"""
|
||||
|
||||
if self.page.locator(NavigationPanelLocators.BUTTON_EXPAND_WORKAREA).count() > 0:
|
||||
self.expand_workarea_button.check_visibility(
|
||||
"Expand workarea button is missing on page"
|
||||
)
|
||||
else:
|
||||
assert False, "Expand workarea button is missing on page"
|
||||
|
||||
def should_be_reduce_workarea_button(self) -> None:
|
||||
"""Проверяет наличие кнопки сжатия рабочей области страницы.
|
||||
|
||||
Raises:
|
||||
AssertionError: Если кнопка отсутствует.
|
||||
"""
|
||||
|
||||
if self.page.locator(NavigationPanelLocators.BUTTON_REDUCE_WORKAREA).count() > 0:
|
||||
self.reduce_workarea_button.check_visibility(
|
||||
"Rduce workarea button is missing on page"
|
||||
)
|
||||
else:
|
||||
assert False, "Reduce workarea button is missing on page"
|
||||
|
|
|
|||
|
|
@ -29,3 +29,6 @@ class NavigationPanelLocators:
|
|||
NODE_ROOT = "//div[contains(@class,'v-treeview-node__root')]"
|
||||
NODE_CHILDREN = "//div[contains(@class,'v-treeview-node__children')]"
|
||||
TOGGLE_BUTTON = "//i[contains(@class,'v-treeview-node__toggle')]"
|
||||
|
||||
BUTTON_EXPAND_WORKAREA = "//button[@data-testid='BASELINE__btn__leftBarMini']"
|
||||
BUTTON_REDUCE_WORKAREA = "//button[@data-testid='BASELINE__btn__!leftBarMini']"
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ class MainPage(BasePage):
|
|||
node_locator, item_name, parent
|
||||
)
|
||||
|
||||
def click_expand_workarea_button(self) -> None:
|
||||
"""Выполняеи нажатие кнопки расширения рабочей области страницы"""
|
||||
|
||||
self.navigation_panel.expand_workarea()
|
||||
|
||||
def click_reduce_workarea_button(self) -> None:
|
||||
"""Выполняеи нажатие кнопки сжатия рабочей области страницы"""
|
||||
|
||||
self.navigation_panel.reduce_workarea()
|
||||
|
||||
def click_user_button(self) -> UserCard:
|
||||
"""Выполняет нажатие кнопки пользователя."""
|
||||
|
||||
|
|
@ -233,3 +243,13 @@ class MainPage(BasePage):
|
|||
NavigationPanelLocators.PANEL_MAIN,
|
||||
"Navigation panel is missing"
|
||||
)
|
||||
|
||||
def should_be_expand_workarea_button(self) -> None:
|
||||
"""Проверяет наличие кнопки расширения рабочей области страницы."""
|
||||
|
||||
self.navigation_panel.should_be_expand_workarea_button()
|
||||
|
||||
def should_be_reduce_workarea_button(self) -> None:
|
||||
"""Проверяет наличие кнопки сжатия рабочей области страницы."""
|
||||
|
||||
self.navigation_panel.should_be_reduce_workarea_button()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from playwright.sync_api import Page, Locator, expect
|
|||
from elements.text_element import Text
|
||||
from elements.button_element import Button
|
||||
from components.table_component import TableComponent
|
||||
from components.expand_button_component import ExpandButton
|
||||
from pages.base_page import BasePage
|
||||
|
||||
|
||||
|
|
@ -41,7 +40,6 @@ class ServiceStatusTab(BasePage):
|
|||
self.update_button_locator,
|
||||
"update_button")
|
||||
|
||||
self.expand_work_area_button = ExpandButton(page)
|
||||
self.services_table = TableComponent(page)
|
||||
|
||||
# Действия:
|
||||
|
|
@ -128,35 +126,11 @@ class ServiceStatusTab(BasePage):
|
|||
|
||||
return self.services_table.get_rows_count(self.table_locator)
|
||||
|
||||
def expand_tab(self) -> None:
|
||||
"""Расширяет рабочую область складки."""
|
||||
def get_workarea_widht(self) -> float:
|
||||
"""Возвращает текущую ширину рабочей области вкладки."""
|
||||
|
||||
iframe_container_bounding_box = self.iframe_container_locator.\
|
||||
evaluate("el => el.getBoundingClientRect()")
|
||||
widht_before = iframe_container_bounding_box["width"]
|
||||
|
||||
self.expand_work_area_button.expand()
|
||||
|
||||
iframe_container_bounding_box = self.iframe_container_locator.\
|
||||
evaluate("el => el.getBoundingClientRect()")
|
||||
widht_after = iframe_container_bounding_box["width"]
|
||||
|
||||
assert widht_before < widht_after,"Services statuses tab should be expanded"
|
||||
|
||||
def reduce_tab(self) -> None:
|
||||
"""Сжимает рабочую область складки."""
|
||||
|
||||
iframe_container_bounding_box = self.iframe_container_locator.\
|
||||
evaluate("el => el.getBoundingClientRect()")
|
||||
widht_before = iframe_container_bounding_box["width"]
|
||||
|
||||
self.expand_work_area_button.reduce()
|
||||
|
||||
iframe_container_bounding_box = self.iframe_container_locator.\
|
||||
evaluate("el => el.getBoundingClientRect()")
|
||||
widht_after = iframe_container_bounding_box["width"]
|
||||
|
||||
assert widht_before > widht_after,"Services statuses tab should be reduced"
|
||||
iframe_container_bounding_box = self.iframe_container_locator.evaluate("el => el.getBoundingClientRect()")
|
||||
return iframe_container_bounding_box["width"]
|
||||
|
||||
def scroll_services_tab_up(self) -> None:
|
||||
"""Прокручивает содержимое вкладки вверх."""
|
||||
|
|
@ -278,7 +252,7 @@ class ServiceStatusTab(BasePage):
|
|||
AssertionError: Если строка не выделена.
|
||||
"""
|
||||
|
||||
offsets_scales = self.get_offsets_scales()
|
||||
# offsets_scales = self.get_offsets_scales()
|
||||
|
||||
self.services_table.check_mui_table_row_highlighting(
|
||||
self.table_locator,
|
||||
|
|
@ -307,15 +281,6 @@ class ServiceStatusTab(BasePage):
|
|||
"Service statuses table is missing"
|
||||
)
|
||||
|
||||
def should_be_expand_work_area_button(self) -> None:
|
||||
"""Проверяет наличие кнопки расширения/сжатия рабочей области вкладки.
|
||||
|
||||
Raises:
|
||||
AssertionError: Если кнопка отсутствует.
|
||||
"""
|
||||
|
||||
self.expand_work_area_button.should_be_button()
|
||||
|
||||
def should_be_update_button(self) -> None:
|
||||
"""Проверяет наличие кнопки 'Обновить'.
|
||||
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@ class TestServiceStatusTab:
|
|||
# Проверка наличия кнопки 'Обновить'
|
||||
sst.should_be_update_button()
|
||||
|
||||
# Проверка наличия кнопки расширения/сжатия рабочей области вкладки
|
||||
sst.should_be_expand_work_area_button()
|
||||
|
||||
# Проверка наличия таблицы статусов сервисов
|
||||
sst.should_be_services_table()
|
||||
|
||||
|
|
@ -99,7 +96,7 @@ class TestServiceStatusTab:
|
|||
sst.check_services_table_row_highlighting(int(rows_count / 2))
|
||||
sst.check_services_table_row_highlighting(rows_count - 1)
|
||||
|
||||
# @pytest.mark.develop
|
||||
@pytest.mark.develop
|
||||
def test_service_status_tab_resize(self, browser: Page):
|
||||
"""Проверяет возможность расширения/сжатия рабочей области вкладки.
|
||||
|
||||
|
|
@ -107,28 +104,45 @@ class TestServiceStatusTab:
|
|||
browser: Экземпляр страницы Playwright.
|
||||
"""
|
||||
|
||||
mp = MainPage(browser)
|
||||
|
||||
sst = ServiceStatusTab(browser)
|
||||
|
||||
# Проверка наличия таблицы статусов сервисов
|
||||
sst.should_be_services_table()
|
||||
|
||||
# Проверка наличия кнопки расширения/сжатия рабочей области вкладки
|
||||
sst.should_be_expand_work_area_button()
|
||||
# Получение количества строк в таблице
|
||||
rows_count_before = sst.get_rows_count()
|
||||
|
||||
# Проверка наличия кнопки расширения рабочей области вкладки
|
||||
mp.should_be_expand_workarea_button()
|
||||
|
||||
# Проверка возможности расширения рабочей области вкладки
|
||||
sst.expand_tab()
|
||||
widht_before = sst.get_workarea_widht()
|
||||
|
||||
mp.click_expand_workarea_button()
|
||||
browser.wait_for_timeout(200)
|
||||
|
||||
widht_after_expand = sst.get_workarea_widht()
|
||||
assert widht_before < widht_after_expand,"Services statuses tab should be expanded"
|
||||
|
||||
# Получение количества строк в таблице
|
||||
rows_count = sst.get_rows_count()
|
||||
|
||||
# Проверка выделения строк
|
||||
sst.check_services_table_row_highlighting(rows_count - 1)
|
||||
rows_count_after_expand = sst.get_rows_count()
|
||||
assert rows_count_before == rows_count_after_expand, "Bad workarea expand action"
|
||||
|
||||
# Проверка возможности сжатия рабочей области вкладки
|
||||
sst.reduce_tab()
|
||||
mp.should_be_reduce_workarea_button()
|
||||
|
||||
# Проверка выделения строк
|
||||
sst.check_services_table_row_highlighting(0)
|
||||
mp.click_reduce_workarea_button()
|
||||
browser.wait_for_timeout(200)
|
||||
|
||||
widht_after_reduce = sst.get_workarea_widht()
|
||||
|
||||
assert widht_after_expand > widht_after_reduce,"Services statuses tab should be reduced"
|
||||
|
||||
# Получение количества строк в таблице
|
||||
rows_count_after_reduce = sst.get_rows_count()
|
||||
assert rows_count_after_reduce == rows_count_after_expand, "Bad workarea reduce action"
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_service_status_tab_reload(self, browser: Page):
|
||||
|
|
|
|||
Loading…
Reference in New Issue