Skip to content

Commit

Permalink
Fix theme selenium integration test.
Browse files Browse the repository at this point in the history
The click actions were being triggered on the wrong element.
  • Loading branch information
tim-schilling committed May 26, 2024
1 parent 7271cac commit de2feca
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,19 +802,21 @@ def test_theme_toggle(self):
self.assertEqual(toolbar.get_attribute("data-theme"), "auto")

# The theme toggle button is shown on the toolbar
self.assertIn('<a id="djToggleThemeButton', toolbar.text)
toggle_button = self.selenium.find_element(By.ID, "djToggleThemeButton")
self.assertTrue(toggle_button.is_displayed())

# The theme changes when user clicks the button
self.selenium.find_element(By.ID, "djDebugToolbar").click()
toggle_button.click()
self.assertEqual(toolbar.get_attribute("data-theme"), "light")
self.selenium.find_element(By.ID, "djDebugToolbar").click()
toggle_button.click()
self.assertEqual(toolbar.get_attribute("data-theme"), "dark")
toggle_button.click()
self.assertEqual(toolbar.get_attribute("data-theme"), "auto")
# Switch back to light.
toggle_button.click()
self.assertEqual(toolbar.get_attribute("data-theme"), "light")

# Enter the page again to check that user settings is saved
self.get("/regular/basic/")
toolbar = self.selenium.find_element(By.ID, "djDebug")
self.assertEqual(toolbar.get_attribute("data-theme"), "dark")

# Set the default again and check that dark changes to auto
self.selenium.find_element(By.ID, "djDebugToolbar").click()
self.assertEqual(toolbar.get_attribute("data-theme"), "auto")
self.assertEqual(toolbar.get_attribute("data-theme"), "light")

0 comments on commit de2feca

Please sign in to comment.