Skip to content

Commit a21da0d

Browse files
gillick competence
1 parent 478ae36 commit a21da0d

File tree

4 files changed

+111
-27
lines changed

4 files changed

+111
-27
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"[python]": {
1919
"editor.defaultFormatter": "ms-python.black-formatter",
2020
"editor.formatOnSave": true,
21-
}
21+
},
22+
"python.analysis.autoImportCompletions": true
2223
}

libs/wrappers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def clean_file_name(file_name: str) -> str:
5858

5959
def get_future_date(offset_days: int) -> str:
6060
_future_date = datetime.now() + timedelta(days=offset_days)
61-
while _future_date.weekday() >= 5:
62-
_future_date = _future_date + timedelta(days=1)
61+
if offset_days != 0:
62+
while _future_date.weekday() >= 5:
63+
_future_date = _future_date + timedelta(days=1)
6364
return _future_date.strftime("%Y%m%d")

pages/pg_sessions.py

Lines changed: 88 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ class pg_sessions:
4747
LNK_CONTINUE = "Continue"
4848
LNK_CONSENT_FORM = "View parental consent form (opens in new tab)"
4949
BTN_CHECK_CONSENT_RESPONSES = "Check consent responses"
50-
LNK_GIVE_GILLICK_CONSENT = "Give your assessment"
50+
LNK_ASSESS_GILLICK_COMPETENT = "Assess Gillick competence"
5151
RDO_YES_GILLICK_COMPETENT = "Yes, they are Gillick competent"
5252
RDO_NO_GILLICK_COMPETENT = "No"
53-
TXT_GILLICK_ASSESSMENT_DETAILS = "CF" # "Details of your assessment"
53+
TXT_GILLICK_ASSESSMENT_DETAILS = "Assessment notes (optional)"
5454
BTN_SAVE_CHANGES = "Save changes"
5555
LBL_ACTIVITY_LOG_ENTRY = f"Triaged decision: Safe to vaccinate"
5656
BTN_GET_CONSENT_RESPONSES = "Get consent response"
57+
BTN_COMPLETE_GILLICK_ASSESSMENT = "Complete your assessment"
58+
LBL_CHILD_COMPETENT = "Child assessed as Gillick competent"
59+
LBL_CHILD_NOT_COMPETENT = "Child assessed as not Gillick competent"
60+
LNK_EDIT_GILLICK_COMPETENCE = "Edit Gillick competence"
61+
BTN_UPDATE_GILLICK_ASSESSMENT = "Update your assessment"
5762

5863
def __get_display_formatted_date(self, date_to_format: str) -> str:
5964
_parsed_date = datetime.strptime(date_to_format, "%Y%m%d")
@@ -121,24 +126,77 @@ def click_save_triage(self):
121126
def click_check_consent_responses(self):
122127
self.po.perform_action(locator=self.BTN_CHECK_CONSENT_RESPONSES, action=actions.CLICK_LINK)
123128

124-
def click_give_gillick_consent(self):
125-
self.po.perform_action(locator=self.LNK_GIVE_GILLICK_CONSENT, action=actions.CLICK_LINK)
129+
def click_assess_gillick_competent(self):
130+
self.po.perform_action(locator=self.LNK_ASSESS_GILLICK_COMPETENT, action=actions.CLICK_LINK)
126131

127-
def __set_gillick_consent(self, is_competent: bool, competency_details: str) -> None:
128-
_expected_text = f"Gillick assessment Are they Gillick competent?Yes, they are Gillick competent Details of your assessment{competency_details}"
129-
self.po.perform_action(locator=self.LNK_GIVE_GILLICK_CONSENT, action=actions.CLICK_BUTTON)
132+
def click_edit_gillick_competence(self):
133+
self.po.perform_action(locator=self.LNK_EDIT_GILLICK_COMPETENCE, action=actions.CLICK_LINK)
134+
135+
def add_gillick_competence(self, is_competent: bool, competence_details: str) -> None:
136+
self.__set_gillick_consent(is_add=True, is_competent=is_competent, competence_details=competence_details)
137+
138+
def edit_gillick_competence(self, is_competent: bool, competence_details: str) -> None:
139+
self.__set_gillick_consent(is_add=False, is_competent=is_competent, competence_details=competence_details)
140+
141+
def __set_gillick_consent(self, is_add: bool, is_competent: bool, competence_details: str) -> None:
130142
if is_competent:
131-
self.po.perform_action(locator=self.RDO_YES_GILLICK_COMPETENT, action=actions.RADIO_BUTTON_SELECT)
143+
self.po.perform_action(
144+
locator="get_by_role('group', name='The child knows which vaccination they will have').get_by_label('Yes').check()",
145+
action=actions.CHAIN_LOCATOR_ACTION,
146+
)
147+
self.po.perform_action(
148+
locator="get_by_role('group', name='The child knows which disease').get_by_label('Yes').check()",
149+
action=actions.CHAIN_LOCATOR_ACTION,
150+
)
151+
self.po.perform_action(
152+
locator="get_by_role('group', name='The child knows what could').get_by_label('Yes').check()",
153+
action=actions.CHAIN_LOCATOR_ACTION,
154+
)
155+
self.po.perform_action(
156+
locator="get_by_role('group', name='The child knows how the').get_by_label('Yes').check()",
157+
action=actions.CHAIN_LOCATOR_ACTION,
158+
)
159+
self.po.perform_action(
160+
locator="get_by_role('group', name='The child knows which side').get_by_label('Yes').check()",
161+
action=actions.CHAIN_LOCATOR_ACTION,
162+
)
132163
else:
133-
self.po.perform_action(locator=self.RDO_NO_GILLICK_COMPETENT, action=actions.RADIO_BUTTON_SELECT)
134-
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
135-
if is_competent:
136164
self.po.perform_action(
137-
locator=self.TXT_GILLICK_ASSESSMENT_DETAILS, action=actions.FILL, value=competency_details
165+
locator="get_by_role('group', name='The child knows which vaccination they will have').get_by_label('No').check()",
166+
action=actions.CHAIN_LOCATOR_ACTION,
138167
)
139-
self.po.perform_action(locator=self.BTN_CONTINUE, action=actions.CLICK_BUTTON)
140-
self.po.perform_action(locator=self.BTN_SAVE_CHANGES, action=actions.CLICK_BUTTON)
141-
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value=_expected_text, exact=False)
168+
self.po.perform_action(
169+
locator="get_by_role('group', name='The child knows which disease').get_by_label('No').check()",
170+
action=actions.CHAIN_LOCATOR_ACTION,
171+
)
172+
self.po.perform_action(
173+
locator="get_by_role('group', name='The child knows what could').get_by_label('No').check()",
174+
action=actions.CHAIN_LOCATOR_ACTION,
175+
)
176+
self.po.perform_action(
177+
locator="get_by_role('group', name='The child knows how the').get_by_label('No').check()",
178+
action=actions.CHAIN_LOCATOR_ACTION,
179+
)
180+
self.po.perform_action(
181+
locator="get_by_role('group', name='The child knows which side').get_by_label('No').check()",
182+
action=actions.CHAIN_LOCATOR_ACTION,
183+
)
184+
self.po.perform_action(
185+
locator=self.TXT_GILLICK_ASSESSMENT_DETAILS, action=actions.FILL, value=competence_details
186+
)
187+
if is_add:
188+
self.po.perform_action(locator=self.BTN_COMPLETE_GILLICK_ASSESSMENT, action=actions.CLICK_BUTTON)
189+
else:
190+
self.po.perform_action(locator=self.BTN_UPDATE_GILLICK_ASSESSMENT, action=actions.CLICK_BUTTON)
191+
if is_competent:
192+
self.po.verify(
193+
locator=self.LBL_MAIN, property=object_properties.TEXT, value=self.LBL_CHILD_COMPETENT, exact=False
194+
)
195+
else:
196+
self.po.verify(
197+
locator=self.LBL_MAIN, property=object_properties.TEXT, value=self.LBL_CHILD_NOT_COMPETENT, exact=False
198+
)
199+
self.po.verify(locator=self.LBL_MAIN, property=object_properties.TEXT, value=competence_details, exact=False)
142200

143201
def schedule_session(self, future_date: str, expect_error: bool = False):
144202
_day = future_date[-2:]
@@ -189,6 +247,14 @@ def verify_scheduled_date(self, message: str):
189247
def click_get_consent_responses(self):
190248
self.po.perform_action(locator=self.BTN_GET_CONSENT_RESPONSES, action=actions.CLICK_BUTTON)
191249

250+
def upload_valid_class_list(self, file_paths: str):
251+
_input_file_path, _ = self.tdo.split_file_paths(file_paths=file_paths)
252+
self.click_scheduled()
253+
self.click_school1()
254+
self.click_import_class_list()
255+
self.choose_file_child_records(file_path=_input_file_path)
256+
self.click_continue()
257+
192258
def update_triage_outcome_positive(self, file_paths):
193259
_input_file_path, _ = self.tdo.split_file_paths(file_paths=file_paths)
194260
self.click_scheduled()
@@ -218,8 +284,8 @@ def update_triage_outcome_positive(self, file_paths):
218284
self.click_activity_log()
219285
self.verify_activity_log_entry()
220286

221-
def schedule_a_valid_session(self):
222-
_future_date = get_future_date(offset_days=10)
287+
def schedule_a_valid_session(self, for_today: bool = False):
288+
_future_date = get_future_date(offset_days=0) if for_today else get_future_date(offset_days=10)
223289
_expected_message = f"Session dates {self.__get_display_formatted_date(date_to_format=_future_date)}"
224290
self.click_unscheduled()
225291
self.click_school1()
@@ -258,10 +324,12 @@ def upload_invalid_class_list_records(self, file_paths: str):
258324
self.click_continue()
259325
self.verify_upload_output(file_path=_output_file_path)
260326

261-
def set_gillick_competency_for_student(self):
327+
def set_gillick_competence_for_student(self):
262328
self.click_today()
263329
self.click_school1()
264330
self.click_check_consent_responses()
265331
self.click_child_full_name()
266-
self.click_give_gillick_consent()
267-
self.__set_gillick_consent(is_competent=True, competency_details="Gillick competent")
332+
self.click_assess_gillick_competent()
333+
self.add_gillick_competence(is_competent=True, competence_details="Gillick competent")
334+
self.click_edit_gillick_competence()
335+
self.edit_gillick_competence(is_competent=False, competence_details="Not Gillick competent")

tests/test_10_consent.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from libs.constants import test_data_file_paths
34
from pages import pg_dashboard, pg_login, pg_parental_consent, pg_sessions
45
from tests.helpers import parental_consent_helper
56

@@ -11,6 +12,21 @@ class Test_Regression_Consent:
1112
dashboard_page = pg_dashboard.pg_dashboard()
1213
sessions_page = pg_sessions.pg_sessions()
1314

15+
@pytest.fixture()
16+
def create_session(self, start_mavis: None):
17+
self.login_page.perform_valid_login()
18+
self.dashboard_page.click_sessions()
19+
self.sessions_page.schedule_a_valid_session(for_today=True)
20+
self.dashboard_page.go_to_dashboard()
21+
self.dashboard_page.click_sessions()
22+
self.sessions_page.upload_valid_class_list(file_paths=test_data_file_paths.COHORTS_POSITIVE)
23+
self.dashboard_page.go_to_dashboard()
24+
self.dashboard_page.click_sessions()
25+
yield
26+
self.dashboard_page.go_to_dashboard()
27+
self.dashboard_page.click_sessions()
28+
self.sessions_page.delete_all_sessions()
29+
1430
@pytest.mark.consent
1531
@pytest.mark.mobile
1632
@pytest.mark.order(1001)
@@ -22,7 +38,5 @@ def test_reg_parental_consent_workflow(self, start_consent_workflow, scenario_da
2238
@pytest.mark.consent
2339
@pytest.mark.mobile
2440
@pytest.mark.order(1002)
25-
def test_reg_gillick_consent(self, start_mavis):
26-
self.login_page.perform_valid_login()
27-
self.dashboard_page.click_sessions()
28-
self.sessions_page.set_gillick_competency_for_student()
41+
def test_reg_gillick_competence(self, create_session):
42+
self.sessions_page.set_gillick_competence_for_student()

0 commit comments

Comments
 (0)