Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions mavis/test/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Programme(StrEnum):
MENACWY = "MenACWY"
TD_IPV = "Td/IPV"

@property
def is_doubles(self) -> bool:
return self == self.MENACWY or self == self.TD_IPV

@property
def vaccines(self):
match self:
Expand Down Expand Up @@ -43,24 +47,21 @@ def health_questions(self):
return programme_specific_questions[self]

@property
def prescreening_questions(self):
common_questions = [
PrescreeningQuestion.FEELING_WELL,
PrescreeningQuestion.NO_RELEVANT_ALLERGIES,
PrescreeningQuestion.NOT_ALREADY_HAD,
PrescreeningQuestion.KNOW_PURPOSE_AND_CONSENT,
def pre_screening_checks(self):
checks = [
PreScreeningCheck.NOT_ACUTELY_UNWELL,
PreScreeningCheck.NO_RELEVANT_ALLERGIES,
PreScreeningCheck.NOT_ALREADY_HAD,
PreScreeningCheck.KNOW_VACCINATION,
]
programme_specific_questions = {
Programme.MENACWY: common_questions
+ [PrescreeningQuestion.NO_RELEVANT_MEDICATION],
Programme.TD_IPV: common_questions
+ [
PrescreeningQuestion.NO_RELEVANT_MEDICATION,
PrescreeningQuestion.NOT_PREGNANT,
],
Programme.HPV: common_questions,
}
return programme_specific_questions[self]

if self.is_doubles:
checks.append(PreScreeningCheck.NO_RELEVANT_MEDICATION)

if self == self.TD_IPV:
checks.append(PreScreeningCheck.NOT_PREGNANT)

return checks


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


class PrescreeningQuestion(StrEnum):
FEELING_WELL = "are feeling well"
class PreScreeningCheck(StrEnum):
KNOW_VACCINATION = "know what the vaccination is for, and are happy to have it"
NOT_ACUTELY_UNWELL = "are not acutely unwell"
NOT_ALREADY_HAD = "have not already had this vaccination"
NOT_PREGNANT = "are not pregnant"
NO_RELEVANT_ALLERGIES = "have no allergies which would prevent vaccination"
NOT_ALREADY_HAD = "have not already had the vaccination"
KNOW_PURPOSE_AND_CONSENT = (
"know what the vaccination is for, and are happy to have it"
)
NO_RELEVANT_MEDICATION = "are not taking any medication which prevents vaccination"
NOT_PREGNANT = "are not pregnant"


class ConsentRefusalReason(StrEnum):
Expand Down
43 changes: 19 additions & 24 deletions mavis/test/pages/sessions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import re
import time
from datetime import datetime
from typing import List

from playwright.sync_api import Page, expect

from ..data import TestData
from ..models import PrescreeningQuestion, Programme
from ..models import Programme
from ..step import step
from ..wrappers import generate_random_string, get_current_datetime, get_offset_date

Expand Down Expand Up @@ -121,13 +120,17 @@ def __init__(
self.notes_length_error = (
page.locator("div").filter(has_text="There is a problemEnter").nth(3)
)
self.prescreening_notes = self.page.get_by_role(
"textbox", name="Pre-screening notes (optional)"
)
self.vaccination_notes = self.page.get_by_role(
"textbox", name="Notes (optional)"
)

pre_screening = self.page.locator("section").filter(
has=page.get_by_role("heading", name="Pre-screening checks")
)
self.pre_screening_listitem = pre_screening.get_by_role("listitem")
self.pre_screening_checkbox = pre_screening.get_by_role("checkbox")
self.pre_screening_notes = pre_screening.get_by_role("textbox")

def __get_display_formatted_date(self, date_to_format: str) -> str:
_parsed_date = datetime.strptime(date_to_format, "%Y%m%d")
_formatted_date = _parsed_date.strftime("%A %d %B %Y").replace(" 0", " ")
Expand Down Expand Up @@ -328,6 +331,14 @@ def click_confirm_button(self):
def click_record_vaccinations(self):
self.record_vaccinations_link.click()

@step("Confirm pre-screening checks are true")
def confirm_pre_screening_checks(self, programme: Programme):
for check in programme.pre_screening_checks:
locator = self.pre_screening_listitem.get_by_text(check)
# TODO: Can we highlight in the report that we're checking this?
expect(locator).to_be_visible()
self.pre_screening_checkbox.check()

@step("Click on Yes")
def select_yes(self):
self.yes_radio.click()
Expand Down Expand Up @@ -570,18 +581,6 @@ def select_year_groups(self, *year_groups: int) -> None:
self.page.get_by_role("checkbox", name=f"Year {year_group}").check()
self.click_continue_button()

def _answer_prescreening_questions(self, programme: Programme):
for question in programme.prescreening_questions:
locator = self.page.get_by_role("checkbox", name=question)

if question == PrescreeningQuestion.FEELING_WELL and programme in [
Programme.MENACWY,
Programme.TD_IPV,
]:
expect(locator).to_be_checked()
else:
locator.check()

def register_child_as_attending(self, child_name: str):
self.click_register_tab()
self.search_for(child_name)
Expand Down Expand Up @@ -614,20 +613,16 @@ def record_vaccs_for_child(
self.search_child(child_name=child_name)
self.click_programme_tab(programme)

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

self._answer_prescreening_questions(programme=programme)
self.prescreening_notes.fill(notes)
self.select_yes()
self.select_left_arm_upper_position()
self.click_continue_button()

if len(notes) > 1000:
expect(self.notes_length_error).to_be_visible()
self.prescreening_notes.fill("Prescreening notes")
self.pre_screening_notes.fill("Prescreening notes")
self.click_continue_button()

self.page.get_by_role("radio", name=programme.vaccines[0]).check()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setup_mav_965(
@allure.issue("MAV-955")
@pytest.mark.rav
@pytest.mark.bug
def test_programmes_rav_prescreening_questions(
def test_programmes_rav_pre_screening_questions(
setup_mav_965, schools, programmes_page, dashboard_page, sessions_page, consent_page
):
"""
Expand Down