Skip to content

Commit 54be725

Browse files
committed
wip
1 parent 142f5bf commit 54be725

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

tests/regression/regression_tests/fobt_regression_tests/test_scenario_2.py

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
from utils.call_and_recall_utils import CallAndRecallUtils
1111
from utils import screening_subject_page_searcher
1212
from utils.batch_processing import batch_processing
13+
from utils.fit_kit import FitKitGeneration, FitKitLogged
14+
from utils.oracle.oracle import OracleDB
1315
from pages.base_page import BasePage
1416
from pages.screening_subject_search.subject_screening_summary_page import (
1517
SubjectScreeningSummaryPage,
1618
)
1719
from pages.communication_production.communications_production_page import (
1820
CommunicationsProductionPage,
1921
)
20-
from utils.oracle.oracle import OracleDB
22+
from pages.fit_test_kits.log_devices_page import LogDevicesPage
23+
from pages.fit_test_kits.fit_test_kits_page import FITTestKitsPage
2124

2225

2326
# Helper function to navigate to subject profile
24-
def navigate_to_subject_profile(page, nhs_no: str) -> None:
27+
def navigate_to_subject_summary_page(page, nhs_no: str) -> None:
2528
"""
2629
Navigates to the subject profile in the UI using the NHS number.
2730
@@ -32,7 +35,7 @@ def navigate_to_subject_profile(page, nhs_no: str) -> None:
3235
BasePage(page).click_main_menu_link()
3336
BasePage(page).go_to_screening_subject_search_page()
3437
screening_subject_page_searcher.search_subject_by_nhs_number(page, nhs_no)
35-
logging.info("[SUBJECT VIEW] Subject loaded in UI")
38+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
3639

3740

3841
# Helper function to navigate to active batch list
@@ -48,6 +51,26 @@ def navigate_to_active_batch_list(page: Page) -> None:
4851
CommunicationsProductionPage(page).go_to_active_batch_list_page()
4952

5053

54+
# Helper function to log FIT kit
55+
def log_fit_kit(page: Page, nhs_no: str) -> str:
56+
BasePage(page).click_main_menu_link()
57+
fit_kit = FitKitGeneration().get_fit_kit_for_subject_sql(nhs_no, False, False)
58+
BasePage(page).go_to_fit_test_kits_page()
59+
FITTestKitsPage(page).go_to_log_devices_page()
60+
logging.info(f"Logging FIT Device ID: {fit_kit}")
61+
LogDevicesPage(page).fill_fit_device_id_field(fit_kit)
62+
sample_date = datetime.datetime.now()
63+
logging.info(f"Setting sample date to {sample_date}")
64+
LogDevicesPage(page).fill_sample_date_field(sample_date)
65+
LogDevicesPage(page).log_devices_title.get_by_text("Scan Device").wait_for()
66+
try:
67+
LogDevicesPage(page).verify_successfully_logged_device_text()
68+
logging.info(f"{fit_kit} Successfully logged")
69+
except Exception as e:
70+
pytest.fail(f"{fit_kit} unsuccessfully logged: {str(e)}")
71+
return fit_kit
72+
73+
5174
@pytest.mark.wip
5275
@pytest.mark.fobt_regression_tests
5376
def test_scenario_2(page: Page) -> None:
@@ -109,8 +132,9 @@ def test_scenario_2(page: Page) -> None:
109132
)
110133
logging.info("[DB ASSERTIONS COMPLETE]Created subject's details checked in the DB")
111134

112-
# Navigate to subject profile in UI
113-
navigate_to_subject_profile(page, nhs_no)
135+
# Navigate to subject summary page in UI
136+
navigate_to_subject_summary_page(page, nhs_no)
137+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
114138

115139
# Assert subject details in the UI
116140
summary_page.assert_subject_age(66)
@@ -138,8 +162,9 @@ def test_scenario_2(page: Page) -> None:
138162
)
139163
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
140164

141-
# Navigate to subject profile in UI
142-
navigate_to_subject_profile(page, nhs_no)
165+
# Navigate to subject summary page in UI
166+
navigate_to_subject_summary_page(page, nhs_no)
167+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
143168

144169
# Assert subject details in the UI
145170
summary_page.assert_screening_status("Call")
@@ -171,8 +196,9 @@ def test_scenario_2(page: Page) -> None:
171196
)
172197
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
173198

174-
# Navigate to subject profile in UI
175-
navigate_to_subject_profile(page, nhs_no)
199+
# Navigate to subject summary page in UI
200+
navigate_to_subject_summary_page(page, nhs_no)
201+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
176202

177203
# Assert subject details in the UI
178204
summary_page.assert_latest_event_status("S9 Pre-invitation Sent")
@@ -212,7 +238,8 @@ def test_scenario_2(page: Page) -> None:
212238
)
213239
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
214240

215-
# TODO: When I log my subject's latest unlogged FIT kit
241+
# When I log my subject's latest unlogged FIT kit
242+
fit_kit = log_fit_kit(page, nhs_no)
216243

217244
# Then my subject has been updated as follows:
218245
subject_assertion(
@@ -223,16 +250,18 @@ def test_scenario_2(page: Page) -> None:
223250
)
224251
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
225252

226-
# Navigate to subject profile in UI
227-
navigate_to_subject_profile(page, nhs_no)
253+
# Navigate to subject summary page in UI
254+
navigate_to_subject_summary_page(page, nhs_no)
255+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
228256

229257
# Assert subject details in the UI
230258
summary_page.assert_latest_event_status(
231259
"S43 Kit Returned and Logged (Initial Test)"
232260
)
233261
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
234262

235-
# TODO: When I read my subject's latest logged FIT kit as "NORMAL"
263+
# When I read my subject's latest logged FIT kit as "NORMAL"
264+
FitKitLogged().read_latest_logged_kit(user_role, 2, fit_kit, "NORMAL")
236265

237266
# Then my subject has been updated as follows:
238267
subject_assertion(
@@ -243,8 +272,9 @@ def test_scenario_2(page: Page) -> None:
243272
)
244273
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
245274

246-
# Navigate to subject profile in UI
247-
navigate_to_subject_profile(page, nhs_no)
275+
# Navigate to subject summary page in UI
276+
navigate_to_subject_summary_page(page, nhs_no)
277+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
248278

249279
# Assert subject details in the UI
250280
summary_page.assert_latest_event_status("S2 Normal")
@@ -268,8 +298,9 @@ def test_scenario_2(page: Page) -> None:
268298
)
269299
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
270300

271-
# Navigate to subject profile in UI
272-
navigate_to_subject_profile(page, nhs_no)
301+
# Navigate to subject summary page in UI
302+
navigate_to_subject_summary_page(page, nhs_no)
303+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
273304

274305
# Assert subject details in the UI
275306
summary_page.assert_latest_event_status("S158 Subject Discharge Sent (Normal)")
@@ -322,8 +353,9 @@ def test_scenario_2(page: Page) -> None:
322353
)
323354
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
324355

325-
# Navigate to subject profile in UI
326-
navigate_to_subject_profile(page, nhs_no)
356+
# Navigate to subject summary page in UI
357+
navigate_to_subject_summary_page(page, nhs_no)
358+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
327359

328360
# Assert subject details in the UI
329361
summary_page.assert_latest_event_status("S159 GP Discharge Sent (Normal)")

0 commit comments

Comments
 (0)