From 85366fbca723c9b37d0ac9db1d44e3f1cb188db2 Mon Sep 17 00:00:00 2001 From: Durval Carvalho Date: Tue, 31 Jan 2023 15:05:03 -0300 Subject: Fixed #34045 -- Improved accessibility of selecting items in admin changelist. This adds "aria-label". --- tests/admin_changelist/tests.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/admin_changelist') diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 413d6d4d7f..c603f15298 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -74,15 +74,15 @@ from .models import ( ) -def build_tbody_html(pk, href, extra_fields): +def build_tbody_html(obj, href, extra_fields): return ( "" '' '' + 'class="action-select" aria-label="Select this object for an action - {}">' 'name' "{}" - ).format(pk, href, extra_fields) + ).format(obj.pk, str(obj), href, extra_fields) @override_settings(ROOT_URLCONF="admin_changelist.urls") @@ -245,7 +245,7 @@ class ChangeListTests(TestCase): table_output = template.render(context) link = reverse("admin:admin_changelist_child_change", args=(new_child.id,)) row_html = build_tbody_html( - new_child.id, link, '-' + new_child, link, '-' ) self.assertNotEqual( table_output.find(row_html), @@ -272,7 +272,7 @@ class ChangeListTests(TestCase): table_output = template.render(context) link = reverse("admin:admin_changelist_child_change", args=(new_child.id,)) row_html = build_tbody_html( - new_child.id, link, '???' + new_child, link, '???' ) self.assertNotEqual( table_output.find(row_html), @@ -297,7 +297,7 @@ class ChangeListTests(TestCase): table_output = template.render(context) link = reverse("admin:admin_changelist_child_change", args=(new_child.id,)) row_html = build_tbody_html( - new_child.id, + new_child, link, '†' '-empty-', @@ -327,13 +327,18 @@ class ChangeListTests(TestCase): table_output = template.render(context) link = reverse("admin:admin_changelist_child_change", args=(new_child.id,)) row_html = build_tbody_html( - new_child.id, link, '%s' % new_parent + new_child, link, '%s' % new_parent ) self.assertNotEqual( table_output.find(row_html), -1, "Failed to find expected row element: %s" % table_output, ) + self.assertInHTML( + '', + table_output, + ) def test_result_list_editable_html(self): """ -- cgit v1.3