summaryrefslogtreecommitdiff
path: root/tests/admin_widgets/tests.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-12-30 10:09:43 -0500
committerTim Graham <timograham@gmail.com>2015-12-30 14:10:09 -0500
commit7bc94b58bf4e139b669d023e0fb10ce380fc89f6 (patch)
treee975e9a54fc3f09aeaef7909bf6ff6882b272910 /tests/admin_widgets/tests.py
parente0f370364adc5d0dc3d7e4f678599c76868e29b0 (diff)
downloaddjango-7bc94b58bf4e139b669d023e0fb10ce380fc89f6.tar.gz
Refs #13614 -- Added test for admin's many-to-many widget data loss bug.
It looks like browsers have fixed the reported issue.
Diffstat (limited to 'tests/admin_widgets/tests.py')
-rw-r--r--tests/admin_widgets/tests.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index ce1ef0eb7d..1fe4741125 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -1140,6 +1140,32 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(SeleniumDataMixin, AdminSelen
self.assertEqual(list(self.school.alumni.all()),
[self.jason, self.peter])
+ def test_back_button_bug(self):
+ """
+ Some browsers had a bug where navigating away from the change page
+ and then clicking the browser's back button would clear the
+ filter_horizontal/filter_vertical widgets (#13614).
+ """
+ self.school.students.set([self.lisa, self.peter])
+ self.school.alumni.set([self.lisa, self.peter])
+ self.admin_login(username='super', password='secret', login_url='/')
+ change_url = reverse('admin:admin_widgets_school_change', args=(self.school.id,))
+ self.selenium.get(self.live_server_url + change_url)
+ # Navigate away and go back to the change form page.
+ self.selenium.find_element_by_link_text('Home').click()
+ self.selenium.back()
+ self.wait_for('#id_students_from')
+ expected_unselected_values = [
+ str(self.arthur.id), str(self.bob.id), str(self.cliff.id),
+ str(self.jason.id), str(self.jenny.id), str(self.john.id),
+ ]
+ expected_selected_values = [str(self.lisa.id), str(self.peter.id)]
+ # Check that everything is still in place
+ self.assertSelectOptions('#id_students_from', expected_unselected_values)
+ self.assertSelectOptions('#id_students_to', expected_selected_values)
+ self.assertSelectOptions('#id_alumni_from', expected_unselected_values)
+ self.assertSelectOptions('#id_alumni_to', expected_selected_values)
+
class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'