Skip to content

Commit

Permalink
ci/cd - add sleep intervals to improve stability of UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheophileDiot committed Nov 4, 2024
1 parent 2f1daa1 commit 4fc2385
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/ui/configs_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@

log_info("Trying to create a new config ...")

sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-element='server-http' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-add-file='']")

configs_modal_path_input = safe_get_element(DRIVER, By.XPATH, "//div[@data-configs-modal-path='']/input")
Expand Down Expand Up @@ -107,6 +109,7 @@
log_info("Check path with conf only filter ...")

assert_button_click(DRIVER, "//button[@data-configs-setting-select='withconf']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-setting-select-dropdown-btn='withconf' and @value='true']")

is_server_http_folder_hidden = DRIVER.execute_script(
Expand All @@ -125,13 +128,17 @@

# Reset
assert_button_click(DRIVER, "//button[@data-configs-setting-select='withconf']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-setting-select-dropdown-btn='withconf' and @value='false']")

log_info("Check path with conf only filter done, check show global conf only ...")

sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-setting-select='globalconf']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-setting-select-dropdown-btn='globalconf' and @value='true']")

sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-element='http' and @data-_type='folder']")

is_app1_example_com_folder_hidden = DRIVER.execute_script(
Expand All @@ -143,21 +150,28 @@
exit(1)

assert_button_click(DRIVER, "//button[@data-configs-setting-select='globalconf']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-setting-select-dropdown-btn='globalconf' and @value='false']")

log_info("Check show global conf only done...")

log_info("Filters working, trying breadcrumb ...")

assert_button_click(DRIVER, "//div[@data-configs-element='http' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//li[@data-configs-breadcrumb-item]")
sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-element='http' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//li[@data-configs-breadcrumb-item and @data-level='0']/button")

log_info("Breadcrumb working, trying to delete the config ...")

sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-element='server-http' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-action-button='hello.conf']")
sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-action-dropdown='hello.conf']/button[@value='delete' and @data-configs-action-dropdown-btn='hello.conf']")

access_page(DRIVER, "//button[@data-configs-modal-submit='']", "configs", False)
Expand All @@ -178,7 +192,9 @@
log_info("The config has been deleted, trying the same for a specific service ...")

assert_button_click(DRIVER, "//div[@data-configs-element='server-http' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//div[@data-path='/etc/bunkerweb/configs/server-http/app1.example.com' and @data-_type='folder']")
sleep(1)
assert_button_click(DRIVER, "//button[@data-configs-add-file='']")

configs_modal_path_input = safe_get_element(DRIVER, By.XPATH, "//div[@data-configs-modal-path='']/input")
Expand Down Expand Up @@ -235,6 +251,7 @@

assert_button_click(DRIVER, "//button[@data-services-action='delete' and @data-services-name='app1.example.com']")

sleep(1)
access_page(DRIVER, "//form[@data-services-modal-form-delete='']//button[@type='submit']", "services", False)

if TEST_TYPE == "linux":
Expand All @@ -244,6 +261,7 @@

access_page(DRIVER, "/html/body/aside[1]/div[2]/ul[1]/li[5]/a", "configs")

sleep(1)
assert_button_click(DRIVER, "//div[@data-configs-element='server-http' and @data-_type='folder']")

with suppress(TimeoutException):
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/services_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@

log_info("Service app2.example.com is present, trying it ...")

DRIVER.refresh()

wait_for_service("app2.example.com")

try:
Expand All @@ -414,8 +416,12 @@

log_info("The service is working, trying to set it as draft ...")

sleep(2)

assert_button_click(DRIVER, "//div[@data-services-service='app2.example.com']//button[@data-services-action='edit']")

sleep(2)

assert_button_click(DRIVER, "//button[@data-toggle-draft-btn='']")

access_page(DRIVER, "//form[@data-services-modal-form and @data-advanced]//button[@data-services-modal-submit='']", "services", False)
Expand Down

0 comments on commit 4fc2385

Please sign in to comment.