Skip to content

Commit 3a79b46

Browse files
committed
Add tests for follow-up journey
Verifies both parent side and nurse side MAV-3378 and MAV-526
1 parent 76ff8a3 commit 3a79b46

File tree

9 files changed

+673
-5
lines changed

9 files changed

+673
-5
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: 80 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,41 @@ 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 = "For example, it may be possible to use a vaccine that does not contain gelatine"
361+
362+
if refusal_reason == ConsentRefusalReason.MEDICAL_REASONS:
363+
expect(self.page.get_by_text(hint_text_medical)).to_be_visible()
364+
elif refusal_reason == ConsentRefusalReason.CONTAINS_GELATINE:
365+
expect(self.page.get_by_text(hint_text_gelatine)).to_be_visible()
366+
else:
367+
expect(self.page.get_by_text(hint_text_medical)).not_to_be_visible()
368+
expect(self.page.get_by_text(hint_text_gelatine)).not_to_be_visible()
369+
370+
@step("Click Change link for discuss options")
371+
def click_change_discuss_options(self) -> None:
372+
self.change_discuss_options_link.click()
373+
374+
@step("Click Change link for refusal reason")
375+
def click_change_refusal_reason(self) -> None:
376+
self.change_reason_for_refusal_link.click()
377+
378+
@step("Verify Discuss options is not shown")
379+
def verify_discuss_options_not_shown(self) -> None:
380+
expect(self.page.get_by_text("Discuss options")).not_to_be_visible()
381+
340382
def go_to_url(self, url: str) -> None:
341383
self.page.goto(url)
342384

@@ -358,6 +400,44 @@ def fill_details(
358400

359401
self.fill_parent_details(parent)
360402

403+
@step("Submit refused consent, follow-up requested: {follow_up_requested}")
404+
def submit_refusal(
405+
self,
406+
reason: ConsentRefusalReason = ConsentRefusalReason.PERSONAL_CHOICE,
407+
follow_up_requested: bool = False,
408+
details: str | None = None,
409+
) -> None:
410+
self.dont_agree_to_vaccination()
411+
self.select_consent_not_given_reason(reason, details)
412+
if reason.has_follow_up_option:
413+
self.answer_follow_up_question(follow_up_requested)
414+
self.click_confirm()
415+
416+
@step("Submit given consent")
417+
def submit_positive_consent(
418+
self,
419+
child: Child,
420+
programme: Programme,
421+
consent_option: ConsentOption,
422+
yes_to_health_questions: bool = False,
423+
) -> None:
424+
if programme is Programme.MMR:
425+
self.agree_to_mmr_vaccination(consent_option)
426+
elif programme is Programme.HPV:
427+
self.agree_to_hpv_vaccination()
428+
elif programme is Programme.FLU:
429+
self.agree_to_flu_vaccination(consent_option)
430+
elif programme in (Programme.MENACWY, Programme.TD_IPV):
431+
programmes = [programme]
432+
self.agree_to_doubles_vaccinations(*programmes)
433+
434+
self.fill_address_details(*child.address)
435+
number_of_questions = len(programme.health_questions(consent_option))
436+
self.answer_health_questions(
437+
number_of_questions, yes_to_health_questions=yes_to_health_questions
438+
)
439+
self.click_confirm()
440+
361441
def answer_health_questions(
362442
self, number_of_questions: int, *, yes_to_health_questions: bool
363443
) -> 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,3 +1,4 @@
1+
from mavis.test.data_models import Location
12
from playwright.sync_api import Page, expect
23

34
from mavis.test.annotations import step
@@ -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)