Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add test for collapsible fieldset functionality in admin

  • Loading branch information...
commit ae2d04f7265bd804e82c601e9cbb52965c564418 1 parent fd3a066
Claude Paroz authored
10  tests/regressiontests/admin_views/admin.py
@@ -71,6 +71,16 @@ class ChapterXtra1Admin(admin.ModelAdmin):
71 71
 class ArticleAdmin(admin.ModelAdmin):
72 72
     list_display = ('content', 'date', callable_year, 'model_year', 'modeladmin_year')
73 73
     list_filter = ('date', 'section')
  74
+    fieldsets=(
  75
+        ('Some fields', {
  76
+            'classes': ('collapse',),
  77
+            'fields': ('title', 'content')
  78
+        }),
  79
+        ('Some other fields', {
  80
+            'classes': ('wide',),
  81
+            'fields': ('date', 'section')
  82
+        })
  83
+    )
74 84
 
75 85
     def changelist_view(self, request):
76 86
         "Test that extra_context works"
24  tests/regressiontests/admin_views/tests.py
@@ -3195,12 +3195,12 @@ def test_prepopulated_maxlength_localized(self):
3195 3195
 
3196 3196
 
3197 3197
 @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3198  
-class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
  3198
+class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
3199 3199
     webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
3200 3200
     urls = "regressiontests.admin_views.urls"
3201 3201
     fixtures = ['admin-views-users.xml']
3202 3202
 
3203  
-    def test_basic(self):
  3203
+    def test_prepopulated_fields(self):
3204 3204
         """
3205 3205
         Ensure that the JavaScript-automated prepopulated fields work with the
3206 3206
         main form and with stacked and tabular inlines.
@@ -3310,12 +3310,28 @@ def test_basic(self):
3310 3310
             slug2='option-one-tabular-inline-ignored-characters',
3311 3311
         )
3312 3312
 
  3313
+    def test_collapsible_fieldset(self):
  3314
+        """
  3315
+        Test that the 'collapse' class in fieldsets definition allows to
  3316
+        show/hide the appropriate field section.
  3317
+        """
  3318
+        self.admin_login(username='super', password='secret', login_url='/test_admin/admin/')
  3319
+        self.selenium.get('%s%s' % (self.live_server_url,
  3320
+            '/test_admin/admin/admin_views/article/add/'))
  3321
+        self.assertFalse(self.selenium.find_element_by_id('id_title').is_displayed())
  3322
+        self.selenium.find_elements_by_link_text('Show')[0].click()
  3323
+        self.assertTrue(self.selenium.find_element_by_id('id_title').is_displayed())
  3324
+        self.assertEqual(
  3325
+            self.selenium.find_element_by_id('fieldsetcollapser0').text,
  3326
+            "Hide"
  3327
+        )
  3328
+
3313 3329
 
3314  
-class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
  3330
+class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
3315 3331
     webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
3316 3332
 
3317 3333
 
3318  
-class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
  3334
+class SeleniumAdminViewsIETests(SeleniumAdminViewsFirefoxTests):
3319 3335
     webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
3320 3336
 
3321 3337
 

0 notes on commit ae2d04f

Please sign in to comment.
Something went wrong with that request. Please try again.