Skip to content

Fix theme selenium integration test. #1915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Loading