1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #36366 -- Improved accessibility of pagination in the admin.

This commit is contained in:
antoliny0919
2025-05-08 19:24:07 +09:00
committed by Sarah Boyce
parent 29f5e1e97d
commit 3f59711581
9 changed files with 118 additions and 33 deletions

View File

@@ -946,6 +946,41 @@ class ChangeListTests(TestCase):
self.assertEqual(cl.paginator.count, 30)
self.assertEqual(list(cl.paginator.page_range), [1, 2, 3])
def test_pagination_render(self):
objs = [Swallow(origin=f"Swallow {i}", load=i, speed=i) for i in range(1, 5)]
Swallow.objects.bulk_create(objs)
request = self.factory.get("/child/")
request.user = self.superuser
admin = SwallowAdmin(Swallow, custom_site)
cl = admin.get_changelist_instance(request)
template = Template(
"{% load admin_list %}{% spaceless %}{% pagination cl %}{% endspaceless %}"
)
context = Context({"cl": cl, "opts": cl.opts})
pagination_output = template.render(context)
self.assertTrue(
pagination_output.startswith(
'<nav class="paginator" aria-labelledby="pagination">'
)
)
self.assertInHTML(
'<h2 id="pagination" class="visually-hidden">Pagination swallows</h2>',
pagination_output,
)
self.assertTrue(pagination_output.endswith("</nav>"))
self.assertInHTML(
'<li><a role="button" href="" aria-current="page">1</a></li>',
pagination_output,
)
self.assertInHTML(
'<li><a role="button" href="?p=2">2</a></li>',
pagination_output,
)
self.assertEqual(pagination_output.count('aria-current="page"'), 1)
self.assertEqual(pagination_output.count('href=""'), 1)
def test_computed_list_display_localization(self):
"""
Regression test for #13196: output of functions should be localized