Skip to content

Commit 09b739c

Browse files
authored
Merge pull request #895 from NHSDigital/add-mmrv-e2e-test
Add MMRV end-to-end test
2 parents d6a2320 + b3a4878 commit 09b739c

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

mavis/test/constants.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import urllib.parse
3+
from datetime import date
34
from enum import StrEnum
45

56
from faker import Faker
@@ -8,6 +9,8 @@
89

910
MAVIS_NOTE_LENGTH_LIMIT = 1000
1011

12+
MMRV_ELIGIBILITY_CUTOFF_DOB = date(2020, 1, 1)
13+
1114

1215
class ConsentOption(StrEnum):
1316
INJECTION = "Injection"
@@ -109,6 +112,10 @@ class HealthQuestion(StrEnum):
109112
"Has your child received a blood or plasma transfusion,"
110113
" or immunoglobulin in the last 3 months?"
111114
)
115+
MMRV_ALLERGIC_REACTION = (
116+
"Has your child had a severe allergic reaction (anaphylaxis) to a previous dose"
117+
" of MMRV or any other vaccine?"
118+
)
112119
MMR_ALLERGIC_REACTION = (
113120
"Has your child had a severe allergic reaction (anaphylaxis) to a previous dose"
114121
" of MMR or any other vaccine?"
@@ -158,6 +165,7 @@ def health_questions(
158165
consent_option: ConsentOption = ConsentOption.INJECTION,
159166
*,
160167
nurse_consent: bool = False,
168+
mmrv_eligibility: bool = False,
161169
) -> list[HealthQuestion]:
162170
includes_nasal = consent_option is not ConsentOption.INJECTION
163171
includes_injection = consent_option is not ConsentOption.NASAL_SPRAY
@@ -190,7 +198,9 @@ def health_questions(
190198
HealthQuestion.BLEEDING_DISORDER,
191199
HealthQuestion.MMR_ANTICOAGULANTS,
192200
HealthQuestion.MMR_TRANSFUSION,
193-
HealthQuestion.MMR_ALLERGIC_REACTION,
201+
HealthQuestion.MMRV_ALLERGIC_REACTION
202+
if mmrv_eligibility
203+
else HealthQuestion.MMR_ALLERGIC_REACTION,
194204
HealthQuestion.MMR_ALLERGIC_REACTION_NEOMYCIN,
195205
HealthQuestion.IMMUNE_SYSTEM,
196206
HealthQuestion.MMR_TB_TEST,
@@ -306,6 +316,10 @@ class Vaccine(StrEnum):
306316
MMR_VAXPRO = "MMR VaxPro"
307317
PRIORIX = "Priorix"
308318

319+
# MMRV
320+
PROQUAD = "ProQuad"
321+
PRIORIX_TETRA = "Priorix-Tetra"
322+
309323
# Td/IPV
310324
REVAXIS = "Revaxis"
311325

@@ -330,6 +344,8 @@ def programme(self) -> Programme:
330344
Vaccine.REVAXIS: Programme.TD_IPV,
331345
Vaccine.MMR_VAXPRO: Programme.MMR,
332346
Vaccine.PRIORIX: Programme.MMR,
347+
Vaccine.PROQUAD: Programme.MMR,
348+
Vaccine.PRIORIX_TETRA: Programme.MMR,
333349
}
334350
return programme_mapping[self]
335351

@@ -363,6 +379,8 @@ def offline_sheet_name(self) -> str:
363379
Vaccine.REVAXIS: Vaccine.REVAXIS,
364380
Vaccine.MMR_VAXPRO: Vaccine.MMR_VAXPRO,
365381
Vaccine.PRIORIX: Vaccine.PRIORIX,
382+
Vaccine.PROQUAD: Vaccine.PROQUAD,
383+
Vaccine.PRIORIX_TETRA: Vaccine.PRIORIX_TETRA,
366384
}
367385
return offline_sheet_map[self]
368386

mavis/test/pages/sessions/nurse_consent_wizard_page.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ def answer_all_health_questions(
111111
programme: Programme,
112112
consent_option: ConsentOption = ConsentOption.INJECTION,
113113
answer: str = "No",
114+
*,
115+
mmrv_eligibility: bool = False,
114116
) -> None:
115117
for locator_text in programme.health_questions(
116-
consent_option, nurse_consent=True
118+
consent_option, nurse_consent=True, mmrv_eligibility=mmrv_eligibility
117119
):
118120
self.select_answer_for_health_question(locator_text, answer)
119121

@@ -198,12 +200,14 @@ def record_parent_positive_consent(
198200
*,
199201
psd_option: bool | None = None,
200202
yes_to_health_questions: bool = False,
203+
mmrv_eligibility: bool = False,
201204
) -> None:
202205
self._process_consent_confirmation(
203206
programme=programme,
204207
consent_option=consent_option,
205208
psd_option=psd_option,
206209
yes_to_health_questions=yes_to_health_questions,
210+
mmrv_eligibility=mmrv_eligibility,
207211
)
208212

209213
def record_parent_no_response(self) -> None:
@@ -224,13 +228,15 @@ def record_child_positive_consent(
224228
*,
225229
psd_option: bool | None = None,
226230
yes_to_health_questions: bool = False,
231+
mmrv_eligibility: bool = False,
227232
) -> None:
228233
self._process_consent_confirmation(
229234
programme=programme,
230235
consent_option=consent_option,
231236
psd_option=psd_option,
232237
yes_to_health_questions=yes_to_health_questions,
233238
child_consent=True,
239+
mmrv_eligibility=mmrv_eligibility,
234240
)
235241

236242
def _handle_refusal_of_consent(self, reason: ConsentRefusalReason) -> None:
@@ -249,20 +255,18 @@ def select_consent_method(self, method: ConsentMethod) -> None:
249255
self.click_continue()
250256

251257
def select_mmrv_eligibility_for_child(self) -> None:
252-
# MMRV test is todo
253-
self.page.wait_for_load_state()
254-
if self.mmrv_question_text.is_visible():
255-
self.select_no()
256-
self.click_continue()
258+
self.select_yes()
259+
self.click_continue()
257260

258-
def _process_consent_confirmation(
261+
def _process_consent_confirmation( # noqa: PLR0913
259262
self,
260263
programme: Programme = Programme.HPV,
261264
consent_option: ConsentOption = ConsentOption.INJECTION,
262265
*,
263266
child_consent: bool = False,
264267
psd_option: bool | None = None,
265268
yes_to_health_questions: bool = False,
269+
mmrv_eligibility: bool = False,
266270
) -> None:
267271
self.agree_to_vaccination(programme, consent_option)
268272

@@ -272,7 +276,7 @@ def _process_consent_confirmation(
272276

273277
answer = "Yes" if yes_to_health_questions else "No"
274278
self.answer_all_health_questions(
275-
programme=programme, consent_option=consent_option, answer=answer
279+
programme, consent_option, answer, mmrv_eligibility=mmrv_eligibility
276280
)
277281

278282
self.click_continue()

mavis/test/pages/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def prepare_child_for_vaccination(
6969
def record_nurse_consent_and_vaccination(
7070
page: Page,
7171
vaccination_record: VaccinationRecord,
72+
*,
73+
mmrv_eligibility: bool = False,
7274
) -> None:
7375
child = vaccination_record.child
7476
programme = vaccination_record.programme
@@ -78,10 +80,14 @@ def record_nurse_consent_and_vaccination(
7880
SessionsPatientPage(page).click_record_a_new_consent_response()
7981
NurseConsentWizardPage(page).select_parent(child.parents[0])
8082
NurseConsentWizardPage(page).select_consent_method(ConsentMethod.IN_PERSON)
81-
NurseConsentWizardPage(page).select_mmrv_eligibility_for_child()
83+
84+
if mmrv_eligibility:
85+
NurseConsentWizardPage(page).select_mmrv_eligibility_for_child()
86+
8287
NurseConsentWizardPage(page).record_parent_positive_consent(
8388
programme=programme,
8489
consent_option=consent_option,
90+
mmrv_eligibility=mmrv_eligibility,
8591
)
8692
notes = generate_random_string(
8793
target_length=MAVIS_NOTE_LENGTH_LIMIT + 1,

tests/test_e2e_nurse_consent_mmr.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from mavis.test.annotations import issue
44
from mavis.test.constants import (
5+
MMRV_ELIGIBILITY_CUTOFF_DOB,
56
ConsentOption,
67
Programme,
78
Vaccine,
@@ -50,11 +51,23 @@ def test_e2e_nurse_consent_mmr(
5051
"""
5152
batch_names = setup_session_for_mmr
5253
programme_group = Programme.MMR
53-
vaccine = (
54-
Vaccine.PRIORIX
55-
if consent_option is ConsentOption.MMR_WITHOUT_GELATINE
56-
else Vaccine.MMR_VAXPRO
57-
)
54+
55+
child = children[programme_group][0]
56+
school = schools[programme_group][0]
57+
58+
mmrv_eligibility = child.date_of_birth > MMRV_ELIGIBILITY_CUTOFF_DOB
59+
if mmrv_eligibility:
60+
vaccine = (
61+
Vaccine.PRIORIX_TETRA
62+
if consent_option is ConsentOption.MMR_WITHOUT_GELATINE
63+
else Vaccine.PROQUAD
64+
)
65+
else:
66+
vaccine = (
67+
Vaccine.PRIORIX
68+
if consent_option is ConsentOption.MMR_WITHOUT_GELATINE
69+
else Vaccine.MMR_VAXPRO
70+
)
5871

5972
child = children[programme_group][0]
6073
school = schools[programme_group][0]
@@ -76,4 +89,5 @@ def test_e2e_nurse_consent_mmr(
7689
record_nurse_consent_and_vaccination(
7790
page,
7891
mmr_vaccination_record,
92+
mmrv_eligibility=mmrv_eligibility,
7993
)

0 commit comments

Comments
 (0)