mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Converted tests for admin first form widget auto-focus to Selenium.
Refs #1707 and 1c0c879be3
.
This commit is contained in:
parent
c01cd4c423
commit
41feab3654
@ -689,27 +689,6 @@ class AdminJavaScriptTest(TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
|
|
||||||
def testSingleWidgetFirsFieldFocus(self):
|
|
||||||
"""
|
|
||||||
JavaScript-assisted auto-focus on first field.
|
|
||||||
"""
|
|
||||||
response = self.client.get('/test_admin/%s/admin_views/picture/add/' % 'admin')
|
|
||||||
self.assertContains(
|
|
||||||
response,
|
|
||||||
'<script type="text/javascript">document.getElementById("id_name").focus();</script>'
|
|
||||||
)
|
|
||||||
|
|
||||||
def testMultiWidgetFirsFieldFocus(self):
|
|
||||||
"""
|
|
||||||
JavaScript-assisted auto-focus should work if a model/ModelAdmin setup
|
|
||||||
is such that the first form field has a MultiWidget.
|
|
||||||
"""
|
|
||||||
response = self.client.get('/test_admin/%s/admin_views/reservation/add/' % 'admin')
|
|
||||||
self.assertContains(
|
|
||||||
response,
|
|
||||||
'<script type="text/javascript">document.getElementById("id_start_date_0").focus();</script>'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_js_minified_only_if_debug_is_false(self):
|
def test_js_minified_only_if_debug_is_false(self):
|
||||||
"""
|
"""
|
||||||
Ensure that the minified versions of the JS files are only used when
|
Ensure that the minified versions of the JS files are only used when
|
||||||
@ -3543,6 +3522,25 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||||||
"Hide"
|
"Hide"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_first_field_focus(self):
|
||||||
|
"""JavaScript-assisted auto-focus on first usable form field."""
|
||||||
|
# First form field has a single widget
|
||||||
|
self.admin_login(username='super', password='secret', login_url='/test_admin/admin/')
|
||||||
|
self.selenium.get('%s%s' % (self.live_server_url,
|
||||||
|
'/test_admin/admin/admin_views/picture/add/'))
|
||||||
|
self.assertEqual(
|
||||||
|
self.selenium.switch_to_active_element(),
|
||||||
|
self.selenium.find_element_by_id('id_name')
|
||||||
|
)
|
||||||
|
|
||||||
|
# First form field has a MultiWidget
|
||||||
|
self.selenium.get('%s%s' % (self.live_server_url,
|
||||||
|
'/test_admin/admin/admin_views/reservation/add/'))
|
||||||
|
self.assertEqual(
|
||||||
|
self.selenium.switch_to_active_element(),
|
||||||
|
self.selenium.find_element_by_id('id_start_date_0')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
|
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
Loading…
Reference in New Issue
Block a user