From 7bc94b58bf4e139b669d023e0fb10ce380fc89f6 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 30 Dec 2015 10:09:43 -0500 Subject: [PATCH] Refs #13614 -- Added test for admin's many-to-many widget data loss bug. It looks like browsers have fixed the reported issue. --- tests/admin_widgets/tests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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'