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
38 changes: 29 additions & 9 deletions pages/pg_parental_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class pg_parental_consent:
TXT_ADDRESS_POSTCODE = "Postcode"
RDO_YES = "Yes"
RDO_NO = "No"
TXT_DETAILS = "Give details"
TXT_GIVE_DETAILS = "Give details"
BTN_CONFIRM = "Confirm"
LBL_SCHOOL_NAME = "school-name"
RDO_VACCINE_ALREADY_RECEIVED = "Vaccine already received"
Expand All @@ -54,6 +54,8 @@ class pg_parental_consent:
RDO_NO_THEY_DO_NOT_AGREE = "No, they do not agree"
RDO_NO_RESPONSE = "No response"
RDO_YES_SAFE_TO_VACCINATE = "Yes, it’s safe to vaccinate"
LBL_CONSENT_RECORDED = "Consent recorded for CF"
LBL_MAIN = "main"

def click_start_now(self):
self.po.perform_action(locator=self.BTN_START_NOW, action=actions.CLICK_BUTTON)
Expand Down Expand Up @@ -132,31 +134,31 @@ def select_severe_allergies(self, allergy_details: str = data_values.EMPTY) -> N
self.po.perform_action(locator=self.RDO_NO, action=actions.RADIO_BUTTON_SELECT)
else:
self.po.perform_action(locator=self.RDO_YES, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=allergy_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=allergy_details)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)

def select_medical_condition(self, medical_condition_details: str = data_values.EMPTY) -> None:
if medical_condition_details == data_values.EMPTY:
self.po.perform_action(locator=self.RDO_NO, action=actions.RADIO_BUTTON_SELECT)
else:
self.po.perform_action(locator=self.RDO_YES, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=medical_condition_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=medical_condition_details)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)

def select_severe_reaction(self, reaction_details: str = data_values.EMPTY) -> None:
if reaction_details == data_values.EMPTY:
self.po.perform_action(locator=self.RDO_NO, action=actions.RADIO_BUTTON_SELECT)
else:
self.po.perform_action(locator=self.RDO_YES, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=reaction_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=reaction_details)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)

def select_extra_support(self, extra_support_details: str = data_values.EMPTY) -> None:
if extra_support_details == data_values.EMPTY:
self.po.perform_action(locator=self.RDO_NO, action=actions.RADIO_BUTTON_SELECT)
else:
self.po.perform_action(locator=self.RDO_YES, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=extra_support_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=extra_support_details)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)

def click_confirm_details(self) -> None:
Expand All @@ -170,23 +172,23 @@ def select_consent_not_given_reason(self, reason: str, reason_details: str) -> N
case "vaccine already received":
self.po.perform_action(locator=self.RDO_VACCINE_ALREADY_RECEIVED, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=reason_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=reason_details)
case "vaccine will be given elsewhere":
self.po.perform_action(
locator=self.RDO_VACCINE_WILL_BE_GIVEN_ELSEWHERE, action=actions.RADIO_BUTTON_SELECT
)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=reason_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=reason_details)
case "medical reasons":
self.po.perform_action(locator=self.RDO_VACCINE_MEDICAL_REASONS, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=reason_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=reason_details)
case "personal choice":
self.po.perform_action(locator=self.RDO_PERSONAL_CHOICE, action=actions.RADIO_BUTTON_SELECT)
case _: # Other
self.po.perform_action(locator=self.RDO_OTHER, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.TXT_DETAILS, action=actions.FILL, value=reason_details)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value=reason_details)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)

def service_give_consent(self):
Expand Down Expand Up @@ -222,3 +224,21 @@ def service_give_consent(self):
self.po.perform_action(locator=self.RDO_YES_SAFE_TO_VACCINATE, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.BTN_CONFIRM, action=actions.CLICK_BUTTON)

def service_refuse_consent(self):
self.po.perform_action(locator="Parent1 (Dad)", action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON) # Parent contact details page
self.po.perform_action(locator=self.RDO_ONLINE, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.RDO_NO_THEY_DO_NOT_AGREE, action=actions.RADIO_BUTTON_SELECT)
# self.po.perform_action(locator=self.RDO_NO_RESPONSE , action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.RDO_VACCINE_ALREADY_RECEIVED, action=actions.RADIO_BUTTON_SELECT)
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.TXT_GIVE_DETAILS, action=actions.FILL, value="Given elsewhere")
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
self.po.perform_action(locator=self.BTN_CONFIRM, action=actions.CLICK_BUTTON)
self.po.verify(
locator=self.LBL_MAIN, property=object_properties.TEXT, value=self.LBL_CONSENT_RECORDED, exact=False
)
54 changes: 48 additions & 6 deletions pages/pg_sessions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from pickle import TRUE

from playwright.sync_api import expect

Expand Down Expand Up @@ -52,14 +53,16 @@ class pg_sessions:
RDO_NO_GILLICK_COMPETENT = "No"
TXT_GILLICK_ASSESSMENT_DETAILS = "Assessment notes (optional)"
BTN_SAVE_CHANGES = "Save changes"
LBL_ACTIVITY_LOG_ENTRY = f"Triaged decision: Safe to vaccinate"
LBL_ACTIVITY_LOG_ENTRY_CONSENT_GIVEN = "Triaged decision: Safe to vaccinate"
LBL_ACTIVITY_LOG_ENTRY_CONSENT_REFUSED = "Consent refused by Parent1 (Dad)"
BTN_GET_CONSENT_RESPONSES = "Get consent response"
BTN_COMPLETE_GILLICK_ASSESSMENT = "Complete your assessment"
LBL_CHILD_COMPETENT = "Child assessed as Gillick competent"
LBL_CHILD_NOT_COMPETENT = "Child assessed as not Gillick competent"
LNK_EDIT_GILLICK_COMPETENCE = "Edit Gillick competence"
BTN_UPDATE_GILLICK_ASSESSMENT = "Update your assessment"
LNK_CONSENT_FORM = "View parental consent form ("
LNK_COULD_NOT_VACCINATE = "Could not vaccinate"

def __get_display_formatted_date(self, date_to_format: str) -> str:
_parsed_date = datetime.strptime(date_to_format, "%Y%m%d")
Expand Down Expand Up @@ -133,6 +136,9 @@ def click_assess_gillick_competent(self):
def click_edit_gillick_competence(self):
self.po.perform_action(locator=self.LNK_EDIT_GILLICK_COMPETENCE, action=actions.CLICK_LINK)

def click_could_not_vaccinate(self):
self.po.perform_action(locator=self.LNK_COULD_NOT_VACCINATE, action=actions.CLICK_LINK)

def add_gillick_competence(self, is_competent: bool, competence_details: str) -> None:
self.__set_gillick_consent(is_add=True, is_competent=is_competent, competence_details=competence_details)

Expand Down Expand Up @@ -236,10 +242,21 @@ def verify_triage_updated(self):
exact=False,
)

def verify_activity_log_entry(self):
self.po.verify(
locator=self.LBL_MAIN, property=object_properties.TEXT, value=self.LBL_ACTIVITY_LOG_ENTRY, exact=False
)
def verify_activity_log_entry(self, consent_given: bool):
if consent_given:
self.po.verify(
locator=self.LBL_MAIN,
property=object_properties.TEXT,
value=self.LBL_ACTIVITY_LOG_ENTRY_CONSENT_GIVEN,
exact=False,
)
else:
self.po.verify(
locator=self.LBL_MAIN,
property=object_properties.TEXT,
value=self.LBL_ACTIVITY_LOG_ENTRY_CONSENT_REFUSED,
exact=False,
)

def verify_scheduled_date(self, message: str):
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value=message, exact=False)
Expand Down Expand Up @@ -283,7 +300,32 @@ def update_triage_outcome_positive(self, file_paths):
self.verify_triage_updated()
self.click_child_full_name()
self.click_activity_log()
self.verify_activity_log_entry()
self.verify_activity_log_entry(consent_given=True)

def update_triage_outcome_consent_refused(self, file_paths):
_input_file_path, _ = self.tdo.split_file_paths(file_paths=file_paths)
self.click_scheduled()
self.click_school1()
self.click_import_class_list()
self.choose_file_child_records(file_path=_input_file_path)
self.click_continue()
self.dashboard_page.go_to_dashboard()
self.dashboard_page.click_sessions()
self.click_scheduled()
self.click_school1()
self.click_check_consent_responses()
self.click_child_full_name()
self.click_get_consent_responses()
self.consent_page.service_refuse_consent()
self.dashboard_page.go_to_dashboard()
self.dashboard_page.click_sessions()
self.click_scheduled()
self.click_school1()
self.click_record_vaccinations()
self.click_could_not_vaccinate()
self.click_child_full_name()
self.click_activity_log()
self.verify_activity_log_entry(consent_given=False)

def schedule_a_valid_session(self, for_today: bool = False):
_future_date = get_offset_date(offset_days=0) if for_today else get_offset_date(offset_days=10)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_07_record_a_vaccine_using_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def test_setup(self, start_mavis: None):
@pytest.mark.order(701)
def test_reg_rav_triage_positive(self, test_setup):
self.sessions_page.update_triage_outcome_positive(file_paths=test_data_file_paths.COHORTS_POSITIVE)

@pytest.mark.rav
@pytest.mark.order(702)
def test_reg_rav_triage_consent_refused(self, test_setup):
self.sessions_page.update_triage_outcome_consent_refused(file_paths=test_data_file_paths.COHORTS_POSITIVE)
Loading