From 0cc32a8f9782f0e465b4653012de9bc41e6d7db4 Mon Sep 17 00:00:00 2001 From: elky Date: Wed, 2 Dec 2015 17:34:35 +0500 Subject: [PATCH] Refs #22955 -- Added test for admin's many-to-many widget refresh data loss bug. This was fixed by 4a438e400b7ce0ab9d0b6876196cbe8d620a4171. --- tests/admin_widgets/tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index d1966a1364..25c2e1ab15 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -1166,6 +1166,30 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(SeleniumDataMixin, AdminSelen self.assertSelectOptions('#id_alumni_from', expected_unselected_values) self.assertSelectOptions('#id_alumni_to', expected_selected_values) + def test_refresh_page(self): + """ + Horizontal and vertical filter widgets keep selected options on page + reload (#22955). + """ + self.school.students.add(self.arthur, self.jason) + self.school.alumni.add(self.arthur, self.jason) + + 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) + + options_len = len(self.selenium.find_elements_by_css_selector('#id_students_to > option')) + self.assertEqual(options_len, 2) + + # self.selenium.refresh() or send_keys(Keys.F5) does hard reload and + # doesn't replicate what happens when a user clicks the browser's + # 'Refresh' button. + self.selenium.execute_script("location.reload()") + self.wait_page_loaded() + + options_len = len(self.selenium.find_elements_by_css_selector('#id_students_to > option')) + self.assertEqual(options_len, 2) + class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests): webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'