update failed tests

* add more logs on some tests like bans test to check why bans items count is not ok
* remove bad global_config logic
* update services access_page
This commit is contained in:
Jordan Blasenhauer 2024-03-01 20:24:39 +01:00
parent 7ef9dcc7bd
commit f10b35aaa8
5 changed files with 55 additions and 24 deletions

View file

@ -91,7 +91,7 @@ class="z-100 w-full grid grid-cols-12 h-fit max-h-100 sm:max-h-125 col-span-12
class="col-span-12 gap-y-4 grid grid-cols-12">
<!-- form global conf -->
<form data-global-config-form
id="form-edit-global-configs"
id="form-edit-global-config"
method="POST"
class="flex flex-col justify-between overflow-hidden overflow-y-auto dark:brightness-110 col-span-12 break-words bg-white shadow-xl p-4 dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />

View file

@ -17,14 +17,14 @@ try:
log_info("Navigating to the logs page ...")
access_page(DRIVER, "/html/body/aside[1]/div[1]/div[2]/a", "account")
log_info("Looking that all desktop tabs are working ...")
log_info("Try to click on all available tabs ...")
assert_button_click(DRIVER, "//button[@data-tab-handler='global']")
assert_button_click(DRIVER, "//button[@data-tab-handler='username']")
assert_button_click(DRIVER, "//button[@data-tab-handler='password']")
assert_button_click(DRIVER, "//button[@data-tab-handler='totp']")
log_info("Start username tab ...")
log_info("All tabs working, start username tab ...")
assert_button_click(DRIVER, "//button[@data-tab-handler='username']")
@ -35,6 +35,8 @@ try:
log_error("The username is not correct, exiting ...")
exit(1)
log_info("username 'admin' is correctly set by default, trying username update ...")
DRIVER.execute_script(f"arguments[0].value = 'admin2'", username_input)
password_input = safe_get_element(DRIVER, By.ID, "curr_password")

View file

@ -8,6 +8,7 @@ from selenium.common.exceptions import TimeoutException
from wizard import DRIVER
from utils import access_page, assert_button_click, safe_get_element
from time import sleep
exit_code = 0
@ -25,6 +26,8 @@ try:
assert_button_click(DRIVER, "//button[@data-add-ban='']")
log_info("Add ban modal clicked ...")
try:
safe_get_element(DRIVER, By.XPATH, "//ul[@data-bans-add-ban-list='']/li", error=True)
except TimeoutException:
@ -33,6 +36,8 @@ try:
assert_button_click(DRIVER, "//button[@data-add-ban-delete-all-item='']")
log_info("Delete all add bans from button clicked ...")
with suppress(TimeoutException):
safe_get_element(DRIVER, By.XPATH, "//ul[@data-bans-add-ban-list='']/li", error=True)
log_error("Bans present even though they shouldn't be, exiting ...")
@ -55,6 +60,8 @@ try:
assert isinstance(ip_input, WebElement), "IP input not found"
ip_input.send_keys(f"127.0.0.{randint(123, 255)}")
log_info("Added 2 bans entries to modal, click on save ...")
access_page(DRIVER, "//button[@data-bans-modal-submit='']", "bans", False)
try:
@ -87,28 +94,47 @@ try:
# Reset
key_word_filter_input.send_keys("")
log_info("Keyword filter worked, trying select filters ...")
# Test select filters
select_filters = [{"name": "reason", "id": "reason", "value": "all"}, {"name": "range", "id": "term", "value": "all"}]
for item in select_filters:
DRIVER.execute_script(f"""document.querySelector('[data-bans-setting-select-dropdown-btn="{item["id"]}"][value="{item["value"]}"]').click()""")
log_info("Bans found, trying to delete them ...")
log_info("All filters worked, try to delete 1 ban ...")
try:
entries = safe_get_element(DRIVER, By.XPATH, "//ul[@data-bans-list='']/li", multiple=True, error=True)
assert isinstance(entries, list), "Bans not found"
log_info(f"Currently {len(entries)} bans items ...")
except TimeoutException:
log_exception("No bans found, exiting ...")
exit(1)
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)
log_info("Ban item id=2 checkbox clicked ...")
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)
log_info("Unban button clicked, access bans ...")
sleep(3)
access_page(DRIVER, False, "bans", False)
log_info("Acces page after delete action ...")
try:
entries = safe_get_element(DRIVER, By.XPATH, "//ul[@data-bans-list='']/li", multiple=True, error=True)
assert isinstance(entries, list), "Bans not found"
log_info(f"Currently {len(entries)} bans items ...")
except TimeoutException:
log_exception("No bans found, exiting ...")
exit(1)

View file

@ -31,23 +31,9 @@ try:
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("")
no_errors = True
retries = 0
while no_errors:

View file

@ -17,21 +17,26 @@ exit_code = 0
try:
log_info("Navigating to the services page ...")
access_page(DRIVER, "/html/body/aside[1]/div[1]/div[3]/ul/li[4]/a", "services")
log_info("Check if default www.example.com service is here ...")
service_name_elem = safe_get_element(DRIVER, By.XPATH, "//div[@data-services-service='www.example.com']//h5")
assert isinstance(service_name_elem, WebElement), "Service name element is not a WebElement"
if service_name_elem.text.strip() != "www.example.com":
log_error("The service is not present, exiting ...")
exit(1)
log_info("Service correctly checked, check if right method ...")
service_method_elem = safe_get_element(DRIVER, By.XPATH, "//div[@data-services-service='www.example.com']//h6")
assert isinstance(service_method_elem, WebElement), "Service method element is not a WebElement"
if service_method_elem.text.strip() != "ui":
log_error("The service should have been created by the ui, exiting ...")
exit(1)
log_info("Service www.example.com is present, trying to edit it ...")
log_info("Service method 'ui' correctly checked, additionnal check ...")
assert_button_click(DRIVER, "//div[@data-services-service='www.example.com']//button[@data-services-action='edit']")
@ -41,13 +46,17 @@ try:
log_error("Modal is hidden even though it shouldn't be, exiting ...")
exit(1)
log_info("Service edit modal checked ...")
input_server_name = safe_get_element(DRIVER, By.ID, "SERVER_NAME")
assert isinstance(input_server_name, WebElement), "Input is not a WebElement"
if input_server_name.get_attribute("value") != "www.example.com":
log_error("The value is not the expected one, exiting ...")
exit(1)
log_info('The value for the "SERVER_NAME" input is the expected one, trying to edit the config ...')
log_info("Input service checked ...")
log_info("Additionnal checks done, trying to edit the config ...")
assert_button_click(DRIVER, "//button[@data-tab-select-dropdown-btn='']")
assert_button_click(DRIVER, "//button[@data-tab-select-handler='gzip']")
@ -109,7 +118,9 @@ 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, False, "services", False)
log_info("Set new service values, trying to save ...")
access_page(DRIVER, "//button[@data-services-modal-submit='']", "services", False)
if TEST_TYPE == "linux":
wait_for_service("app1.example.com")
@ -137,7 +148,7 @@ try:
log_error("The service should have been created by the ui, exiting ...")
exit(1)
log_info("Service app1.example.com is present, trying it ...")
log_info("New service 'app1.example.com' is present, trying it ...")
try:
safe_get_element(DRIVER, By.XPATH, "//button[@data-services-action='edit' and @data-services-name='app1.example.com']//ancestor::div//a", error=True)
@ -289,7 +300,7 @@ try:
log_error("The service should have been created by the ui, exiting ...")
exit(1)
log_info("Service app3.example.com is present, trying filters...")
log_info("Service app3.example.com is present, trying service card filters...")
# Set keyword with no matching settings
keyword_no_match = "dqz48 é84 dzq 584dz5qd4"
@ -306,6 +317,8 @@ try:
# Reset
btn_keyword.send_keys("")
log_info("Service card keyword filter working, trying select filters ...")
# Test select filters
select_filters = [
{"name": "Method", "id": "method", "value": "all"},
@ -329,11 +342,15 @@ try:
# Click on the delete button
DRIVER.execute_script("arguments[0].click()", delete_card_button)
log_info("Delete button clicked, modal open ...")
delete_modal_button = safe_get_element(DRIVER, By.XPATH, "//form[@data-services-modal-form-delete='']//button[@type='submit']")
assert isinstance(delete_modal_button, WebElement), "Delete modal button is not a WebElement"
DRIVER.execute_script("arguments[0].click()", delete_modal_button)
log_info("Delete service modal button clicked, check if delete ...")
if TEST_TYPE == "linux":
wait_for_service()