diff options
| author | Bas Peschier <basp@fabrique.nl> | 2014-02-22 11:36:15 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-22 13:26:29 +0100 |
| commit | 578bdb532cd88333569ef3f77042653e1a9f2d9d (patch) | |
| tree | 8d864b6979246691071c47bd4aca09813d1c4b97 /tests | |
| parent | 462edd22e5577ff9ee6477f7572b571700d1a2aa (diff) | |
Added tests and minified javascript missing in 83a3add4bed8d8d49f93b30c817c66908b0a26ba.
Refs #22038.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_changelist/admin.py | 4 | ||||
| -rw-r--r-- | tests/admin_changelist/fixtures/users.json | 20 | ||||
| -rw-r--r-- | tests/admin_changelist/tests.py | 46 |
3 files changed, 69 insertions, 1 deletions
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index 42b8c959af..b2bd578e80 100644 --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -1,11 +1,15 @@ from django.contrib import admin from django.core.paginator import Paginator +from django.contrib.auth.admin import UserAdmin +from django.contrib.auth.models import User from .models import Event, Child, Parent, Swallow site = admin.AdminSite(name="admin") +site.register(User, UserAdmin) + class CustomPaginator(Paginator): def __init__(self, queryset, page_size, orphans=0, allow_empty_first_page=True): diff --git a/tests/admin_changelist/fixtures/users.json b/tests/admin_changelist/fixtures/users.json new file mode 100644 index 0000000000..72d86d70ad --- /dev/null +++ b/tests/admin_changelist/fixtures/users.json @@ -0,0 +1,20 @@ +[ + { + "pk": 100, + "model": "auth.user", + "fields": { + "username": "super", + "first_name": "Super", + "last_name": "User", + "is_active": true, + "is_superuser": true, + "is_staff": true, + "last_login": "2007-05-30 13:20:10", + "groups": [], + "user_permissions": [], + "password": "sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158", + "email": "super@example.com", + "date_joined": "2007-05-30 13:20:10" + } + } +] diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 4819dfe4d9..ca889f0648 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -6,10 +6,11 @@ from django.contrib import admin from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.admin.templatetags.admin_list import pagination from django.contrib.admin.views.main import ChangeList, SEARCH_VAR, ALL_VAR +from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.template import Context, Template -from django.test import TestCase +from django.test import TestCase, override_settings from django.test.client import RequestFactory from django.utils import formats from django.utils import six @@ -661,3 +662,46 @@ class AdminLogNodeTestCase(TestCase): # Rendering should be u'' since this templatetag just logs, # it doesn't render any string. self.assertEqual(template.render(context), '') + + +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): + + available_apps = ['admin_changelist'] + AdminSeleniumWebDriverTestCase.available_apps + fixtures = ['users.json'] + urls = "admin_changelist.urls" + webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' + + def test_add_row_selection(self): + """ + Ensure that the status line for selected rows gets updated correcly (#22038) + """ + self.admin_login(username='super', password='secret') + self.selenium.get('%s%s' % (self.live_server_url, + '/admin/auth/user/')) + + form_id = '#changelist-form' + + # Test amount of rows in the Changelist + rows = self.selenium.find_elements_by_css_selector( + '%s #result_list tbody tr' % form_id) + self.assertEqual(len(rows), 1) + + # Test current selection + selection_indicator = self.selenium.find_element_by_css_selector( + '%s .action-counter' % form_id) + self.assertEqual(selection_indicator.text, "0 of 1 selected") + + # Select a row and check again + row_selector = self.selenium.find_element_by_css_selector( + '%s #result_list tbody tr:first-child .action-select' % form_id) + row_selector.click() + self.assertEqual(selection_indicator.text, "1 of 1 selected") + + +class SeleniumChromeTests(SeleniumFirefoxTests): + webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' + + +class SeleniumIETests(SeleniumFirefoxTests): + webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' |
