added locally hosted htmx dependency; updated base.html template & req's files accordingly; wrote new FT (failing) in test_dashboard that calls for this lib
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
@@ -37,3 +38,64 @@ class DashboardMaintenanceTest(FunctionalTest):
|
||||
self.browser.find_element(By.CSS_SELECTOR, "#id_new_username").get_attribute("value")
|
||||
)
|
||||
)
|
||||
|
||||
def test_user_can_toggle_applet_visibility_via_gear_menu(self):
|
||||
# 1. Auth as discoman@example.com, navigate home
|
||||
self.create_pre_authenticated_session("discoman@example.com")
|
||||
self.browser.get(self.live_server_url)
|
||||
# 2. Assert both applets present on page (id_applet_username, id_applet_theme_switcher)
|
||||
self.browser.find_element(By.ID, "id_applet_username")
|
||||
self.browser.find_element(By.ID, "id_applet_theme_switcher")
|
||||
# 3. Click el w. id="id_dash_gear"
|
||||
dash_gear = self.browser.find_element(By.ID, "id_dash_gear")
|
||||
dash_gear.click()
|
||||
# 4. A menu appears; wait_for el w. id="id_applet_menu"
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_applet_menu")
|
||||
)
|
||||
# 5. Find two checkboxes in menu, name="username" & name="theme-switcher"; assert both .is_selected()
|
||||
menu = self.browser.find_element(By.ID, "id_applet_menu")
|
||||
username_cb = menu.find_element(By.NAME, "username")
|
||||
theme_cb = menu.find_element(By.NAME, "theme-switcher")
|
||||
self.assertTrue(username_cb.is_selected())
|
||||
self.assertTrue(theme_cb.is_selected())
|
||||
# 6. Click theme-switcher box to uncheck it
|
||||
theme_cb.click()
|
||||
self.assertFalse(theme_cb.is_selected())
|
||||
self.browser.execute_script("window.__no_reload_marker = True")
|
||||
# 7. Submit the menu form via [type="submit"] btn inside menu
|
||||
menu.find_element(By.CSS_SELECTOR, '[type="submit"]').click()
|
||||
self.wait_for(
|
||||
lambda: self.assertFalse(
|
||||
self.browser.find_element(By.ID, "id_applet_menu").is_displayed()
|
||||
)
|
||||
)
|
||||
# 8. wait_for theme-switcher applet to be gone
|
||||
self.wait_for(
|
||||
lambda: self.assertRaises(
|
||||
NoSuchElementException,
|
||||
self.browser.find_element,
|
||||
By.ID, "id_applet_theme_switcher"
|
||||
)
|
||||
)
|
||||
# 9. assert id_applet_username remains
|
||||
self.browser.find_element(By.ID, "id_applet_username")
|
||||
# 10. Click gear again, find menu, find theme-switcher checkbox; assert now NOT selected
|
||||
dash_gear.click()
|
||||
self.assertFalse(theme_cb.is_selected())
|
||||
# 11. Click it to re-check box; submit
|
||||
theme_cb.click()
|
||||
self.assertTrue(theme_cb.is_selected())
|
||||
menu.find_element(By.CSS_SELECTOR, '[type="submit"]').click()
|
||||
# 12. wait_for id_applet_theme_switcher to reappear
|
||||
self.wait_for(
|
||||
lambda: self.assertFalse(
|
||||
self.browser.find_element(By.ID, "id_applet_menu").is_displayed()
|
||||
)
|
||||
)
|
||||
self.wait_for(
|
||||
lambda: self.assertTrue(
|
||||
self.browser.find_element(By.ID, "id_applet_theme_switcher")
|
||||
)
|
||||
)
|
||||
self.assertTrue(self.browser.execute_script("return window.__no_reload_marker === true"))
|
||||
|
||||
Reference in New Issue
Block a user