diff options
| author | Tim Graham <timograham@gmail.com> | 2017-12-01 14:00:00 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-01 22:14:32 -0500 |
| commit | 81057645f61fe545f4f11737dbd3040043ed2436 (patch) | |
| tree | 3ab66278054967fc51614e063732be2ff30c12c8 /tests/admin_views/test_autocomplete_view.py | |
| parent | 095c1aaa898bed40568009db836aa8434f1b983d (diff) | |
Fixed #28871 -- Fixed initialization of autocomplete widgets in "Add another" inlines.
Also allowed autocomplete widgets to work on AdminSites with a name other
than 'admin'.
Diffstat (limited to 'tests/admin_views/test_autocomplete_view.py')
| -rw-r--r-- | tests/admin_views/test_autocomplete_view.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/admin_views/test_autocomplete_view.py b/tests/admin_views/test_autocomplete_view.py index b8c12448e1..8db18d2468 100644 --- a/tests/admin_views/test_autocomplete_view.py +++ b/tests/admin_views/test_autocomplete_view.py @@ -17,6 +17,7 @@ PAGINATOR_SIZE = AutocompleteJsonView.paginate_by class AuthorAdmin(admin.ModelAdmin): + ordering = ['id'] search_fields = ['id'] @@ -229,3 +230,23 @@ class SeleniumTests(AdminSeleniumTestCase): search.send_keys(Keys.RETURN) select = Select(self.selenium.find_element_by_id('id_related_questions')) self.assertEqual(len(select.all_selected_options), 2) + + def test_inline_add_another_widgets(self): + def assertNoResults(row): + elem = row.find_element_by_css_selector('.select2-selection') + elem.click() # Open the autocomplete dropdown. + results = self.selenium.find_element_by_css_selector('.select2-results') + self.assertTrue(results.is_displayed()) + option = self.selenium.find_element_by_css_selector('.select2-results__option') + self.assertEqual(option.text, 'No results found') + + # Autocomplete works in rows present when the page loads. + self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_book_add')) + rows = self.selenium.find_elements_by_css_selector('.dynamic-authorship_set') + self.assertEqual(len(rows), 3) + assertNoResults(rows[0]) + # Autocomplete works in rows added using the "Add another" button. + self.selenium.find_element_by_link_text('Add another Authorship').click() + rows = self.selenium.find_elements_by_css_selector('.dynamic-authorship_set') + self.assertEqual(len(rows), 4) + assertNoResults(rows[-1]) |
