Skip to content

Commit 1e83e6f

Browse files
committed
moved helper methods from test file into relevant utils
1 parent 5d060ac commit 1e83e6f

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from playwright.sync_api import Page, expect, Locator
22
from pages.base_page import BasePage
33
from datetime import datetime
4+
from pages.communication_production.communications_production_page import CommunicationsProductionPage
45
from utils.calendar_picker import CalendarPicker
56
from utils.table_util import TableUtils
67
import logging
@@ -204,6 +205,17 @@ def select_first_batch_row(self, table_selector: str, timeout_ms: int = 0) -> No
204205
), f"No batch links found in table '{table_selector}'"
205206
first_link.click()
206207

208+
def navigate_to_active_batch_list_page(self) -> None:
209+
"""
210+
Navigates to the active batch list page from anywhere in bcss (providing the main menu link is displayed).
211+
212+
Args:
213+
page (Page): The Playwright page object.
214+
"""
215+
BasePage(self.page).click_main_menu_link()
216+
BasePage(self.page).go_to_communications_production_page()
217+
CommunicationsProductionPage(self.page).go_to_active_batch_list_page()
218+
207219

208220
class ActiveBatchListPage(BatchListPage):
209221
"""Active Batch List Page-specific methods."""

tests/regression/regression_tests/fobt_regression_tests/test_scenario_2.py

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,7 @@
2121
)
2222
from pages.fit_test_kits.log_devices_page import LogDevicesPage
2323
from pages.fit_test_kits.fit_test_kits_page import FITTestKitsPage
24-
25-
26-
# Helper function to navigate to subject profile
27-
def navigate_to_subject_summary_page(page, nhs_no: str) -> None:
28-
"""
29-
Navigates to the subject profile in the UI using the NHS number.
30-
31-
Args:
32-
page (Page): The Playwright page object.
33-
nhs_no (str): The NHS number of the subject to search.
34-
"""
35-
BasePage(page).click_main_menu_link()
36-
BasePage(page).go_to_screening_subject_search_page()
37-
screening_subject_page_searcher.search_subject_by_nhs_number(page, nhs_no)
38-
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
39-
40-
41-
# Helper function to navigate to active batch list
42-
def navigate_to_active_batch_list(page: Page) -> None:
43-
"""
44-
Navigates to the active batch list page in the UI.
45-
46-
Args:
47-
page (Page): The Playwright page object.
48-
"""
49-
BasePage(page).click_main_menu_link()
50-
BasePage(page).go_to_communications_production_page()
51-
CommunicationsProductionPage(page).go_to_active_batch_list_page()
24+
from pages.communication_production.batch_list_page import BatchListPage
5225

5326

5427
# Helper function to log FIT kit
@@ -128,7 +101,7 @@ def test_scenario_2(page: Page) -> None:
128101
logging.info("[DB ASSERTIONS COMPLETE] Created subject's details checked in the DB")
129102

130103
# Navigate to subject summary page in UI
131-
navigate_to_subject_summary_page(page, nhs_no)
104+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
132105
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
133106

134107
# Assert subject details in the UI
@@ -158,7 +131,7 @@ def test_scenario_2(page: Page) -> None:
158131
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
159132

160133
# Navigate to subject summary page in UI
161-
navigate_to_subject_summary_page(page, nhs_no)
134+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
162135
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
163136

164137
# Assert subject details in the UI
@@ -181,7 +154,7 @@ def test_scenario_2(page: Page) -> None:
181154
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
182155

183156
# Then there is a "S1" letter batch for my subject with the exact title "Pre-invitation (FIT)"
184-
navigate_to_active_batch_list(page)
157+
BatchListPage(page).navigate_to_active_batch_list_page()
185158
ActiveBatchListPage(page).is_batch_present("S1 - Pre-invitation (FIT)")
186159
logging.info("[UI ASSERTIONS COMPLETE] S1 Letter batch exists")
187160

@@ -191,15 +164,14 @@ def test_scenario_2(page: Page) -> None:
191164
page, "S1", "Pre-invitation (FIT)", "S9 - Pre-invitation Sent", True
192165
)
193166
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
167+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
194168

195169
# Navigate to subject summary page in UI
196170
# navigate_to_subject_summary_page(page, nhs_no)
197171
# logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
198172

199173
# Assert subject details in the UI
200174
# summary_page.assert_latest_event_status("S9 - Pre-invitation Sent")
201-
# logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
202-
# logging.info("[DEBUG TEST PASSED]")
203175

204176
# When I run Timed Events for my subject
205177
# nhs_df = pd.DataFrame(
@@ -248,7 +220,7 @@ def test_scenario_2(page: Page) -> None:
248220
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
249221

250222
# Navigate to subject summary page in UI
251-
navigate_to_subject_summary_page(page, nhs_no)
223+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
252224
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
253225

254226
# Assert subject details in the UI
@@ -270,15 +242,15 @@ def test_scenario_2(page: Page) -> None:
270242
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
271243

272244
# Navigate to subject summary page in UI
273-
navigate_to_subject_summary_page(page, nhs_no)
245+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
274246
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
275247

276248
# Assert subject details in the UI
277249
summary_page.assert_latest_event_status("S2 - Normal")
278250
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
279251

280252
# And there is a "S2" letter batch for my subject with the exact title "Subject Result (Normal)"
281-
navigate_to_active_batch_list(page)
253+
BatchListPage(page).navigate_to_active_batch_list_page()
282254
ActiveBatchListPage(page).is_batch_present("S2 - Subject Result (Normal)")
283255
logging.info("[UI ASSERTIONS COMPLETE] S2 Letter batch exists")
284256

@@ -302,15 +274,15 @@ def test_scenario_2(page: Page) -> None:
302274
# logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
303275

304276
# Navigate to subject summary page in UI
305-
navigate_to_subject_summary_page(page, nhs_no)
277+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
306278
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
307279

308280
# Assert subject details in the UI
309281
summary_page.assert_latest_event_status("S158 - Subject Discharge Sent (Normal)")
310282
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
311283

312284
# And there is a "S158" letter batch for my subject with the exact title "GP Result (Normal)"
313-
navigate_to_active_batch_list(page)
285+
BatchListPage(page).navigate_to_active_batch_list_page()
314286
ActiveBatchListPage(page).is_batch_present("S158 - GP Result (Normal)")
315287
logging.info("[UI ASSERTIONS COMPLETE] S158 Letter batch exists")
316288

@@ -357,7 +329,7 @@ def test_scenario_2(page: Page) -> None:
357329
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
358330

359331
# Navigate to subject summary page in UI
360-
navigate_to_subject_summary_page(page, nhs_no)
332+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
361333
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
362334

363335
# Assert subject details in the UI

utils/screening_subject_page_searcher.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
SubjectScreeningSummaryPage,
88
)
99
from playwright.sync_api import Page, expect
10+
import logging
1011

1112

1213
def verify_subject_event_status_by_nhs_no(
@@ -233,3 +234,18 @@ def search_subject_episode_by_nhs_number(page: Page, nhs_number: str) -> None:
233234
SearchAreaSearchOptions.SEARCH_AREA_WHOLE_DATABASE.value
234235
)
235236
SubjectScreeningPage(page).click_search_button()
237+
238+
239+
def navigate_to_subject_summary_page(page, nhs_no: str) -> None:
240+
"""
241+
Navigates to the subject summary page in the UI using the given NHS number.
242+
This method can be used from anywhere in bcss providing the main menu link is displayed.
243+
244+
Args:
245+
page (Page): The Playwright page object.
246+
nhs_no (str): The NHS number of the subject to view.
247+
"""
248+
BasePage(page).click_main_menu_link()
249+
BasePage(page).go_to_screening_subject_search_page()
250+
search_subject_by_nhs_number(page, nhs_no)
251+
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")

0 commit comments

Comments
 (0)