Skip to content

Commit e8d0892

Browse files
MAVIS-1696
1 parent 8249279 commit e8d0892

File tree

7 files changed

+135
-33
lines changed

7 files changed

+135
-33
lines changed

.env.generic

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
TEST_USERNAME=
22
TEST_PASSWORD=
3-
TEST_URL=https://test.mavistesting.com
3+
TEST_URL=https://pentest.mavistesting.com
44
HEADLESS=false
5-
LOGIN_USERNAME=
6-
LOGIN_PASSWORD=
7-
CAPTURE_SCREENSHOTS=true
8-
PARENTAL_CONSENT_URL=
9-
RESET_ENDPOINT=
5+
NURSE_USERNAME=
6+
NURSE_PASSWORD=
7+
SUPERUSER_USERNAME=
8+
SUPERUSER_PASSWORD=
9+
CAPTURE_SCREENSHOTS=false
10+
RESET_ENDPOINT=https://pentest.mavistesting.com/reset/R1L
1011
API_TOKEN=

libs/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class escape_characters:
8888
SINGLE_QUOTE_CLOSE,
8989
TAB,
9090
]
91-
FILE_NAME = [
91+
FILE_NAME: Final[str] = [
9292
SEPARATOR_CHAR,
9393
COLON,
9494
DOUBLE_QUOTE,
@@ -104,7 +104,7 @@ class escape_characters:
104104

105105

106106
class file_encoding:
107-
ASCII = "ascii"
107+
ASCII: Final[str] = "ascii"
108108

109109

110110
class test_data_file_paths:
@@ -123,6 +123,7 @@ class test_data_file_paths:
123123
COHORTS_INVALID_STRUCTURE: Final[str] = "COHORTS_INVALID_STRUCTURE"
124124
COHORTS_EMPTY_FILE: Final[str] = "COHORTS_EMPTY_FILE"
125125
COHORTS_HEADER_ONLY: Final[str] = "COHORTS_HEADER_ONLY"
126+
COHORTS_NO_APPROVAL: Final[str] = "COHORTS_NO_APPROVAL"
126127
CHILD_POSITIVE: Final[str] = "CHILD_POSITIVE"
127128
CHILD_NEGATIVE: Final[str] = "CHILD_NEGATIVE"
128129
CHILD_INVALID_STRUCTURE: Final[str] = "CHILD_INVALID_STRUCTURE"

pages/pg_parental_consent.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ class pg_parental_consent:
5050
RDO_PERSONAL_CHOICE = "Personal choice"
5151
RDO_OTHER = "Other"
5252
RDO_ONLINE = "Online"
53+
RDO_IN_PERSON = "In person"
5354
RDO_YES_THEY_AGREE = "Yes, they agree"
5455
RDO_NO_THEY_DO_NOT_AGREE = "No, they do not agree"
5556
RDO_NO_RESPONSE = "No response"
5657
RDO_YES_SAFE_TO_VACCINATE = "Yes, it’s safe to vaccinate"
5758
LBL_CONSENT_RECORDED = "Consent recorded for CF"
5859
LBL_MAIN = "main"
60+
RDO_PARENT1_DAD = "Parent1 (Dad)"
61+
RDO_PARENT2_MUM = "Parent2 (Mum)"
5962

6063
def click_start_now(self):
6164
self.po.perform_action(locator=self.BTN_START_NOW, action=actions.CLICK_BUTTON)
@@ -192,7 +195,7 @@ def select_consent_not_given_reason(self, reason: str, reason_details: str) -> N
192195
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
193196

194197
def service_give_consent(self):
195-
self.po.perform_action(locator="Parent1 (Dad)", action=actions.RADIO_BUTTON_SELECT)
198+
self.po.perform_action(locator=self.RDO_PARENT1_DAD, action=actions.RADIO_BUTTON_SELECT)
196199
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
197200
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON) # Parent contact details page
198201
self.po.perform_action(locator=self.RDO_ONLINE, action=actions.RADIO_BUTTON_SELECT)
@@ -226,7 +229,7 @@ def service_give_consent(self):
226229
self.po.perform_action(locator=self.BTN_CONFIRM, action=actions.CLICK_BUTTON)
227230

228231
def service_refuse_consent(self):
229-
self.po.perform_action(locator="Parent1 (Dad)", action=actions.RADIO_BUTTON_SELECT)
232+
self.po.perform_action(locator=self.RDO_PARENT1_DAD, action=actions.RADIO_BUTTON_SELECT)
230233
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
231234
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON) # Parent contact details page
232235
self.po.perform_action(locator=self.RDO_ONLINE, action=actions.RADIO_BUTTON_SELECT)
@@ -242,3 +245,25 @@ def service_refuse_consent(self):
242245
self.po.verify(
243246
locator=self.LBL_MAIN, property=object_properties.TEXT, value=self.LBL_CONSENT_RECORDED, exact=False
244247
)
248+
249+
def parent_1_verbal_no_response(self):
250+
self.po.perform_action(locator=self.RDO_PARENT1_DAD, action=actions.RADIO_BUTTON_SELECT)
251+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
252+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON) # Parent contact details page
253+
self.po.perform_action(locator=self.RDO_IN_PERSON, action=actions.RADIO_BUTTON_SELECT)
254+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
255+
self.po.perform_action(locator=self.RDO_NO_RESPONSE, action=actions.RADIO_BUTTON_SELECT)
256+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
257+
self.po.perform_action(locator=self.BTN_CONFIRM, action=actions.CLICK_BUTTON)
258+
259+
def parent_2_verbal_refuse_consent(self):
260+
self.po.perform_action(locator=self.RDO_PARENT2_MUM, action=actions.RADIO_BUTTON_SELECT)
261+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
262+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON) # Parent contact details page
263+
self.po.perform_action(locator=self.RDO_IN_PERSON, action=actions.RADIO_BUTTON_SELECT)
264+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
265+
self.po.perform_action(locator=self.RDO_NO_THEY_DO_NOT_AGREE, action=actions.RADIO_BUTTON_SELECT)
266+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
267+
self.po.perform_action(locator=self.RDO_PERSONAL_CHOICE, action=actions.RADIO_BUTTON_SELECT)
268+
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
269+
self.po.perform_action(locator=self.BTN_CONFIRM, action=actions.CLICK_BUTTON)

pages/pg_sessions.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class pg_sessions:
1818
LNK_TAB_TODAY = "Today"
1919
LNK_TAB_SCHEDULED = "Scheduled"
2020
LNK_TAB_UNSCHEDULED = "Unscheduled"
21+
LNK_TAB_NO_RESPONSE = "No response"
2122
LNK_TAB_ACTIVITY_LOG = "Activity log"
2223
LNK_IMPORT_CLASS_LIST = "Import class list"
2324
LBL_CHOOSE_COHORT_FILE_1 = f"{LNK_SCHOOL_1}Import class"
@@ -26,6 +27,7 @@ class pg_sessions:
2627
LNK_ADD_SESSION_DATES = "Add session dates"
2728
LNK_RECORD_VACCINATIONS = "Record vaccinations"
2829
LNK_CHILD_FULL_NAME = "CF"
30+
LNK_CHILD_NO_CONSENT = "NoConsent1 NoConsent1"
2931
LNK_UPDATE_TRIAGE_OUTCOME = "Update triage outcome"
3032
LNK_SCHEDULE_SESSIONS = "Schedule sessions"
3133
RDO_YES_SAFE_TO_VACCINATE = "Yes, it’s safe to vaccinate"
@@ -42,15 +44,15 @@ class pg_sessions:
4244
LNK_BACK = "Back"
4345
LNK_CONTINUE = "Continue"
4446
LNK_CONSENT_FORM = "View parental consent form (opens in new tab)"
45-
BTN_CHECK_CONSENT_RESPONSES = "Check consent responses"
4647
LNK_ASSESS_GILLICK_COMPETENT = "Assess Gillick competence"
4748
RDO_YES_GILLICK_COMPETENT = "Yes, they are Gillick competent"
4849
RDO_NO_GILLICK_COMPETENT = "No"
4950
TXT_GILLICK_ASSESSMENT_DETAILS = "Assessment notes (optional)"
5051
BTN_SAVE_CHANGES = "Save changes"
5152
LBL_ACTIVITY_LOG_ENTRY_CONSENT_GIVEN = "Triaged decision: Safe to vaccinate"
5253
LBL_ACTIVITY_LOG_ENTRY_CONSENT_REFUSED = "Consent refused by Parent1 (Dad)"
53-
BTN_GET_CONSENT_RESPONSES = "Get consent response"
54+
BTN_GET_CONSENT_RESPONSE = "Get consent response"
55+
LNK_CHECK_CONSENT_RESPONSES = "Check consent responses"
5456
BTN_COMPLETE_GILLICK_ASSESSMENT = "Complete your assessment"
5557
LBL_CHILD_COMPETENT = "Child assessed as Gillick competent"
5658
LBL_CHILD_NOT_COMPETENT = "Child assessed as not Gillick competent"
@@ -59,6 +61,9 @@ class pg_sessions:
5961
LNK_CONSENT_FORM = "View parental consent form ("
6062
LNK_COULD_NOT_VACCINATE = "Could not vaccinate"
6163
LNK_CONSENT_REFUSED = "Consent refused"
64+
LNK_MARK_AS_INVALID = "Mark as invalid"
65+
LNK_PARENT2 = "Parent2"
66+
TXT_NOTES = "Notes"
6267

6368
def __get_display_formatted_date(self, date_to_format: str) -> str:
6469
_parsed_date = datetime.strptime(date_to_format, "%Y%m%d")
@@ -86,6 +91,9 @@ def click_scheduled(self):
8691
def click_unscheduled(self):
8792
self.po.perform_action(locator=self.LNK_TAB_UNSCHEDULED, action=actions.CLICK_LINK, exact=True)
8893

94+
def click_no_response(self):
95+
self.po.perform_action(locator=self.LNK_TAB_NO_RESPONSE, action=actions.CLICK_LINK, exact=False)
96+
8997
def click_activity_log(self):
9098
self.po.perform_action(locator=self.LNK_TAB_ACTIVITY_LOG, action=actions.CLICK_LINK, exact=True)
9199

@@ -114,6 +122,9 @@ def click_record_vaccinations(self):
114122
def click_child_full_name(self):
115123
self.po.perform_action(locator=self.LNK_CHILD_FULL_NAME, action=actions.CLICK_WILDCARD)
116124

125+
def click_child_no_consent(self):
126+
self.po.perform_action(locator=self.LNK_CHILD_NO_CONSENT, action=actions.CLICK_LINK)
127+
117128
def click_update_triage_outcome(self):
118129
self.po.perform_action(locator=self.LNK_UPDATE_TRIAGE_OUTCOME, action=actions.CLICK_LINK)
119130

@@ -124,7 +135,7 @@ def click_save_triage(self):
124135
self.po.perform_action(locator=self.BTN_SAVE_TRIAGE, action=actions.CLICK_BUTTON)
125136

126137
def click_check_consent_responses(self):
127-
self.po.perform_action(locator=self.BTN_CHECK_CONSENT_RESPONSES, action=actions.CLICK_LINK)
138+
self.po.perform_action(locator=self.LNK_CHECK_CONSENT_RESPONSES, action=actions.CLICK_LINK)
128139

129140
def click_assess_gillick_competent(self):
130141
self.po.perform_action(locator=self.LNK_ASSESS_GILLICK_COMPETENT, action=actions.CLICK_LINK)
@@ -280,12 +291,30 @@ def verify_activity_log_entry(self, consent_given: bool):
280291
exact=False,
281292
)
282293

294+
def invalidate_parent2_refusal(self):
295+
self.po.perform_action(locator=self.LNK_PARENT2, action=actions.CLICK_LINK)
296+
self.po.perform_action(locator=self.LNK_MARK_AS_INVALID, action=actions.CLICK_LINK)
297+
self.po.perform_action(locator=self.TXT_NOTES, action=actions.FILL, value="Invalidation notes.")
298+
self.po.perform_action(locator=self.LNK_MARK_AS_INVALID, action=actions.CLICK_BUTTON)
299+
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value="Consent refusedInvalid")
300+
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value="Invalidation notes.")
301+
self.po.perform_action(locator=self.LNK_BACK, action=actions.CLICK_LINK)
302+
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value="Consent refusedInvalid")
303+
self.po.verify(
304+
locator=self.LBL_MAIN,
305+
property=object_properties.TEXT,
306+
value="No-one responded to our requests for consent.",
307+
)
308+
283309
def verify_scheduled_date(self, message: str):
284310
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value=message, exact=False)
285311
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_LINK)
286312

313+
def click_get_consent_response(self):
314+
self.po.perform_action(locator=self.BTN_GET_CONSENT_RESPONSE, action=actions.CLICK_BUTTON)
315+
287316
def click_get_consent_responses(self):
288-
self.po.perform_action(locator=self.BTN_GET_CONSENT_RESPONSES, action=actions.CLICK_BUTTON)
317+
self.po.perform_action(locator=self.LNK_CHECK_CONSENT_RESPONSES, action=actions.CLICK_BUTTON)
289318

290319
def upload_valid_class_list(self, file_paths: str):
291320
_input_file_path, _ = self.tdo.get_file_paths(file_paths=file_paths)
@@ -308,7 +337,7 @@ def update_triage_outcome_positive(self, file_paths):
308337
self.click_school1()
309338
self.click_check_consent_responses()
310339
self.click_child_full_name()
311-
self.click_get_consent_responses()
340+
self.click_get_consent_response()
312341
self.consent_page.service_give_consent()
313342
self.dashboard_page.go_to_dashboard()
314343
self.dashboard_page.click_sessions()
@@ -337,7 +366,7 @@ def update_triage_outcome_consent_refused(self, file_paths):
337366
self.click_school1()
338367
self.click_check_consent_responses()
339368
self.click_child_full_name()
340-
self.click_get_consent_responses()
369+
self.click_get_consent_response()
341370
self.consent_page.service_refuse_consent()
342371
self.click_consent_refused()
343372
self.click_child_full_name()
@@ -404,3 +433,28 @@ def set_gillick_competence_for_student(self):
404433

405434
def get_consent_url(self) -> str:
406435
return self.po.get_object_property(locator=self.LNK_CONSENT_FORM, property=object_properties.HREF)
436+
437+
def disparate_consent_scenario(self):
438+
self.click_no_response()
439+
self.click_child_no_consent()
440+
self.click_get_consent_response()
441+
self.consent_page.parent_1_verbal_no_response()
442+
self.click_no_response()
443+
self.click_child_no_consent()
444+
self.click_get_consent_response()
445+
self.consent_page.parent_2_verbal_refuse_consent()
446+
self.click_consent_refused()
447+
self.click_child_no_consent()
448+
self.invalidate_parent2_refusal()
449+
self.click_activity_log()
450+
wait(timeout=wait_time.MIN)
451+
# FIXME: Make the following generic
452+
self.po.verify(
453+
locator=self.LBL_MAIN, property=object_properties.TEXT, value="Consent from Parent2 invalidated"
454+
)
455+
self.po.verify(
456+
locator=self.LBL_MAIN, property=object_properties.TEXT, value="Consent refused by Parent2 (Mum)"
457+
)
458+
self.po.verify(
459+
locator=self.LBL_MAIN, property=object_properties.TEXT, value="Consent not_provided by Parent1 (Dad)"
460+
)

test_data/cohorts/i_no_consent.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_COMMON_NAME,CHILD_DATE_OF_BIRTH,CHILD_SCHOOL_URN,CHILD_NHS_NUMBER,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_POSTCODE,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE
2+
NoConsent1,NoConsent1,ChildCommon,1-1-2009,142181,<<NHS_NO>>,Addr1,Add2,City,AA1 1AA,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],

test_data/file_mapping.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COHORTS_NEGATIVE,test_data/cohorts/i_negative.csv,test_data/cohorts/o_negative.c
1313
COHORTS_INVALID_STRUCTURE,test_data/cohorts/i_invalid_structure.csv,test_data/cohorts/o_invalid_structure.csv,cohort
1414
COHORTS_EMPTY_FILE,test_data/cohorts/i_empty.csv,test_data/cohorts/o_empty.csv,cohort
1515
COHORTS_HEADER_ONLY,test_data/cohorts/i_header_only.csv,test_data/cohorts/o_header_only.csv,cohort
16+
COHORTS_NO_APPROVAL,test_data/cohorts/i_no_consent.csv,,cohort
1617
CHILD_POSITIVE,test_data/child/i_positive.csv,test_data/child/o_positive.csv,child
1718
CHILD_NEGATIVE,test_data/child/i_negative.csv,test_data/child/o_negative.csv,child
1819
CHILD_INVALID_STRUCTURE,test_data/child/i_invalid_structure.csv,test_data/child/o_invalid_structure.csv,child

tests/test_09_consent.py

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ class Test_Consent:
1515
dashboard_page = pg_dashboard.pg_dashboard()
1616
sessions_page = pg_sessions.pg_sessions()
1717

18-
@pytest.fixture
19-
def setup_tests(self, start_mavis: None):
20-
self.login_page.login_as_nurse()
21-
self.dashboard_page.click_sessions()
22-
self.sessions_page.schedule_a_valid_session(for_today=True)
23-
self.dashboard_page.go_to_dashboard()
24-
self.dashboard_page.click_sessions()
25-
self.sessions_page.upload_valid_class_list(file_paths=test_data_file_paths.COHORTS_POSITIVE)
26-
self.dashboard_page.go_to_dashboard()
27-
self.dashboard_page.click_sessions()
28-
yield
29-
self.dashboard_page.go_to_dashboard()
30-
self.dashboard_page.click_sessions()
31-
self.sessions_page.delete_all_sessions()
32-
self.login_page.logout_of_mavis()
33-
3418
@pytest.fixture
3519
def get_session_link(self, start_mavis: None):
3620
self.login_page.login_as_nurse()
@@ -57,5 +41,39 @@ def test_parental_consent_workflow(self, get_session_link: str, scenario_data: I
5741
@pytest.mark.consent
5842
@pytest.mark.mobile
5943
@pytest.mark.order(902)
60-
def test_gillick_competence(self, setup_tests: None):
44+
def test_gillick_competence(self, start_mavis: None):
45+
self.login_page.login_as_nurse()
46+
self.dashboard_page.click_sessions()
47+
self.sessions_page.schedule_a_valid_session(for_today=True)
48+
self.dashboard_page.go_to_dashboard()
49+
self.dashboard_page.click_sessions()
50+
self.sessions_page.upload_valid_class_list(file_paths=test_data_file_paths.COHORTS_POSITIVE)
51+
self.dashboard_page.go_to_dashboard()
52+
self.dashboard_page.click_sessions()
6153
self.sessions_page.set_gillick_competence_for_student()
54+
self.dashboard_page.go_to_dashboard()
55+
self.dashboard_page.click_sessions()
56+
self.sessions_page.delete_all_sessions()
57+
self.login_page.logout_of_mavis()
58+
59+
@pytest.mark.consent
60+
@pytest.mark.mobile
61+
@pytest.mark.bugs # MAVIS-1696
62+
@pytest.mark.order(903)
63+
def test_invalid_consent(self, start_mavis: None):
64+
self.login_page.login_as_nurse()
65+
self.dashboard_page.click_sessions()
66+
self.sessions_page.schedule_a_valid_session()
67+
self.dashboard_page.go_to_dashboard()
68+
self.dashboard_page.click_sessions()
69+
self.sessions_page.upload_valid_class_list(file_paths=test_data_file_paths.COHORTS_NO_APPROVAL)
70+
self.dashboard_page.go_to_dashboard()
71+
self.dashboard_page.click_sessions()
72+
self.sessions_page.click_scheduled()
73+
self.sessions_page.click_school1()
74+
self.sessions_page.click_check_consent_responses()
75+
self.sessions_page.disparate_consent_scenario()
76+
self.dashboard_page.go_to_dashboard()
77+
self.dashboard_page.click_sessions()
78+
self.sessions_page.delete_all_sessions()
79+
self.login_page.logout_of_mavis()

0 commit comments

Comments
 (0)