77from utils .subject_assertion import subject_assertion
88from utils .call_and_recall_utils import CallAndRecallUtils
99from utils import screening_subject_page_searcher
10+ from utils .batch_processing import batch_processing
1011from pages .base_page import BasePage
1112from pages .screening_subject_search .subject_screening_summary_page import (
1213 SubjectScreeningSummaryPage ,
@@ -22,6 +23,8 @@ def navigate_to_subject_profile(page, nhs_no: str) -> None:
2223 page (Page): The Playwright page object.
2324 nhs_no (str): The NHS number of the subject to search.
2425 """
26+ BasePage (page ).click_main_menu_link ()
27+ BasePage (page ).go_to_screening_subject_search_page ()
2528 screening_subject_page_searcher .search_subject_by_nhs_number (page , nhs_no )
2629 logging .info ("[SUBJECT VIEW] Subject loaded in UI" )
2730
@@ -54,7 +57,11 @@ def test_scenario_2(page: Page) -> None:
5457 logging .info ("[TEST START] Regression - fobt normal kit reading" )
5558
5659 # Given I log in to BCSS "England" as user role "Hub Manager"
57- UserTools .user_login (page , "Hub Manager State Registered at BCS01" )
60+ user_role = UserTools .user_login (
61+ page , "Hub Manager State Registered at BCS01" , return_role_type = True
62+ )
63+ if user_role is None :
64+ raise ValueError ("User cannot be assigned to a UserRoleType" )
5865
5966 # Go to screening subject search page
6067 base_page = BasePage (page )
@@ -77,12 +84,12 @@ def test_scenario_2(page: Page) -> None:
7784 subject_assertion (
7885 nhs_no ,
7986 {
80- "age (y/d) " : "66/130 " ,
87+ "subject age " : "66" ,
8188 "subject has episodes" : "No" ,
8289 "screening status" : "Inactive" ,
8390 },
8491 )
85- logging .info ("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB" )
92+ logging .info ("[DB ASSERTIONS COMPLETE]Created subject's details checked in the DB" )
8693
8794 # Navigate to subject profile in UI
8895 navigate_to_subject_profile (page , nhs_no )
@@ -121,6 +128,7 @@ def test_scenario_2(page: Page) -> None:
121128 logging .info ("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI" )
122129
123130 # When I invite my subject for FOBT screening
131+ CallAndRecallUtils ().invite_subject_for_fobt_screening (nhs_no , user_role )
124132
125133 # Then my subject has been updated as follows:
126134 subject_assertion (
@@ -131,21 +139,21 @@ def test_scenario_2(page: Page) -> None:
131139 "latest episode type" : "FOBT" ,
132140 },
133141 )
142+ logging .info (
143+ "[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB"
144+ )
134145 # Then there is a "S1" letter batch for my subject with the exact title "Pre-invitation (FIT)"
146+ LetterBatchUtils ().assert_letter_batch_exists (nhs_no , "S1" , "Pre-invitation (FIT)" )
135147 logging .info (
136- "[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB & letter batch exists"
148+ "[ASSERTIONS COMPLETE]S1 Letter batch exists"
137149 )
138150
139151 # When I process the open "S1" letter batch for my subject
140-
141152 # Then my subject has been updated as follows:
142- subject_assertion (
143- nhs_no ,
144- {
145- "latest event status" : "S9 Pre-invitation Sent" ,
146- },
153+ batch_processing (
154+ page , "S1" , "Pre-invitation (FIT)" , "S9 - Pre-invitation Sent" , True
147155 )
148- logging .info ("[ASSERTIONS COMPLETE]Updated subject status checked in the DB" )
156+ logging .info ("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB" )
149157
150158 # Navigate to subject profile in UI
151159 navigate_to_subject_profile (page , nhs_no )
@@ -158,14 +166,16 @@ def test_scenario_2(page: Page) -> None:
158166 # Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
159167
160168 # When I process the open "S9" letter batch for my subject
161-
162169 # Then my subject has been updated as follows:
163- subject_assertion (
164- nhs_no ,
165- {
166- "latest event status" : "S10 Invitation & Test Kit Sent" ,
167- },
170+ batch_processing (
171+ page ,
172+ "S9" ,
173+ "Invitation & Test Kit (FIT)" ,
174+ "S10 - Invitation & Test Kit Sent" ,
175+ True ,
168176 )
177+ logging .info ("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB" )
178+
169179 # When I log my subject's latest unlogged FIT kit
170180
171181 # Then my subject has been updated as follows:
@@ -230,29 +240,29 @@ def test_scenario_2(page: Page) -> None:
230240 nhs_no ,
231241 {
232242 "calculated screening due date" : "2 years from latest S158 event" ,
233- "calculated lynch due date" : None ,
234- "calculated surveillance due date" : None ,
235- "ceased confirmation date" : None ,
236- "ceased confirmation details" : None ,
237- "ceased confirmation user ID" : None ,
238- "clinical reason for cease" : None ,
243+ "calculated lynch due date" : "Null" ,
244+ "calculated surveillance due date" : "Null" ,
245+ "ceased confirmation date" : "Null" ,
246+ "ceased confirmation details" : "Null" ,
247+ "ceased confirmation user ID" : "Null" ,
248+ "clinical reason for cease" : "Null" ,
239249 "latest episode accumulated result" : "Definitive normal FOBt outcome" ,
240250 "latest episode recall calculation method" : "Date of last patient letter" ,
241251 "latest episode recall episode type" : "FOBT screening" ,
242- "latest episode recall surveillance type" : None ,
252+ "latest episode recall surveillance type" : "Null" ,
243253 "latest episode status" : "Closed" ,
244254 "latest episode status reason" : "Episode Complete" ,
245255 "latest event status" : "S159 GP Discharge Sent (Normal)" ,
246- "lynch due date" : None ,
247- "lynch due date date of change" : None ,
248- "lynch due date reason" : None ,
256+ "lynch due date" : "Null" ,
257+ "lynch due date date of change" : "Null" ,
258+ "lynch due date reason" : "Null" ,
249259 "screening status" : "Recall" ,
250260 # 'Screening status date of change' intentionally omitted as status may or may not have changed
251261 "screening status reason" : "Recall" ,
252262 "screening due date" : "Calculated screening due date" ,
253263 "screening due date date of change" : "Today" ,
254264 "screening due date reason" : "Recall" ,
255- "surveillance due date" : None ,
265+ "surveillance due date" : "Null" ,
256266 "surveillance due date date of change" : "Unchanged" ,
257267 "surveillance due date reason" : "Unchanged" ,
258268 },
0 commit comments