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

@@ -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)