kopia lustrzana https://github.com/wagtail/wagtail
Add Python unit tests to ensure the skip link element is present
rodzic
1772909551
commit
3c628b8ad2
|
@ -32,7 +32,7 @@
|
|||
|
||||
{% block js %}{% endblock %}
|
||||
|
||||
<a class="skiplink button" href="#main" data-controller="w-skip-link" data-action="w-skip-link#skip">{% trans 'Skip to main content' %}</a>
|
||||
<a class="skiplink button" href="#main" data-controller="w-focus" data-action="w-focus#focus:prevent">{% trans 'Skip to main content' %}</a>
|
||||
|
||||
<div class="wrapper">
|
||||
{% block furniture %}{% endblock %}
|
||||
|
|
|
@ -31,6 +31,22 @@ class TestHome(WagtailTestUtils, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "Test Site")
|
||||
|
||||
def test_accessible_skip_link_exists(self):
|
||||
response = self.client.get(reverse("wagtailadmin_home"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
soup = self.get_soup(response.content)
|
||||
|
||||
# Check that the skip link is present and has the correct attributes
|
||||
skip_link = soup.select_one(".skiplink")
|
||||
self.assertIsNotNone(skip_link)
|
||||
self.assertEqual(skip_link["href"], "#main")
|
||||
self.assertEqual(skip_link["data-controller"], "w-focus")
|
||||
self.assertEqual(skip_link["data-action"], "w-focus#focus:prevent")
|
||||
|
||||
# Check that the main content area has the correct ID
|
||||
main_content = soup.select_one("#main")
|
||||
self.assertIsNotNone(main_content)
|
||||
|
||||
def test_admin_menu(self):
|
||||
response = self.client.get(reverse("wagtailadmin_home"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
Ładowanie…
Reference in New Issue