Skip to content

Commit

Permalink
Fixed isolation of SeleniumTests.test_search_input_filtered_page() test.
Browse files Browse the repository at this point in the history
Test crashed when the sidebar was not closed.
  • Loading branch information
felixxm committed Jul 4, 2023
1 parent 968684a commit 42b4f81
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/admin_views/tests.py
Expand Up @@ -5635,6 +5635,10 @@ def test_view_only_change_form(self):
self.assertContains(response, '<div class="readonly">%s</div>' % self.p1.slug)


def _clean_sidebar_state(driver):
driver.execute_script("localStorage.removeItem('django.admin.navSidebarIsOpen')")


@override_settings(ROOT_URLCONF="admin_views.urls")
class SeleniumTests(AdminSeleniumTestCase):
available_apps = ["admin_views"] + AdminSeleniumTestCase.available_apps
Expand Down Expand Up @@ -6113,6 +6117,7 @@ def test_list_editable_popups(self):
By.CSS_SELECTOR, "#toggle-nav-sidebar"
)
toggle_button.click()
self.addCleanup(_clean_sidebar_state, self.selenium)
select = Select(self.selenium.find_element(By.ID, "id_form-0-section"))
self.assertEqual(select.first_selected_option.text, "<i>edited section</i>")
# Rendered select2 input.
Expand Down Expand Up @@ -6291,6 +6296,12 @@ def test_search_input_filtered_page(self):
)
person_url = reverse("admin:admin_views_person_changelist") + "?q=Gui"
self.selenium.get(self.live_server_url + person_url)
# Hide sidebar.
toggle_button = self.selenium.find_element(
By.CSS_SELECTOR, "#toggle-nav-sidebar"
)
toggle_button.click()
self.addCleanup(_clean_sidebar_state, self.selenium)
self.assertGreater(
self.selenium.find_element(By.ID, "searchbar").rect["width"],
50,
Expand Down

0 comments on commit 42b4f81

Please sign in to comment.