diff options
| author | Eliana Rosselli <elianarosselli@Octobots-MacBook-Pro.local> | 2023-10-20 09:42:30 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-15 21:01:00 +0100 |
| commit | c83c639ba0c67dbb0f627be3df29d1224ea92d2b (patch) | |
| tree | c5d4a6e7e7a7bc925f6fcbb1d472be413fb3525c /tests/admin_views | |
| parent | 5b885106a7e5e27c4a85d8e9223bfd880f6851e2 (diff) | |
Fixed #34909 -- Associated links in admin navigation sidebar with row descriptions.
This adds aria-describedby attribute to the models' links in the admin
navigation sidebar.
Thanks Thibaud Colas for the review.
Co-authored-by: Dara Silvera <dsilvera@octobot.io>
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/test_nav_sidebar.py | 3 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/admin_views/test_nav_sidebar.py b/tests/admin_views/test_nav_sidebar.py index e9b367b63b..1875a2f7a1 100644 --- a/tests/admin_views/test_nav_sidebar.py +++ b/tests/admin_views/test_nav_sidebar.py @@ -111,9 +111,10 @@ class AdminSidebarTests(TestCase): self.assertContains(response, '<tr class="model-héllo current-model">') self.assertContains( response, - '<th scope="row">' + '<th scope="row" id="admin_views-héllo">' '<a href="/test_sidebar/admin/admin_views/h%C3%A9llo/" aria-current="page">' "Héllos</a></th>", + html=True, ) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 98a77221b2..cb61c88941 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1605,6 +1605,29 @@ class AdminViewBasicTest(AdminViewBasicTestCase): '<main id="content-start" class="content" tabindex="-1">', ) + def test_aria_describedby_for_add_and_change_links(self): + response = self.client.get(reverse("admin:index")) + tests = [ + ("admin_views", "actor"), + ("admin_views", "worker"), + ("auth", "group"), + ("auth", "user"), + ] + for app_label, model_name in tests: + with self.subTest(app_label=app_label, model_name=model_name): + row_id = f"{app_label}-{model_name}" + self.assertContains(response, f'<th scope="row" id="{row_id}">') + self.assertContains( + response, + f'<a href="/test_admin/admin/{app_label}/{model_name}/" ' + f'class="changelink" aria-describedby="{row_id}">Change</a>', + ) + self.assertContains( + response, + f'<a href="/test_admin/admin/{app_label}/{model_name}/add/" ' + f'class="addlink" aria-describedby="{row_id}">Add</a>', + ) + @override_settings( AUTH_PASSWORD_VALIDATORS=[ |
