summaryrefslogtreecommitdiff
path: root/tests/admin_views
diff options
context:
space:
mode:
authorantoliny0919 <antoliny0919@gmail.com>2025-05-08 19:24:07 +0900
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-06-27 18:03:16 +0200
commit3f59711581bd22ebd0f13fb040b15b69c0eee21f (patch)
tree7b3eea333004013bbfdd1d48b6eb4644cd164c8f /tests/admin_views
parent29f5e1e97d660855d34c1ee5edbd5cfe094b6ca7 (diff)
Fixed #36366 -- Improved accessibility of pagination in the admin.
Diffstat (limited to 'tests/admin_views')
-rw-r--r--tests/admin_views/test_history_view.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/admin_views/test_history_view.py b/tests/admin_views/test_history_view.py
index 7079c1d0d8..49a60aa306 100644
--- a/tests/admin_views/test_history_view.py
+++ b/tests/admin_views/test_history_view.py
@@ -80,20 +80,29 @@ class SeleniumTests(AdminSeleniumTestCase):
self.selenium.get(self.live_server_url + user_history_url)
paginator = self.selenium.find_element(By.CSS_SELECTOR, ".paginator")
+ self.assertEqual(paginator.tag_name, "nav")
+ labelledby = paginator.get_attribute("aria-labelledby")
+ description = self.selenium.find_element(By.CSS_SELECTOR, "#%s" % labelledby)
+ self.assertHTMLEqual(
+ description.get_attribute("outerHTML"),
+ '<h2 id="pagination" class="visually-hidden">Pagination user entries</h2>',
+ )
self.assertTrue(paginator.is_displayed())
+ aria_current_link = paginator.find_elements(By.CSS_SELECTOR, "[aria-current]")
+ self.assertEqual(len(aria_current_link), 1)
+ # The current page.
+ current_page_link = aria_current_link[0]
+ self.assertEqual(current_page_link.get_attribute("aria-current"), "page")
+ self.assertEqual(current_page_link.get_attribute("href"), "")
self.assertIn("%s entries" % LogEntry.objects.count(), paginator.text)
self.assertIn(str(Paginator.ELLIPSIS), paginator.text)
- # The current page.
- current_page_link = self.selenium.find_element(
- By.CSS_SELECTOR, "span.this-page"
- )
self.assertEqual(current_page_link.text, "1")
# The last page.
- last_page_link = self.selenium.find_element(By.CSS_SELECTOR, ".end")
+ last_page_link = self.selenium.find_element(By.XPATH, "//ul/li[last()]/a")
self.assertTrue(last_page_link.text, "20")
# Select the second page.
pages = paginator.find_elements(By.TAG_NAME, "a")
- second_page_link = pages[0]
+ second_page_link = pages[1]
self.assertEqual(second_page_link.text, "2")
second_page_link.click()
self.assertIn("?p=2", self.selenium.current_url)