MCPcopy
hub / github.com/django/django / test_prepopulated_fields

Method test_prepopulated_fields

tests/admin_views/tests.py:6326–6579  ·  view source on GitHub ↗

The JavaScript-automated prepopulated fields work with the main form and with stacked and tabular inlines. Refs #13068, #9264, #9983, #9784.

(self)

Source from the content-addressed store, hash-verified

6324 self.take_screenshot("login")
6325
6326 def test_prepopulated_fields(self):
6327 """
6328 The JavaScript-automated prepopulated fields work with the main form
6329 and with stacked and tabular inlines.
6330 Refs #13068, #9264, #9983, #9784.
6331 """
6332 from selenium.webdriver import ActionChains
6333 from selenium.webdriver.common.by import By
6334
6335 self.admin_login(
6336 username="super", password="secret", login_url=reverse("admin:index")
6337 )
6338 self.selenium.get(
6339 self.live_server_url + reverse("admin:admin_views_mainprepopulated_add")
6340 )
6341 self.wait_for(".select2")
6342
6343 # Main form ----------------------------------------------------------
6344 self.selenium.find_element(By.ID, "id_pubdate").send_keys("2012-02-18")
6345 status = self.selenium.find_element(By.ID, "id_status")
6346 ActionChains(self.selenium).move_to_element(status).click(status).perform()
6347 self.select_option("#id_status", "option two")
6348 self.selenium.find_element(By.ID, "id_name").send_keys(
6349 " the mAin nÀMë and it's awεšomeıııİ"
6350 )
6351 slug1 = self.selenium.find_element(By.ID, "id_slug1").get_attribute("value")
6352 slug2 = self.selenium.find_element(By.ID, "id_slug2").get_attribute("value")
6353 slug3 = self.selenium.find_element(By.ID, "id_slug3").get_attribute("value")
6354 self.assertEqual(slug1, "the-main-name-and-its-awesomeiiii-2012-02-18")
6355 self.assertEqual(slug2, "option-two-the-main-name-and-its-awesomeiiii")
6356 self.assertEqual(
6357 slug3, "the-main-n\xe0m\xeb-and-its-aw\u03b5\u0161ome\u0131\u0131\u0131i"
6358 )
6359
6360 # Stacked inlines with fieldsets -------------------------------------
6361 # Initial inline
6362 self.selenium.find_element(
6363 By.ID, "id_relatedprepopulated_set-0-pubdate"
6364 ).send_keys("2011-12-17")
6365 status = self.selenium.find_element(
6366 By.ID, "id_relatedprepopulated_set-0-status"
6367 )
6368 ActionChains(self.selenium).move_to_element(status).click(status).perform()
6369 self.select_option("#id_relatedprepopulated_set-0-status", "option one")
6370 self.selenium.find_element(
6371 By.ID, "id_relatedprepopulated_set-0-name"
6372 ).send_keys(" here is a sŤāÇkeð inline ! ")
6373 slug1 = self.selenium.find_element(
6374 By.ID, "id_relatedprepopulated_set-0-slug1"
6375 ).get_attribute("value")
6376 slug2 = self.selenium.find_element(
6377 By.ID, "id_relatedprepopulated_set-0-slug2"
6378 ).get_attribute("value")
6379 self.assertEqual(slug1, "here-is-a-stacked-inline-2011-12-17")
6380 self.assertEqual(slug2, "option-one-here-is-a-stacked-inline")
6381 initial_select2_inputs = self.selenium.find_elements(
6382 By.CLASS_NAME, "select2-selection"
6383 )

Callers

nothing calls this directly

Calls 7

reverseFunction · 0.90
admin_loginMethod · 0.80
wait_forMethod · 0.80
select_optionMethod · 0.80
wait_page_loadedMethod · 0.80
getMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected