@@ -802,19 +802,21 @@ def test_theme_toggle(self):
802
802
self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
803
803
804
804
# The theme toggle button is shown on the toolbar
805
- self .assertIn ('<a id="djToggleThemeButton' , toolbar .text )
805
+ toggle_button = self .selenium .find_element (By .ID , "djToggleThemeButton" )
806
+ self .assertTrue (toggle_button .is_displayed ())
806
807
807
808
# The theme changes when user clicks the button
808
- self . selenium . find_element ( By . ID , "djDebugToolbar" ) .click ()
809
+ toggle_button .click ()
809
810
self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
810
- self . selenium . find_element ( By . ID , "djDebugToolbar" ) .click ()
811
+ toggle_button .click ()
811
812
self .assertEqual (toolbar .get_attribute ("data-theme" ), "dark" )
813
+ toggle_button .click ()
814
+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
815
+ # Switch back to light.
816
+ toggle_button .click ()
817
+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
812
818
813
819
# Enter the page again to check that user settings is saved
814
820
self .get ("/regular/basic/" )
815
821
toolbar = self .selenium .find_element (By .ID , "djDebug" )
816
- self .assertEqual (toolbar .get_attribute ("data-theme" ), "dark" )
817
-
818
- # Set the default again and check that dark changes to auto
819
- self .selenium .find_element (By .ID , "djDebugToolbar" ).click ()
820
- self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
822
+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
0 commit comments