summaryrefslogtreecommitdiff
path: root/tests/admin_views/tests.py
diff options
context:
space:
mode:
authorFab <fabianjarrett@gmail.com>2022-08-05 08:27:20 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-08-05 17:21:38 +0200
commit82e9e19ebe6bc920f1cfffc42d86648644fd4a78 (patch)
treee62070c2c227ef2e2fd2bef0b3124992c601cb39 /tests/admin_views/tests.py
parent7b0ed458d960f1b0bf5c46a74b2fef0e0def71b8 (diff)
[4.1.x] Fixed #33893 -- Reverted "Fixed #28889 -- Prevented double submission of admin forms."
Regression in fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa. Backport of 0756c61f2ada56e4ae625589099c0141a77737eb from main
Diffstat (limited to 'tests/admin_views/tests.py')
-rw-r--r--tests/admin_views/tests.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 88468e883c..3037ec1c3b 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -6432,6 +6432,45 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertEqual(traveler.living_country.name, "Italy")
self.assertEqual(traveler.favorite_country_to_vacation.name, "Qatar")
+ def test_redirect_on_add_view_add_another_button(self):
+ from selenium.webdriver.common.by import By
+
+ self.admin_login(
+ username="super", password="secret", login_url=reverse("admin:index")
+ )
+ add_url = reverse("admin7:admin_views_section_add")
+ self.selenium.get(self.live_server_url + add_url)
+ name_input = self.selenium.find_element(By.ID, "id_name")
+ name_input.send_keys("Test section 1")
+ self.selenium.find_element(
+ By.XPATH, '//input[@value="Save and add another"]'
+ ).click()
+ self.assertEqual(Section.objects.count(), 1)
+ name_input = self.selenium.find_element(By.ID, "id_name")
+ name_input.send_keys("Test section 2")
+ self.selenium.find_element(
+ By.XPATH, '//input[@value="Save and add another"]'
+ ).click()
+ self.assertEqual(Section.objects.count(), 2)
+
+ def test_redirect_on_add_view_continue_button(self):
+ from selenium.webdriver.common.by import By
+
+ self.admin_login(
+ username="super", password="secret", login_url=reverse("admin:index")
+ )
+ add_url = reverse("admin7:admin_views_section_add")
+ self.selenium.get(self.live_server_url + add_url)
+ name_input = self.selenium.find_element(By.ID, "id_name")
+ name_input.send_keys("Test section 1")
+ self.selenium.find_element(
+ By.XPATH, '//input[@value="Save and continue editing"]'
+ ).click()
+ self.assertEqual(Section.objects.count(), 1)
+ name_input = self.selenium.find_element(By.ID, "id_name")
+ name_input_value = name_input.get_attribute("value")
+ self.assertEqual(name_input_value, "Test section 1")
+
@override_settings(ROOT_URLCONF="admin_views.urls")
class ReadonlyTest(AdminFieldExtractionMixin, TestCase):