Skip to content

Commit 72e69d9

Browse files
committed
Add tests for follow-up journey
Verifies both parent side and nurse side MAV-3378 and MAV-526
1 parent a74edef commit 72e69d9

File tree

8 files changed

+684
-1
lines changed

8 files changed

+684
-1
lines changed

mavis/test/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ def requires_details(self) -> bool:
430430
ConsentRefusalReason.CONTAINS_GELATINE,
431431
)
432432

433+
@property
434+
def has_follow_up_option(self) -> bool:
435+
return self not in (
436+
ConsentRefusalReason.VACCINE_ALREADY_RECEIVED,
437+
ConsentRefusalReason.VACCINE_WILL_BE_GIVEN_ELSEWHERE,
438+
)
439+
433440

434441
class ConsentMethod(StrEnum):
435442
PHONE = "By phone"

mavis/test/pages/online_consent_wizard_page.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Programme,
1111
)
1212
from mavis.test.data_models import Child, Parent, School
13+
from mavis.test.utils import expect_details
1314

1415

1516
class OnlineConsentWizardPage:
@@ -124,6 +125,12 @@ def __init__(self, page: Page) -> None:
124125
"radio",
125126
name="No",
126127
)
128+
self.change_discuss_options_link = self.page.get_by_role(
129+
"link", name="Change follow-up request"
130+
)
131+
self.change_reason_for_refusal_link = self.page.get_by_role(
132+
"link", name="Change reason for refusal"
133+
)
127134

128135
@step("Click Continue")
129136
def click_continue(self) -> None:
@@ -337,6 +344,44 @@ def expect_confirmation_text(self, text: str) -> None:
337344
confirmation = self.page.locator(".nhsuk-panel.nhsuk-panel--confirmation")
338345
expect(confirmation).to_contain_text(text)
339346

347+
@step("Verify check and confirm refusal details")
348+
def verify_check_and_confirm_refusal_details(
349+
self, refusal_reason: ConsentRefusalReason, *, follow_up_requested: bool
350+
) -> None:
351+
expect_details(self.page, "Reason", str(refusal_reason))
352+
expected_discuss_value = "Yes" if follow_up_requested else "No"
353+
expect_details(self.page, "Discuss options", expected_discuss_value)
354+
355+
@step("Verify follow-up hint text")
356+
def verify_follow_up_hint_text(self, refusal_reason: ConsentRefusalReason) -> None:
357+
hint_text_medical = (
358+
"We understand alternatives might not be suitable in some cases."
359+
)
360+
hint_text_gelatine = (
361+
"For example, it may be possible to use a vaccine that "
362+
"does not contain gelatine"
363+
)
364+
365+
if refusal_reason == ConsentRefusalReason.MEDICAL_REASONS:
366+
expect(self.page.get_by_text(hint_text_medical)).to_be_visible()
367+
elif refusal_reason == ConsentRefusalReason.CONTAINS_GELATINE:
368+
expect(self.page.get_by_text(hint_text_gelatine)).to_be_visible()
369+
else:
370+
expect(self.page.get_by_text(hint_text_medical)).not_to_be_visible()
371+
expect(self.page.get_by_text(hint_text_gelatine)).not_to_be_visible()
372+
373+
@step("Click Change link for discuss options")
374+
def click_change_discuss_options(self) -> None:
375+
self.change_discuss_options_link.click()
376+
377+
@step("Click Change link for refusal reason")
378+
def click_change_refusal_reason(self) -> None:
379+
self.change_reason_for_refusal_link.click()
380+
381+
@step("Verify Discuss options is not shown")
382+
def verify_discuss_options_not_shown(self) -> None:
383+
expect(self.page.get_by_text("Discuss options")).not_to_be_visible()
384+
340385
def go_to_url(self, url: str) -> None:
341386
self.page.goto(url)
342387

@@ -358,6 +403,46 @@ def fill_details(
358403

359404
self.fill_parent_details(parent)
360405

406+
@step("Submit refused consent, follow-up requested: {follow_up_requested}")
407+
def submit_refusal(
408+
self,
409+
reason: ConsentRefusalReason = ConsentRefusalReason.PERSONAL_CHOICE,
410+
*,
411+
follow_up_requested: bool = False,
412+
details: str | None = None,
413+
) -> None:
414+
self.dont_agree_to_vaccination()
415+
self.select_consent_not_given_reason(reason, details)
416+
if reason.has_follow_up_option:
417+
self.answer_follow_up_question(yes_to_follow_up_request=follow_up_requested)
418+
self.click_confirm()
419+
420+
@step("Submit given consent")
421+
def submit_positive_consent(
422+
self,
423+
child: Child,
424+
programme: Programme,
425+
consent_option: ConsentOption,
426+
*,
427+
yes_to_health_questions: bool = False,
428+
) -> None:
429+
if programme is Programme.MMR:
430+
self.agree_to_mmr_vaccination(consent_option)
431+
elif programme is Programme.HPV:
432+
self.agree_to_hpv_vaccination()
433+
elif programme is Programme.FLU:
434+
self.agree_to_flu_vaccination(consent_option)
435+
elif programme in (Programme.MENACWY, Programme.TD_IPV):
436+
programmes = [programme]
437+
self.agree_to_doubles_vaccinations(*programmes)
438+
439+
self.fill_address_details(*child.address)
440+
number_of_questions = len(programme.health_questions(consent_option))
441+
self.answer_health_questions(
442+
number_of_questions, yes_to_health_questions=yes_to_health_questions
443+
)
444+
self.click_confirm()
445+
361446
def answer_health_questions(
362447
self, number_of_questions: int, *, yes_to_health_questions: bool
363448
) -> None:

mavis/test/pages/search_components/patient_status_search_component.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def __init__(
3232
"checkbox",
3333
name="Conflicting consent",
3434
)
35+
self.follow_up_requested_checkbox = self.page.get_by_role(
36+
"checkbox",
37+
name="Follow-up requested",
38+
)
3539

3640
@step("Select Needs consent")
3741
def select_needs_consent(self) -> None:
@@ -53,6 +57,10 @@ def select_due_vaccination(self) -> None:
5357
def select_conflicting_consent(self) -> None:
5458
self.conflicting_consent_checkbox.check()
5559

60+
@step("Select Follow-up requested")
61+
def select_follow_up_requested(self) -> None:
62+
self.follow_up_requested_checkbox.check()
63+
5664
@step("Expect Has a refusal to be selected")
5765
def expect_has_a_refusal_to_be_selected(self) -> None:
5866
expect(self.has_a_refusal_radio).to_be_checked()

mavis/test/pages/sessions/sessions_children_page.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def register_child_as_attending(self, child: Child) -> None:
3333
def click_on_attending(self) -> None:
3434
self.attending_button.click()
3535

36+
@step("Click on child to view patient session page")
37+
def click_child(self, child: Child) -> None:
38+
self.page.get_by_role("link", name=str(child)).last.click()
39+
3640
def verify_child_shows_correct_flu_consent_method(
3741
self,
3842
child: Child,
@@ -60,3 +64,22 @@ def check_note_appears_in_search(self, child: Child, note: str) -> None:
6064
heading = self.page.get_by_role("heading", name=str(child))
6165
next_element = heading.locator("xpath=following-sibling::*[1]")
6266
expect(next_element.get_by_role("blockquote")).to_have_text(note)
67+
68+
@step("Verify child programme status is {2} {3}")
69+
def expect_child_programme_status(
70+
self,
71+
child: Child,
72+
programme: str,
73+
status: str,
74+
additional_text: str | None = None,
75+
) -> None:
76+
child_locator = self.search.get_patient_card_locator(child)
77+
programme_status_section = child_locator.locator(f"p:has-text('{programme}')")
78+
reload_until_element_is_visible(self.page, programme_status_section)
79+
80+
expect(programme_status_section).to_contain_text(status)
81+
if additional_text:
82+
additional_text_locator = programme_status_section.get_by_text(
83+
additional_text
84+
)
85+
reload_until_element_is_visible(self.page, additional_text_locator)

mavis/test/pages/sessions/sessions_patient_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ def expect_conflicting_consent_text(self) -> None:
258258
def expect_consent_status(self, programme: Programme, status: str) -> None:
259259
expect(self.page.get_by_text(f"{programme}: {status}")).to_be_visible()
260260

261+
def expect_consent_recorded_success(self) -> None:
262+
expect_alert_text(self.page, "Consent recorded")
263+
261264
def expect_child_safe_to_vaccinate(self, child: Child) -> None:
262265
expect(
263266
self.page.get_by_text(

mavis/test/pages/sessions/sessions_patient_session_activity_page.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from playwright.sync_api import Page, expect
22

33
from mavis.test.annotations import step
4+
from mavis.test.data_models import Location
45
from mavis.test.pages.header_component import HeaderComponent
56
from mavis.test.utils import (
67
expect_alert_text,
@@ -45,3 +46,7 @@ def add_note(self, note: str) -> None:
4546

4647
def check_session_activity_entry(self, text: str) -> None:
4748
expect(self.page.get_by_role("heading", name=text).first).to_be_visible()
49+
50+
@step("Go back to Session")
51+
def click_back_to_session(self, location: Location) -> None:
52+
self.page.get_by_role("link", name=location.name).click()

mavis/test/pages/unmatched_responses/consent_response_page.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from playwright.sync_api import Page
1+
from playwright.sync_api import Page, expect
22

33
from mavis.test.annotations import step
44
from mavis.test.pages.header_component import HeaderComponent
@@ -16,6 +16,7 @@ def __init__(self, page: Page) -> None:
1616
exact=True,
1717
)
1818
self.match_link = page.get_by_role("link", name="Match", exact=True)
19+
self.follow_up_link = page.get_by_role("link", name="Follow up", exact=True)
1920

2021
@step("Click on Archive")
2122
def click_archive(self) -> None:
@@ -28,3 +29,14 @@ def click_create_new_record(self) -> None:
2829
@step("Click on Match")
2930
def click_match(self) -> None:
3031
self.match_link.click()
32+
33+
@step("Click on Follow up")
34+
def click_follow_up(self) -> None:
35+
self.follow_up_link.click()
36+
37+
def expect_follow_up_available(self) -> None:
38+
expect(self.follow_up_link).to_be_visible()
39+
40+
@step("Verify Follow up link is not available")
41+
def expect_follow_up_not_available(self) -> None:
42+
expect(self.follow_up_link).not_to_be_visible()

0 commit comments

Comments
 (0)