Skip to content

Commit b9f51d5

Browse files
committed
Update tests following pre-screening redesign
In nhsuk/manage-vaccinations-in-schools#3493 the pre-screening checks have been redesigned to be a single checkbox with some list items on each check that needs to be taken. This updates the tests to ensure they continue to work under this new design.
1 parent 6b40759 commit b9f51d5

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

mavis/test/models.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class Programme(StrEnum):
88
MENACWY = "MenACWY"
99
TD_IPV = "Td/IPV"
1010

11+
@property
12+
def is_doubles(self) -> bool:
13+
return self == self.MENACWY or self == self.TD_IPV
14+
1115
@property
1216
def vaccines(self):
1317
match self:
@@ -43,24 +47,21 @@ def health_questions(self):
4347
return programme_specific_questions[self]
4448

4549
@property
46-
def prescreening_questions(self):
47-
common_questions = [
48-
PrescreeningQuestion.FEELING_WELL,
49-
PrescreeningQuestion.NO_RELEVANT_ALLERGIES,
50-
PrescreeningQuestion.NOT_ALREADY_HAD,
51-
PrescreeningQuestion.KNOW_PURPOSE_AND_CONSENT,
50+
def pre_screening_checks(self):
51+
checks = [
52+
PreScreeningCheck.NOT_ACUTELY_UNWELL,
53+
PreScreeningCheck.NO_RELEVANT_ALLERGIES,
54+
PreScreeningCheck.NOT_ALREADY_HAD,
55+
PreScreeningCheck.KNOW_VACCINATION,
5256
]
53-
programme_specific_questions = {
54-
Programme.MENACWY: common_questions
55-
+ [PrescreeningQuestion.NO_RELEVANT_MEDICATION],
56-
Programme.TD_IPV: common_questions
57-
+ [
58-
PrescreeningQuestion.NO_RELEVANT_MEDICATION,
59-
PrescreeningQuestion.NOT_PREGNANT,
60-
],
61-
Programme.HPV: common_questions,
62-
}
63-
return programme_specific_questions[self]
57+
58+
if self.is_doubles:
59+
checks.append(PreScreeningCheck.NO_RELEVANT_MEDICATION)
60+
61+
if self == self.TD_IPV:
62+
checks.append(PreScreeningCheck.NOT_PREGNANT)
63+
64+
return checks
6465

6566

6667
class Vaccine(StrEnum):
@@ -93,15 +94,13 @@ class HealthQuestion(StrEnum):
9394
PAST_TDIPV_VACCINE = "Has your child had a tetanus, diphtheria and polio vaccination in the last 5 years?"
9495

9596

96-
class PrescreeningQuestion(StrEnum):
97-
FEELING_WELL = "are feeling well"
97+
class PreScreeningCheck(StrEnum):
98+
KNOW_VACCINATION = "know what the vaccination is for, and are happy to have it"
99+
NOT_ACUTELY_UNWELL = "are not acutely unwell"
100+
NOT_ALREADY_HAD = "have not already had this vaccination"
101+
NOT_PREGNANT = "are not pregnant"
98102
NO_RELEVANT_ALLERGIES = "have no allergies which would prevent vaccination"
99-
NOT_ALREADY_HAD = "have not already had the vaccination"
100-
KNOW_PURPOSE_AND_CONSENT = (
101-
"know what the vaccination is for, and are happy to have it"
102-
)
103103
NO_RELEVANT_MEDICATION = "are not taking any medication which prevents vaccination"
104-
NOT_PREGNANT = "are not pregnant"
105104

106105

107106
class ConsentRefusalReason(StrEnum):

mavis/test/pages/sessions.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import re
2-
import time
32
from datetime import datetime
43
from typing import List
54

65
from playwright.sync_api import Page, expect
76

87
from ..data import TestData
9-
from ..models import PrescreeningQuestion, Programme
8+
from ..models import Programme
109
from ..step import step
1110
from ..wrappers import generate_random_string, get_current_datetime, get_offset_date
1211

@@ -121,13 +120,17 @@ def __init__(
121120
self.notes_length_error = (
122121
page.locator("div").filter(has_text="There is a problemEnter").nth(3)
123122
)
124-
self.prescreening_notes = self.page.get_by_role(
125-
"textbox", name="Pre-screening notes (optional)"
126-
)
127123
self.vaccination_notes = self.page.get_by_role(
128124
"textbox", name="Notes (optional)"
129125
)
130126

127+
pre_screening = self.page.locator("section").filter(
128+
has=page.get_by_role("heading", name="Pre-screening checks")
129+
)
130+
self.pre_screening_listitem = pre_screening.get_by_role("listitem")
131+
self.pre_screening_checkbox = pre_screening.get_by_role("checkbox")
132+
self.pre_screening_notes = pre_screening.get_by_role("textbox")
133+
131134
def __get_display_formatted_date(self, date_to_format: str) -> str:
132135
_parsed_date = datetime.strptime(date_to_format, "%Y%m%d")
133136
_formatted_date = _parsed_date.strftime("%A %d %B %Y").replace(" 0", " ")
@@ -328,6 +331,14 @@ def click_confirm_button(self):
328331
def click_record_vaccinations(self):
329332
self.record_vaccinations_link.click()
330333

334+
@step("Confirm pre-screening checks are true")
335+
def confirm_pre_screening_checks(self, programme: Programme):
336+
for check in programme.pre_screening_checks:
337+
locator = self.pre_screening_listitem.get_by_text(check)
338+
# TODO: Can we highlight in the report that we're checking this?
339+
expect(locator).to_be_visible()
340+
self.pre_screening_checkbox.check()
341+
331342
@step("Click on Yes")
332343
def select_yes(self):
333344
self.yes_radio.click()
@@ -570,18 +581,6 @@ def select_year_groups(self, *year_groups: int) -> None:
570581
self.page.get_by_role("checkbox", name=f"Year {year_group}").check()
571582
self.click_continue_button()
572583

573-
def _answer_prescreening_questions(self, programme: Programme):
574-
for question in programme.prescreening_questions:
575-
locator = self.page.get_by_role("checkbox", name=question)
576-
577-
if question == PrescreeningQuestion.FEELING_WELL and programme in [
578-
Programme.MENACWY,
579-
Programme.TD_IPV,
580-
]:
581-
expect(locator).to_be_checked()
582-
else:
583-
locator.check()
584-
585584
def register_child_as_attending(self, child_name: str):
586585
self.click_register_tab()
587586
self.search_for(child_name)
@@ -614,20 +613,16 @@ def record_vaccs_for_child(
614613
self.search_child(child_name=child_name)
615614
self.click_programme_tab(programme)
616615

617-
# FIXME: Figure out why we need this. Without this pause, the form
618-
# elements seem to clear out when the continue button is pressed
619-
# and the form fails to submit.
620-
time.sleep(0.25)
616+
self.confirm_pre_screening_checks(programme)
617+
self.pre_screening_notes.fill(notes)
621618

622-
self._answer_prescreening_questions(programme=programme)
623-
self.prescreening_notes.fill(notes)
624619
self.select_yes()
625620
self.select_left_arm_upper_position()
626621
self.click_continue_button()
627622

628623
if len(notes) > 1000:
629624
expect(self.notes_length_error).to_be_visible()
630-
self.prescreening_notes.fill("Prescreening notes")
625+
self.pre_screening_notes.fill("Prescreening notes")
631626
self.click_continue_button()
632627

633628
self.page.get_by_role("radio", name=programme.vaccines[0]).check()

tests/test_reset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def setup_mav_965(
3232
@allure.issue("MAV-955")
3333
@pytest.mark.rav
3434
@pytest.mark.bug
35-
def test_programmes_rav_prescreening_questions(
35+
def test_programmes_rav_pre_screening_questions(
3636
setup_mav_965, schools, programmes_page, dashboard_page, sessions_page, consent_page
3737
):
3838
"""

0 commit comments

Comments
 (0)