Skip to content

Commit 9b72dc3

Browse files
committed
Update patient session page tests for new designs
Adds ConsentStatus enum to standardise consent status values across tests Updates expect_consent_status method in SessionsPatientPage to map status values to actual UI text displayed in new patient session designs (e.g. "Consent given" → "is ready for the vaccinator") Also updates page object locators for new designs
1 parent d8891f8 commit 9b72dc3

4 files changed

Lines changed: 48 additions & 27 deletions

File tree

mavis/test/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ class ConsentMethod(StrEnum):
448448
IN_PERSON = "In person"
449449

450450

451+
class ConsentStatus(StrEnum):
452+
GIVEN = "Consent given"
453+
REFUSED = "Consent refused"
454+
FOLLOW_UP_REQUESTED = "Follow-up requested"
455+
CONFLICTS = "Conflicting consent"
456+
NO_CONTACT_DETAILS = "No contact details"
457+
REQUEST_SCHEDULED = "Request scheduled"
458+
REQUEST_NOT_SCHEDULED = "Request not scheduled"
459+
NO_RESPONSE = "No response"
460+
NOT_REQUIRED = "Not required"
461+
462+
451463
class ReportFormat(StrEnum):
452464
CAREPLUS = "CSV for CarePlus (System C)"
453465
CSV = "CSV"

mavis/test/pages/sessions/sessions_patient_page.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from mavis.test.constants import (
77
MAVIS_NOTE_LENGTH_LIMIT,
88
ConsentOption,
9+
ConsentStatus,
910
DeliverySite,
1011
Programme,
1112
)
@@ -44,7 +45,7 @@ def __init__(self, page: Page) -> None:
4445
)
4546
self.edit_gillick_competence_link = self.page.get_by_role(
4647
"link",
47-
name="Edit Gillick competence",
48+
name="Update Gillick competence",
4849
)
4950
self.could_not_vaccinate_link = self.page.get_by_role(
5051
"link",
@@ -60,7 +61,7 @@ def __init__(self, page: Page) -> None:
6061
)
6162
self.notes_textbox = self.page.get_by_role("textbox", name="Notes")
6263
self.record_a_new_consent_response_button = self.page.get_by_role(
63-
"button",
64+
"link",
6465
name="Record a new consent response",
6566
)
6667
self.ready_for_injection_radio = self.page.locator(
@@ -250,8 +251,22 @@ def expect_conflicting_consent_text(self) -> None:
250251
),
251252
).to_be_visible()
252253

253-
def expect_consent_status(self, programme: Programme, status: str) -> None:
254-
expect(self.page.get_by_text(f"{programme}: {status}")).to_be_visible()
254+
def expect_consent_status(
255+
self, status: ConsentStatus
256+
) -> None:
257+
if status is ConsentStatus.GIVEN:
258+
expected_text = "is ready for the vaccinator"
259+
elif status is ConsentStatus.REFUSED:
260+
expected_text = "refused to give consent"
261+
elif status is ConsentStatus.FOLLOW_UP_REQUESTED:
262+
expected_text = "would like to speak to a member of the team"
263+
elif status is ConsentStatus.NO_RESPONSE:
264+
expected_text = "No-one responded to our requests"
265+
elif status is ConsentStatus.CONFLICTS:
266+
expected_text = "You can only vaccinate if all respondents give consent"
267+
else:
268+
expected_text = str(status)
269+
expect(self.page.get_by_text(expected_text, exact=False)).to_be_visible()
255270

256271
def expect_consent_recorded_success(self) -> None:
257272
expect_alert_text(self.page, "Consent recorded")

tests/test_follow_up_requests.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from mavis.test.constants import (
44
ConsentOption,
55
ConsentRefusalReason,
6+
ConsentStatus,
67
Programme,
78
Vaccine,
89
)
@@ -182,8 +183,8 @@ def test_consent_refusal_with_follow_up_request(
182183

183184
SessionsChildrenPage(page).click_child(child)
184185

185-
status = "Follow-up requested" if follow_up_requested else "Consent refused"
186-
SessionsPatientPage(page).expect_consent_status(Programme.MMR_MMRV, status)
186+
status = ConsentStatus.FOLLOW_UP_REQUESTED if follow_up_requested else ConsentStatus.REFUSED
187+
SessionsPatientPage(page).expect_consent_status(status)
187188

188189
SessionsPatientPage(page).click_session_activity_and_notes()
189190

@@ -290,9 +291,7 @@ def test_follow_up_journey_decision_stands_confirm_refusal(
290291
SessionsChildrenPage(page).tabs.click_children_tab()
291292
SessionsChildrenPage(page).click_child(child)
292293

293-
SessionsPatientPage(page).expect_consent_status(
294-
Programme.MMR_MMRV, "Follow-up requested"
295-
)
294+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.FOLLOW_UP_REQUESTED)
296295

297296
SessionsPatientPage(page).click_response_from_parent(parent)
298297
ConsentResponseDetailsPage(page).expect_follow_up_available()
@@ -306,9 +305,7 @@ def test_follow_up_journey_decision_stands_confirm_refusal(
306305
ConsentConfirmRefusalPage(page).expect_refusal_confirmation_success()
307306

308307
SessionsPatientPage(page).click_back()
309-
SessionsPatientPage(page).expect_consent_status(
310-
Programme.MMR_MMRV, "Consent refused"
311-
)
308+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.REFUSED)
312309

313310
SessionsPatientPage(page).click_session_activity_and_notes()
314311

@@ -377,7 +374,7 @@ def test_follow_up_journey_decision_changed_record_consent(
377374
SessionsPatientPage(page).expect_consent_recorded_success()
378375

379376
SessionsChildrenPage(page).click_child(child)
380-
SessionsPatientPage(page).expect_consent_status("MMR", "Consent given")
377+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.GIVEN)
381378

382379
SessionsPatientPage(page).verify_original_response_invalidated(
383380
parent, "Consent given in follow-up discussion."
@@ -434,9 +431,7 @@ def test_gillick_self_consent_overrides_follow_up_requested(
434431
SessionsChildrenPage(page).search.click_on_update_results()
435432
SessionsChildrenPage(page).click_child(child)
436433

437-
SessionsPatientPage(page).expect_consent_status(
438-
Programme.MMR_MMRV, "Follow-up requested"
439-
)
434+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.FOLLOW_UP_REQUESTED)
440435

441436
SessionsPatientPage(page).click_assess_gillick_competence()
442437
GillickCompetencePage(page).add_gillick_competence(is_competent=True)
@@ -452,15 +447,15 @@ def test_gillick_self_consent_overrides_follow_up_requested(
452447

453448
SessionsChildrenPage(page).search.select_due_vaccination()
454449
SessionsChildrenPage(page).search.search_and_click_child(child)
455-
SessionsPatientPage(page).expect_consent_status("MMR", "Consent given")
450+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.GIVEN)
456451

457452

458453
@pytest.mark.parametrize(
459454
("parent2_action", "expected_status"),
460455
[
461-
("given", "Follow-up requested"),
462-
("refused", "Conflicting consent"),
463-
("follow_up", "Follow-up requested"),
456+
("given", ConsentStatus.FOLLOW_UP_REQUESTED),
457+
("refused", ConsentStatus.CONFLICTS),
458+
("follow_up", ConsentStatus.FOLLOW_UP_REQUESTED),
464459
],
465460
ids=[
466461
"parent_1_follow_up_parent_2_given",
@@ -522,14 +517,14 @@ def test_multiple_parents_with_follow_up_request(
522517
)
523518
SessionsChildrenPage(page).tabs.click_children_tab()
524519

525-
if expected_status == "Conflicting consent":
520+
if expected_status == ConsentStatus.CONFLICTS:
526521
SessionsChildrenPage(page).search.select_has_a_refusal()
527522
SessionsChildrenPage(page).search.select_conflicting_consent()
528523
else:
529524
SessionsChildrenPage(page).search.select_needs_consent()
530525

531526
SessionsChildrenPage(page).search.search_and_click_child(child)
532-
SessionsPatientPage(page).expect_consent_status(Programme.MMR_MMRV, expected_status)
527+
SessionsPatientPage(page).expect_consent_status(expected_status)
533528

534529
if parent2_action != "follow_up":
535530
SessionsPatientPage(page).click_response_from_parent(child.parents[1])

tests/test_nurse_consent.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
MAVIS_NOTE_LENGTH_LIMIT,
66
ConsentMethod,
77
ConsentRefusalReason,
8+
ConsentStatus,
89
DeliverySite,
910
Programme,
1011
Vaccine,
@@ -312,9 +313,7 @@ def test_conflicting_consent_with_gillick_consent(
312313

313314
SessionsChildrenPage(page).search.search_and_click_child(child)
314315
SessionsPatientPage(page).click_programme_tab(Programme.HPV)
315-
SessionsPatientPage(page).expect_consent_status(
316-
Programme.HPV, "Conflicting consent"
317-
)
316+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.CONFLICTS)
318317
SessionsPatientPage(page).expect_conflicting_consent_text()
319318
SessionsPatientPage(page).click_assess_gillick_competence()
320319
GillickCompetencePage(page).add_gillick_competence(is_competent=True)
@@ -327,7 +326,7 @@ def test_conflicting_consent_with_gillick_consent(
327326
SessionsChildrenPage(page).search.select_due_vaccination()
328327
SessionsChildrenPage(page).search.search_and_click_child(child)
329328
SessionsPatientPage(page).click_programme_tab(Programme.HPV)
330-
SessionsPatientPage(page).expect_consent_status(Programme.HPV, "Consent given")
329+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.GIVEN)
331330
SessionsPatientPage(page).click_session_activity_and_notes()
332331
SessionsPatientSessionActivityPage(page).check_session_activity_entry(
333332
f"Consent given by {child!s} (Child (Gillick competent))",
@@ -371,7 +370,7 @@ def test_consent_refusal_do_not_want_vaccination_at_school(
371370
SessionsChildrenPage(page).search.select_consent_refused()
372371
SessionsChildrenPage(page).search.search_and_click_child(child)
373372
SessionsPatientPage(page).click_programme_tab(Programme.HPV)
374-
SessionsPatientPage(page).expect_consent_status(Programme.HPV, "Consent refused")
373+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.REFUSED)
375374

376375

377376
@pytest.mark.accessibility

0 commit comments

Comments
 (0)