Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for collapsible fieldset functionality in admin

  • Loading branch information...
commit ae2d04f7265bd804e82c601e9cbb52965c564418 1 parent fd3a066
Claude Paroz claudep authored
10 tests/regressiontests/admin_views/admin.py
View
@@ -71,6 +71,16 @@ class ChapterXtra1Admin(admin.ModelAdmin):
class ArticleAdmin(admin.ModelAdmin):
list_display = ('content', 'date', callable_year, 'model_year', 'modeladmin_year')
list_filter = ('date', 'section')
+ fieldsets=(
+ ('Some fields', {
+ 'classes': ('collapse',),
+ 'fields': ('title', 'content')
+ }),
+ ('Some other fields', {
+ 'classes': ('wide',),
+ 'fields': ('date', 'section')
+ })
+ )
def changelist_view(self, request):
"Test that extra_context works"
24 tests/regressiontests/admin_views/tests.py
View
@@ -3195,12 +3195,12 @@ def test_prepopulated_maxlength_localized(self):
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
-class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
+class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
urls = "regressiontests.admin_views.urls"
fixtures = ['admin-views-users.xml']
- def test_basic(self):
+ def test_prepopulated_fields(self):
"""
Ensure that the JavaScript-automated prepopulated fields work with the
main form and with stacked and tabular inlines.
@@ -3310,12 +3310,28 @@ def test_basic(self):
slug2='option-one-tabular-inline-ignored-characters',
)
+ def test_collapsible_fieldset(self):
+ """
+ Test that the 'collapse' class in fieldsets definition allows to
+ show/hide the appropriate field section.
+ """
+ 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/article/add/'))
+ self.assertFalse(self.selenium.find_element_by_id('id_title').is_displayed())
+ self.selenium.find_elements_by_link_text('Show')[0].click()
+ self.assertTrue(self.selenium.find_element_by_id('id_title').is_displayed())
+ self.assertEqual(
+ self.selenium.find_element_by_id('fieldsetcollapser0').text,
+ "Hide"
+ )
+
-class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
+class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
-class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
+class SeleniumAdminViewsIETests(SeleniumAdminViewsFirefoxTests):
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
Please sign in to comment.
Something went wrong with that request. Please try again.