Skip to content

Commit 215dce3

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 8064c67 commit 215dce3

3 files changed

Lines changed: 45 additions & 21 deletions

File tree

mavis/test/constants.py

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

460460

461+
class ConsentStatus(StrEnum):
462+
GIVEN = "Consent given"
463+
REFUSED = "Consent refused"
464+
FOLLOW_UP_REQUESTED = "Follow-up requested"
465+
CONFLICTS = "Conflicting consent"
466+
NO_CONTACT_DETAILS = "No contact details"
467+
REQUEST_SCHEDULED = "Request scheduled"
468+
REQUEST_NOT_SCHEDULED = "Request not scheduled"
469+
NO_RESPONSE = "No response"
470+
NOT_REQUIRED = "Not required"
471+
472+
461473
class ReportFormat(StrEnum):
462474
CAREPLUS = "CSV for CarePlus (System C)"
463475
CSV = "CSV"

mavis/test/pages/sessions/sessions_patient_page.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from mavis.test.constants import (
55
MAVIS_NOTE_LENGTH_LIMIT,
66
ConsentOption,
7+
ConsentStatus,
78
DeliverySite,
89
Programme,
910
)
@@ -53,7 +54,7 @@ def __init__(self, page: Page) -> None:
5354
)
5455
self.notes_textbox = self.page.get_by_role("textbox", name="Notes")
5556
self.record_a_new_consent_response_button = self.page.get_by_role(
56-
"button",
57+
"link",
5758
name="Record a new consent response",
5859
)
5960
self.ready_for_injection_radio = self.page.locator(
@@ -239,8 +240,20 @@ def expect_conflicting_consent_text(self) -> None:
239240
),
240241
).to_be_visible()
241242

242-
def expect_consent_status(self, programme: Programme, status: str) -> None:
243-
expect(self.page.get_by_text(f"{programme}: {status}")).to_be_visible()
243+
def expect_consent_status(self, status: ConsentStatus) -> None:
244+
if status is ConsentStatus.GIVEN:
245+
expected_text = "is ready for the vaccinator"
246+
elif status is ConsentStatus.REFUSED:
247+
expected_text = "refused to give consent"
248+
elif status is ConsentStatus.FOLLOW_UP_REQUESTED:
249+
expected_text = "would like to speak to a member of the team"
250+
elif status is ConsentStatus.NO_RESPONSE:
251+
expected_text = "No-one responded to our requests"
252+
elif status is ConsentStatus.CONFLICTS:
253+
expected_text = "You can only vaccinate if all respondents give consent"
254+
else:
255+
expected_text = str(status)
256+
expect(self.page.get_by_text(expected_text, exact=False)).to_be_visible()
244257

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

tests/test_follow_up_requests.py

Lines changed: 17 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,12 @@ 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 = (
187+
ConsentStatus.FOLLOW_UP_REQUESTED
188+
if follow_up_requested
189+
else ConsentStatus.REFUSED
190+
)
191+
SessionsPatientPage(page).expect_consent_status(status)
187192

188193
SessionsPatientPage(page).click_session_activity_and_notes()
189194

@@ -290,9 +295,7 @@ def test_follow_up_journey_decision_stands_confirm_refusal(
290295
SessionsChildrenPage(page).tabs.click_children_tab()
291296
SessionsChildrenPage(page).click_child(child)
292297

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

297300
SessionsPatientPage(page).click_response_from_parent(parent)
298301
ConsentResponseDetailsPage(page).expect_follow_up_available()
@@ -306,9 +309,7 @@ def test_follow_up_journey_decision_stands_confirm_refusal(
306309
ConsentConfirmRefusalPage(page).expect_refusal_confirmation_success()
307310

308311
SessionsPatientPage(page).click_back()
309-
SessionsPatientPage(page).expect_consent_status(
310-
Programme.MMR_MMRV, "Consent refused"
311-
)
312+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.REFUSED)
312313

313314
SessionsPatientPage(page).click_session_activity_and_notes()
314315

@@ -377,7 +378,7 @@ def test_follow_up_journey_decision_changed_record_consent(
377378
SessionsPatientPage(page).expect_consent_recorded_success()
378379

379380
SessionsChildrenPage(page).click_child(child)
380-
SessionsPatientPage(page).expect_consent_status("MMR", "Consent given")
381+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.GIVEN)
381382

382383
SessionsPatientPage(page).verify_original_response_invalidated(
383384
parent, "Consent given in follow-up discussion."
@@ -434,9 +435,7 @@ def test_gillick_self_consent_overrides_follow_up_requested(
434435
SessionsChildrenPage(page).search.click_on_update_results()
435436
SessionsChildrenPage(page).click_child(child)
436437

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

441440
SessionsPatientPage(page).click_assess_gillick_competence()
442441
GillickCompetencePage(page).add_gillick_competence(is_competent=True)
@@ -452,15 +451,15 @@ def test_gillick_self_consent_overrides_follow_up_requested(
452451

453452
SessionsChildrenPage(page).search.select_due_vaccination()
454453
SessionsChildrenPage(page).search.search_and_click_child(child)
455-
SessionsPatientPage(page).expect_consent_status("MMR", "Consent given")
454+
SessionsPatientPage(page).expect_consent_status(ConsentStatus.GIVEN)
456455

457456

458457
@pytest.mark.parametrize(
459458
("parent2_action", "expected_status"),
460459
[
461-
("given", "Follow-up requested"),
462-
("refused", "Conflicting consent"),
463-
("follow_up", "Follow-up requested"),
460+
("given", ConsentStatus.FOLLOW_UP_REQUESTED),
461+
("refused", ConsentStatus.CONFLICTS),
462+
("follow_up", ConsentStatus.FOLLOW_UP_REQUESTED),
464463
],
465464
ids=[
466465
"parent_1_follow_up_parent_2_given",
@@ -522,14 +521,14 @@ def test_multiple_parents_with_follow_up_request(
522521
)
523522
SessionsChildrenPage(page).tabs.click_children_tab()
524523

525-
if expected_status == "Conflicting consent":
524+
if expected_status == ConsentStatus.CONFLICTS:
526525
SessionsChildrenPage(page).search.select_has_a_refusal()
527526
SessionsChildrenPage(page).search.select_conflicting_consent()
528527
else:
529528
SessionsChildrenPage(page).search.select_needs_consent()
530529

531530
SessionsChildrenPage(page).search.search_and_click_child(child)
532-
SessionsPatientPage(page).expect_consent_status(Programme.MMR_MMRV, expected_status)
531+
SessionsPatientPage(page).expect_consent_status(expected_status)
533532

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

0 commit comments

Comments
 (0)