2023-12-15 17:59:58 +07:00
|
|
|
import allure
|
|
|
|
|
2023-12-06 19:00:09 +07:00
|
|
|
import configs
|
2023-12-15 17:59:58 +07:00
|
|
|
import driver.objects_access
|
2023-12-06 19:00:09 +07:00
|
|
|
from gui.components.base_popup import BasePopup
|
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.check_box import CheckBox
|
2023-12-15 17:59:58 +07:00
|
|
|
from gui.elements.object import QObject
|
2023-12-06 19:00:09 +07:00
|
|
|
from gui.elements.text_edit import TextEdit
|
2024-02-13 16:04:24 +07:00
|
|
|
from gui.objects_map import names
|
2023-12-06 19:00:09 +07:00
|
|
|
|
|
|
|
|
|
|
|
class CategoryPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(CategoryPopup, self).__init__()
|
2024-02-13 16:04:24 +07:00
|
|
|
self._name_text_edit = TextEdit(names.createOrEditCommunityCategoryNameInput_TextEdit)
|
|
|
|
self._channel_item_checkbox = CheckBox(names.channelItemCheckbox_StatusCheckBox)
|
|
|
|
self._channels_view = QObject(names.createOrEditCommunityCategoryChannelList_StatusListView)
|
2023-12-06 19:00:09 +07:00
|
|
|
|
2023-12-15 17:59:58 +07:00
|
|
|
@allure.step('Wait until appears {0}')
|
2023-12-06 19:00:09 +07:00
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
self._name_text_edit.wait_until_appears(timeout_msec)
|
|
|
|
return self
|
|
|
|
|
2023-12-15 17:59:58 +07:00
|
|
|
@allure.step('Enter category title in category popup')
|
|
|
|
def enter_category_title(self, title):
|
|
|
|
self._name_text_edit.text = title
|
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Click checkbox in category popup')
|
|
|
|
def click_checkbox_by_index(self, index: int):
|
|
|
|
checkboxes = []
|
|
|
|
for child in driver.objects_access.walk_children(self._channels_view.object):
|
|
|
|
if child.id == 'channelItemCheckbox':
|
|
|
|
checkboxes.append(child)
|
|
|
|
driver.mouseClick(checkboxes[index])
|
|
|
|
return self
|
|
|
|
|
2023-12-06 19:00:09 +07:00
|
|
|
|
|
|
|
class NewCategoryPopup(CategoryPopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(NewCategoryPopup, self).__init__()
|
2024-02-13 16:04:24 +07:00
|
|
|
self._create_button = Button(names.create_StatusButton)
|
2023-12-06 19:00:09 +07:00
|
|
|
|
2023-12-15 17:59:58 +07:00
|
|
|
@allure.step('Create category')
|
2023-12-06 19:00:09 +07:00
|
|
|
def create(self, name: str, checkbox_state: bool):
|
|
|
|
self._name_text_edit.text = name
|
|
|
|
if checkbox_state:
|
2023-12-15 17:59:58 +07:00
|
|
|
self._channel_item_checkbox.click()
|
2023-12-06 19:00:09 +07:00
|
|
|
self._create_button.click()
|
|
|
|
self.wait_until_hidden()
|
2023-12-15 17:59:58 +07:00
|
|
|
|
|
|
|
|
|
|
|
class EditCategoryPopup(CategoryPopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(EditCategoryPopup, self).__init__()
|
2024-02-13 16:04:24 +07:00
|
|
|
self._delete_button = Button(names.delete_Category_StatusButton)
|
|
|
|
self._save_button = Button(names.save_StatusButton)
|
2023-12-15 17:59:58 +07:00
|
|
|
|
|
|
|
@allure.step('Click save in edit category popup')
|
|
|
|
def save(self):
|
|
|
|
self._save_button.click()
|
|
|
|
self.wait_until_hidden()
|