diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-04-25 17:15:16 -0700 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-29 07:01:41 +0200 |
commit | bdff97d373682d8e1693c24f3b9f4cf2445fd2a2 (patch) | |
tree | 2efa70e943ba3e9dbb69c869db585d6a91e8664c /tests/admin_changelist | |
parent | 68fc21b3784aa34c7ba5515ab02ef0c7b6ee856d (diff) | |
download | django-bdff97d373682d8e1693c24f3b9f4cf2445fd2a2.tar.gz |
Added tests for saving with pending actions in admin changelist.
Diffstat (limited to 'tests/admin_changelist')
-rw-r--r-- | tests/admin_changelist/admin.py | 2 | ||||
-rw-r--r-- | tests/admin_changelist/tests.py | 49 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index 1e686bd6fb..1194f26dd4 100644 --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -105,6 +105,8 @@ site.register(Child, DynamicListDisplayChildAdmin) class NoListDisplayLinksParentAdmin(admin.ModelAdmin): list_display_links = None + list_display = ['name'] + list_editable = ['name'] site.register(Parent, NoListDisplayLinksParentAdmin) diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 1d55813e22..4dff1edb32 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -1306,3 +1306,52 @@ class SeleniumTests(AdminSeleniumTestCase): '%s #result_list tbody tr:first-child .action-select' % form_id) row_selector.click() self.assertEqual(selection_indicator.text, "1 of 1 selected") + + def test_save_with_changes_warns_on_pending_action(self): + from selenium.webdriver.support.ui import Select + + Parent.objects.create(name='parent') + + self.admin_login(username='super', password='secret') + self.selenium.get(self.live_server_url + reverse('admin:admin_changelist_parent_changelist')) + + name_input = self.selenium.find_element_by_id('id_form-0-name') + name_input.clear() + name_input.send_keys('other name') + Select( + self.selenium.find_element_by_name('action') + ).select_by_value('delete_selected') + self.selenium.find_element_by_name('_save').click() + alert = self.selenium.switch_to.alert + try: + self.assertEqual( + alert.text, + 'You have selected an action, but you haven\'t saved your ' + 'changes to individual fields yet. Please click OK to save. ' + 'You\'ll need to re-run the action.', + ) + finally: + alert.dismiss() + + def test_save_without_changes_warns_on_pending_action(self): + from selenium.webdriver.support.ui import Select + + Parent.objects.create(name='parent') + + self.admin_login(username='super', password='secret') + self.selenium.get(self.live_server_url + reverse('admin:admin_changelist_parent_changelist')) + + Select( + self.selenium.find_element_by_name('action') + ).select_by_value('delete_selected') + self.selenium.find_element_by_name('_save').click() + alert = self.selenium.switch_to.alert + try: + self.assertEqual( + alert.text, + 'You have selected an action, and you haven\'t made any ' + 'changes on individual fields. You\'re probably looking for ' + 'the Go button rather than the Save button.', + ) + finally: + alert.dismiss() |