Skip to content

Commit cc311d7

Browse files
authored
Merge pull request #242 from NHSDigital/DTOSS-9936-include-name-in-checkin-links
[DTOSS-9936] (accessibility) include name in checkin links
2 parents 360f185 + c74bc3c commit cc311d7

3 files changed

Lines changed: 56 additions & 7 deletions

File tree

manage_breast_screening/clinics/tests/system/test_user_views_clinic_show_page.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def test_user_views_clinic_show_page_with_special_appointments(self):
4848
self.when_i_click_on_the_special_appointment()
4949
self.then_i_can_see_the_special_appointment_banner()
5050

51+
def test_accessibility(self):
52+
self.given_there_are_appointments()
53+
self.and_i_am_on_the_clinic_show_page()
54+
self.then_the_accessibility_baseline_is_met()
55+
5156
def given_there_are_appointments(self):
5257
self.confirmed_appointment = AppointmentFactory(
5358
clinic_slot__clinic=self.clinic,
@@ -56,6 +61,13 @@ def given_there_are_appointments(self):
5661
screening_episode__participant__first_name="Janet",
5762
screening_episode__participant__last_name="Confirmed",
5863
)
64+
self.another_confirmed_appointment = AppointmentFactory(
65+
clinic_slot__clinic=self.clinic,
66+
clinic_slot__starts_at=datetime.now(timezone.utc).replace(hour=9, minute=0),
67+
screening_episode__participant__first_name="Also",
68+
screening_episode__participant__last_name="Confirmed",
69+
current_status=AppointmentStatus.CONFIRMED,
70+
)
5971
self.checked_in_appointment = AppointmentFactory(
6072
clinic_slot__clinic=self.clinic,
6173
clinic_slot__starts_at=datetime.now(timezone.utc).replace(
@@ -74,6 +86,12 @@ def given_there_are_appointments(self):
7486
def given_i_am_on_the_clinic_list(self):
7587
self.page.goto(self.live_server_url + reverse("clinics:index"))
7688

89+
def and_i_am_on_the_clinic_show_page(self):
90+
self.page.goto(
91+
self.live_server_url
92+
+ reverse("clinics:show", kwargs={"pk": self.clinic.pk})
93+
)
94+
7795
def when_i_click_on_the_clinic(self):
7896
self.page.get_by_role("link", name="West London BSS").click()
7997

@@ -86,10 +104,15 @@ def then_i_should_see_the_clinic_show_page(self):
86104
def and_i_can_see_remaining_appointments(self):
87105
remaining_link = self.page.get_by_role("link", name=re.compile("Remaining"))
88106
count_span = remaining_link.locator(".app-count")
89-
expect(count_span).to_contain_text("2")
107+
expect(count_span).to_contain_text("3")
90108
rows = self.page.locator("table.nhsuk-table tbody tr").all()
91109
self._expect_rows_to_match_appointments(
92-
rows, [self.confirmed_appointment, self.checked_in_appointment]
110+
rows,
111+
[
112+
self.confirmed_appointment,
113+
self.another_confirmed_appointment,
114+
self.checked_in_appointment,
115+
],
93116
)
94117

95118
def when_i_click_on_checked_in(self):
@@ -118,19 +141,22 @@ def when_i_click_on_all(self):
118141
def then_i_can_see_all_appointments(self):
119142
all_link = self.page.get_by_role("link", name=re.compile("All"))
120143
count_span = all_link.locator(".app-count")
121-
expect(count_span).to_contain_text("3")
144+
expect(count_span).to_contain_text("4")
122145
rows = self.page.locator("table.nhsuk-table tbody tr").all()
123146
self._expect_rows_to_match_appointments(
124147
rows,
125148
[
126149
self.confirmed_appointment,
150+
self.another_confirmed_appointment,
127151
self.checked_in_appointment,
128152
self.screened_appointment,
129153
],
130154
)
131155

132156
def when_i_check_in_an_appointment(self):
133-
self.page.get_by_role("button", name=re.compile("Check in")).click()
157+
self.page.get_by_role(
158+
"button", name=re.compile("Check in Janet Confirmed")
159+
).click()
134160

135161
def then_the_appointment_is_checked_in(self):
136162
row = self.page.locator("tr").filter(has_text="Janet Confirmed")
@@ -141,6 +167,7 @@ def and_the_appointments_remain_in_the_same_order(self):
141167
rows = self.page.locator("table.nhsuk-table tbody tr").all()
142168
expected_times = [
143169
format_time(self.confirmed_appointment.clinic_slot.starts_at),
170+
format_time(self.another_confirmed_appointment.clinic_slot.starts_at),
144171
format_time(self.checked_in_appointment.clinic_slot.starts_at),
145172
format_time(self.screened_appointment.clinic_slot.starts_at),
146173
]

manage_breast_screening/core/jinja2/components/appointment-status/template.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{% set action_url = check_in_url or url('mammograms:check_in', kwargs={'pk': appointment.pk}) %}
1414
<form action="{{ action_url }}" method="post" novalidate>
1515
<p class="nhsuk-u-margin-top-2 nhsuk-u-margin-bottom-0">
16-
<button class="app-button--link">Check in</button>
16+
<button class="app-button--link">Check in<span class="nhsuk-u-visually-hidden"> {{ appointment.participant.full_name }}</span></button>
1717
</p>
1818
{{ csrf_input }}
1919
</form>

manage_breast_screening/core/system_test_setup.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from collections import Counter
23

34
import pytest
45
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
@@ -56,9 +57,30 @@ def expect_validation_error(
5657

5758
expect(field).to_be_focused()
5859

59-
def then_the_accessibility_baseline_is_met(self):
60+
def then_the_accessibility_baseline_is_met(self, require_unique_link_text=True):
6061
"""
61-
Check there are no Axe violations
62+
Check for certain accessibility issues that can be detected automatically without
63+
context of the page under test.
64+
65+
If require_unique_link_text is True (the default), then fail if there are
66+
any links on the page with identical link text (or any buttons styled to
67+
look like links). This depends on context, but generally we should be disambiguating
68+
any interactive elements that appear close together, and avoiding any non-specific
69+
links like "click here".
6270
"""
6371
results = self.axe.run()
6472
self.assertEqual(results.violations_count, 0, results.generate_report())
73+
74+
if require_unique_link_text:
75+
links = self.page.get_by_role("link").or_(
76+
self.page.locator("css=.app-button--link")
77+
)
78+
79+
counter = Counter(link.text_content().strip() for link in links.all())
80+
81+
# Known bug: There is an extra "home" link that is shown at mobile screen widths. This will be fixed in NHS.UK frontend 10.0.0
82+
counter["Home"] -= 1
83+
84+
duplicates = {k: v for k, v in counter.items() if v > 1}
85+
86+
self.assertEqual(len(duplicates), 0, duplicates)

0 commit comments

Comments
 (0)