mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
fix filter settings + use execute_script on tests
* fix filter settings showing all settings when search value is empty * enhance multiple settings template : add presentation title + better typo for multiple setting title * update access_page to get page without button action * click on selenium exception button using execute_script avoiding issues
This commit is contained in:
parent
8c8a2e51b0
commit
781eee2901
7 changed files with 42 additions and 32 deletions
|
|
@ -241,7 +241,7 @@ class FilterSettings {
|
|||
// case no tab match
|
||||
if (isAllHidden) {
|
||||
this.tabContainer
|
||||
.querySelector("[data-tab-select-dropdown-btn] span")
|
||||
.querySelector("[data-tab-select-dropdown-btn]")
|
||||
.setAttribute("data-tab-id", "no-match");
|
||||
return (this.tabContainer.querySelector(
|
||||
"[data-tab-select-dropdown-btn] span",
|
||||
|
|
@ -250,24 +250,24 @@ class FilterSettings {
|
|||
|
||||
// click first not hidden tab
|
||||
const currTabEl = this.tabContainer.querySelector(
|
||||
"[data-tab-select-dropdown-btn] span",
|
||||
"[data-tab-select-dropdown-btn]",
|
||||
);
|
||||
|
||||
const currTabName = currTabEl.getAttribute("data-tab-id");
|
||||
|
||||
// case previously no match
|
||||
if (currTabName === "no-match") {
|
||||
if (currTabName === "no-match" && !isAllHidden) {
|
||||
return firstNotHiddenEl.click();
|
||||
}
|
||||
|
||||
const currTabBtn = this.tabContainer.querySelector(
|
||||
`[data-tab-select-handler='${currTabName}']`,
|
||||
);
|
||||
if (!currTabBtn) return;
|
||||
|
||||
if (!currTabBtn.classList.contains("!hidden")) {
|
||||
return currTabBtn.click();
|
||||
}
|
||||
|
||||
if (currTabBtn.classList.contains("!hidden")) {
|
||||
return firstNotHiddenEl.click();
|
||||
}
|
||||
|
|
|
|||
9
src/ui/templates/settings_plugins.html
vendored
9
src/ui/templates/settings_plugins.html
vendored
|
|
@ -248,11 +248,16 @@
|
|||
{% if multList.append(value['multiple']) %}{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if multList|length > 0 %}
|
||||
<h5 class="transition duration-300 ease-in-out ml-2 font-bold text-[1.1rem] uppercase dark:text-white/90 mt-2 mb-0">
|
||||
multiple settings
|
||||
</h5>
|
||||
{% endif %}
|
||||
{% for multiple in multList %}
|
||||
<!-- plugin multiple handler -->
|
||||
<div data-multiple-handler
|
||||
class="flex items-center mx-0 sm:mx-4 md:mx-6 mb-2 mt-5 2xl:mx-6 col-span-12 ">
|
||||
<h5 class="input-title max-w-[150px] sm:max-w-[350px]">{{ multiple }}</h5>
|
||||
class="flex items-center mx-2 mb-2 mt-5 col-span-12 ">
|
||||
<h5 class="input-title max-w-[150px] sm:max-w-[350px]">{{ multiple.replace('-', ' ').replace('_', ' ')|upper }}</h5>
|
||||
<button data-{{ current_endpoint }}-multiple-add="{{ multiple }}" type="button" class="ml-3 dark:brightness-90 inline-block px-3 py-1.5 font-bold text-center text-white uppercase align-middle transition-all rounded-lg cursor-pointer bg-green-500 hover:bg-green-500/80 focus:bg-green-500/80 leading-normal text-md ease-in tracking-tight-rem shadow-xs bg-150 bg-x-25 hover:-translate-y-px active:opacity-85 hover:shadow-md">
|
||||
Add
|
||||
</button>
|
||||
|
|
|
|||
1
src/ui/templates/settings_tabs_select.html
vendored
1
src/ui/templates/settings_tabs_select.html
vendored
|
|
@ -3,6 +3,7 @@
|
|||
<div class="relative col-span-12 h-full">
|
||||
<button data-tab-select-dropdown-btn
|
||||
aria-controls="tab-dropdown"
|
||||
data-tab-id="{{ plugins[0]['id'] }}"
|
||||
class="settings-tabs-select-btn">
|
||||
<span aria-description="current tab" class="settings-tabs-select-btn-text">
|
||||
{% if current_endpoint == "global-config" %}general{% endif %}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,16 @@ try:
|
|||
|
||||
log_info("Bans found, trying to delete them ...")
|
||||
|
||||
assert_button_click(DRIVER, "//input[@id='ban-item-2']")
|
||||
access_page(DRIVER, "//button[@data-unban-btn='']", "bans", False)
|
||||
delete_ban_checkbox = safe_get_element(DRIVER, By.XPATH, "//input[@id='ban-item-2']")
|
||||
assert isinstance(delete_ban_checkbox, WebElement), "Delete checkbox is not WebElement"
|
||||
DRIVER.execute_script("arguments[0].click()", delete_ban_checkbox)
|
||||
|
||||
unban_button = safe_get_element(DRIVER, By.XPATH, "//button[@data-unban-btn='']")
|
||||
assert isinstance(unban_button, WebElement), "Delete button is not WebElement"
|
||||
|
||||
DRIVER.execute_script("arguments[0].click()", unban_button)
|
||||
|
||||
access_page(DRIVER, False, "bans", False)
|
||||
|
||||
try:
|
||||
entries = safe_get_element(DRIVER, By.XPATH, "//ul[@data-bans-list='']/li", multiple=True, error=True)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,22 @@ try:
|
|||
log_error(f"Filter keyword with value {keyword_no_match} shouldn't match something.")
|
||||
exit(1)
|
||||
|
||||
log_info("Filter with unmatched keyword works as expected, try with a keyword that matches a setting...")
|
||||
|
||||
btn_keyword.send_keys("Datastore")
|
||||
|
||||
settings = safe_get_element(
|
||||
DRIVER,
|
||||
By.XPATH,
|
||||
"//form[@id='form-edit-global-configs']//div[@data-setting-container='' and not(contains(@class, 'hidden'))]",
|
||||
multiple=True,
|
||||
)
|
||||
assert isinstance(settings, list), "Hidden settings is not a list of WebElements"
|
||||
|
||||
if len(settings) != 1:
|
||||
log_error(f"The filter didn't work (found {len(settings)} settings instead of 1), exiting ...")
|
||||
exit(1)
|
||||
|
||||
# Reset
|
||||
btn_keyword.send_keys("")
|
||||
|
||||
|
|
@ -100,24 +116,6 @@ try:
|
|||
assert_button_click(DRIVER, "//button[@data-tab-select-dropdown-btn='']")
|
||||
assert_button_click(DRIVER, button)
|
||||
|
||||
log_info("Trying to filter the global config ...")
|
||||
|
||||
setting_filter_elem = safe_get_element(DRIVER, By.ID, "settings-filter")
|
||||
assert isinstance(setting_filter_elem, WebElement), "Setting filter input is not a WebElement"
|
||||
setting_filter_elem.send_keys("Datastore")
|
||||
|
||||
settings = safe_get_element(
|
||||
DRIVER,
|
||||
By.XPATH,
|
||||
"//form[@id='form-edit-global-configs']//div[@data-setting-container='' and not(contains(@class, 'hidden'))]",
|
||||
multiple=True,
|
||||
)
|
||||
assert isinstance(settings, list), "Hidden settings is not a list of WebElements"
|
||||
|
||||
if len(settings) != 1:
|
||||
log_error(f"The filter didn't work (found {len(settings)} settings instead of 1), exiting ...")
|
||||
exit(1)
|
||||
|
||||
log_info("✅ Global config page tests finished successfully")
|
||||
except SystemExit as e:
|
||||
exit_code = e.code
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ try:
|
|||
assert isinstance(reverse_proxy_url_input, WebElement), "Reverse proxy url input is not a WebElement"
|
||||
reverse_proxy_url_input.send_keys("/")
|
||||
|
||||
access_page(DRIVER, "//button[@data-services-modal-submit='']", "services", False)
|
||||
access_page(DRIVER, False, "services", False)
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
wait_for_service("app1.example.com")
|
||||
|
|
@ -334,8 +334,6 @@ try:
|
|||
|
||||
DRIVER.execute_script("arguments[0].click()", delete_modal_button)
|
||||
|
||||
access_page(DRIVER, "/html/body/aside[1]/div[1]/div[3]/ul/li[4]/a", "services")
|
||||
|
||||
if TEST_TYPE == "linux":
|
||||
wait_for_service()
|
||||
|
||||
|
|
|
|||
|
|
@ -106,14 +106,14 @@ def assert_alert_message(driver, message: str):
|
|||
assert_button_click(driver, "//button[@data-flash-sidebar-close='']/*[local-name() = 'svg']")
|
||||
|
||||
|
||||
def access_page(driver, button: Union[str, WebElement], name: str, message: bool = True, *, retries: int = 0, clicked: bool = False):
|
||||
def access_page(driver, button: Union[bool, str, WebElement], name: str, message: bool = True, *, retries: int = 0, clicked: bool = False):
|
||||
if retries > 5:
|
||||
log_error("Too many retries...")
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
if not clicked:
|
||||
clicked = assert_button_click(driver, button)
|
||||
if not isinstance(button, bool) and not clicked:
|
||||
= clicked = assert_button_click(driver, button)
|
||||
|
||||
title: Union[WebElement, List[WebElement]] = safe_get_element(driver, By.XPATH, "/html/body/div[3]/header/div/nav/h6", driver_wait=WebDriverWait(driver, 45))
|
||||
assert isinstance(title, WebElement), "Title is not a WebElement"
|
||||
|
|
|
|||
Loading…
Reference in a new issue