Skip to content

Commit 8e70efb

Browse files
committed
Merge branch 'recovery-fix' into feature/BCSS-21304-selenium0to-playwright-fobtregressiontests-scenario-2
# Conflicts: # tests/regression/regression_tests/test_fobt_regression_tests.py # utils/fit_kit.py
2 parents 2d4800d + fb0bd59 commit 8e70efb

File tree

8 files changed

+142
-347
lines changed

8 files changed

+142
-347
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
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 (
5+
CommunicationsProductionPage,
6+
)
47
from utils.calendar_picker import CalendarPicker
58
from utils.table_util import TableUtils
69
import logging
@@ -204,6 +207,17 @@ def select_first_batch_row(self, table_selector: str, timeout_ms: int = 0) -> No
204207
), f"No batch links found in table '{table_selector}'"
205208
first_link.click()
206209

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

208222
class ActiveBatchListPage(BatchListPage):
209223
"""Active Batch List Page-specific methods."""
@@ -216,7 +230,10 @@ def select_first_active_batch(self) -> None:
216230
self.select_first_batch_row(self.table_selector, timeout_ms=10000)
217231

218232
def is_batch_present(self, batch_type: str) -> bool:
219-
"""Checks if a batch of the given type exists in the active batch list."""
233+
"""Checks if a batch of the given type exists in the active batch list.
234+
Args:
235+
batch_type (str): The type of the batch to check for e.g. "S1 - Pre-invitation (FIT)"
236+
"""
220237
locator = self.page.locator(
221238
f"{self.table_selector} tbody tr td", has_text=batch_type
222239
)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def navigate_to_spine_search(self) -> None:
331331
Navigates to the Spine Search screen by clicking the appropriate link
332332
and loading the target URL.
333333
"""
334-
#self.retrieve_data_link.click()
334+
# self.retrieve_data_link.click()
335335
self.click(self.retrieve_data_link)
336336
self.page.goto(self.spine_url)
337337

@@ -377,15 +377,17 @@ def assert_latest_event_status(self, expected_status: str) -> None:
377377
Asserts that the latest event status displayed in the summary table matches the expected value.
378378
379379
Args:
380-
expected_status (str): The expected event status (e.g., 'S9 Pre-invitation Sent').
380+
expected_status (str): The expected event status (e.g., 'S9 - Pre-invitation Sent').
381381
382382
Raises:
383383
AssertionError: If the status in the UI does not match the expected value.
384384
"""
385-
actual_status = self.latest_event_status_cell.inner_text().strip()
386-
assert actual_status == expected_status, (
387-
f"[LATEST EVENT STATUS MISMATCH] Expected '{expected_status}', but found '{actual_status}' in UI."
388-
)
385+
cell = self.get_latest_event_status_cell(expected_status)
386+
actual_status = cell.inner_text().strip()
387+
assert (
388+
actual_status == expected_status
389+
), f"[LATEST EVENT STATUS MISMATCH] Expected '{expected_status}', but found '{actual_status}' in UI."
390+
389391

390392
class ChangeScreeningStatusOptions(Enum):
391393
"""Enum for Change Screening Status options."""
Lines changed: 64 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
import logging
33
import datetime
4-
import pandas as pd
54
from playwright.sync_api import Page
65
from pages.communication_production.batch_list_page import ActiveBatchListPage
76
from utils.oracle.subject_creation_util import CreateSubjectSteps
@@ -10,42 +9,11 @@
109
from utils.call_and_recall_utils import CallAndRecallUtils
1110
from utils import screening_subject_page_searcher
1211
from utils.batch_processing import batch_processing
13-
from pages.base_page import BasePage
12+
from utils.fit_kit import FitKitLogged
1413
from pages.screening_subject_search.subject_screening_summary_page import (
1514
SubjectScreeningSummaryPage,
1615
)
17-
from pages.communication_production.communications_production_page import (
18-
CommunicationsProductionPage,
19-
)
20-
from utils.oracle.oracle import OracleDB
21-
22-
23-
# Helper function to navigate to subject profile
24-
def navigate_to_subject_profile(page, nhs_no: str) -> None:
25-
"""
26-
Navigates to the subject profile in the UI using the NHS number.
27-
28-
Args:
29-
page (Page): The Playwright page object.
30-
nhs_no (str): The NHS number of the subject to search.
31-
"""
32-
BasePage(page).click_main_menu_link()
33-
BasePage(page).go_to_screening_subject_search_page()
34-
screening_subject_page_searcher.search_subject_by_nhs_number(page, nhs_no)
35-
logging.info("[SUBJECT VIEW] Subject loaded in UI")
36-
37-
38-
# Helper function to navigate to active batch list
39-
def navigate_to_active_batch_list(page: Page) -> None:
40-
"""
41-
Navigates to the active batch list page in the UI.
42-
43-
Args:
44-
page (Page): The Playwright page object.
45-
"""
46-
BasePage(page).click_main_menu_link()
47-
BasePage(page).go_to_communications_production_page()
48-
CommunicationsProductionPage(page).go_to_active_batch_list_page()
16+
from pages.communication_production.batch_list_page import BatchListPage
4917

5018

5119
@pytest.mark.wip
@@ -81,11 +49,6 @@ def test_scenario_2(page: Page) -> None:
8149
if user_role is None:
8250
raise ValueError("User cannot be assigned to a UserRoleType")
8351

84-
# Go to screening subject search page
85-
base_page = BasePage(page)
86-
base_page.click_main_menu_link()
87-
base_page.go_to_screening_subject_search_page()
88-
8952
# And I create a subject that meets the following criteria:
9053
requirements = {
9154
"age (y/d)": "66/130",
@@ -107,19 +70,19 @@ def test_scenario_2(page: Page) -> None:
10770
"screening status": "Inactive",
10871
},
10972
)
110-
logging.info("[DB ASSERTIONS COMPLETE]Created subject's details checked in the DB")
73+
logging.info("[DB ASSERTIONS COMPLETE] Created subject details checked in the DB")
11174

112-
# Navigate to subject profile in UI
113-
navigate_to_subject_profile(page, nhs_no)
75+
# Navigate to subject summary page in UI
76+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
11477

11578
# Assert subject details in the UI
11679
summary_page.assert_subject_age(66)
11780
summary_page.assert_screening_status("Inactive")
118-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
81+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
11982

12083
# When I run the FOBT failsafe trawl for my subject
12184
CallAndRecallUtils().run_failsafe(nhs_no)
122-
logging.info(f"[FAILSAFE TRAWL RUN]FOBT failsafe trawl run for subject {nhs_no}")
85+
logging.info(f"[FAILSAFE TRAWL RUN] FOBT failsafe trawl run for subject {nhs_no}")
12386

12487
# Then my subject has been updated as follows:
12588
today = datetime.datetime.now().strftime("%d/%m/%Y")
@@ -136,14 +99,14 @@ def test_scenario_2(page: Page) -> None:
13699
"Screening Status Reason": "Failsafe Trawl",
137100
},
138101
)
139-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
102+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
140103

141-
# Navigate to subject profile in UI
142-
navigate_to_subject_profile(page, nhs_no)
104+
# Navigate to subject summary page in UI
105+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
143106

144107
# Assert subject details in the UI
145108
summary_page.assert_screening_status("Call")
146-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
109+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
147110

148111
# When I invite my subject for FOBT screening
149112
CallAndRecallUtils().invite_subject_for_fobt_screening(nhs_no, user_role)
@@ -157,40 +120,29 @@ def test_scenario_2(page: Page) -> None:
157120
"latest episode type": "FOBT",
158121
},
159122
)
160-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
123+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
161124

162125
# Then there is a "S1" letter batch for my subject with the exact title "Pre-invitation (FIT)"
163-
navigate_to_active_batch_list(page)
126+
BatchListPage(page).navigate_to_active_batch_list_page()
164127
ActiveBatchListPage(page).is_batch_present("S1 - Pre-invitation (FIT)")
165-
logging.info("[ASSERTIONS COMPLETE]S1 Letter batch exists")
128+
logging.info("[UI ASSERTIONS COMPLETE] S1 Letter batch exists")
166129

167130
# When I process the open "S1" letter batch for my subject
168-
# Then my subject has been updated as follows:
131+
# Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
169132
batch_processing(
170133
page, "S1", "Pre-invitation (FIT)", "S9 - Pre-invitation Sent", True
171134
)
172-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
173-
174-
# Navigate to subject profile in UI
175-
navigate_to_subject_profile(page, nhs_no)
135+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
136+
logging.info("[UI ASSERTIONS COMPLETE] S9 Letter batch exists")
176137

177-
# Assert subject details in the UI
178-
summary_page.assert_latest_event_status("S9 Pre-invitation Sent")
179-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
180-
181-
# When I run Timed Events for my subject
182-
nhs_df = pd.DataFrame(
183-
{"subject_nhs_number": [nhs_no]}
184-
) # Create DataFrame with NHS number to pass to timed events procedure
185-
OracleDB().exec_bcss_timed_events(
186-
nhs_df
187-
) # Execute timed events procedure to process the subject
188-
logging.info("[TIMED EVENTS] Executed for existing subject")
189-
190-
# Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
191-
navigate_to_active_batch_list(page)
192-
ActiveBatchListPage(page).is_batch_present("S9 - Invitation & Test Kit (FIT)")
193-
logging.info("[ASSERTIONS COMPLETE]S9 Letter batch exists")
138+
# Then my subject has been updated as follows:
139+
subject_assertion(
140+
nhs_no,
141+
{
142+
"latest event status": "S9 - Pre-invitation Sent",
143+
},
144+
)
145+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
194146

195147
# When I process the open "S9" letter batch for my subject
196148
batch_processing(
@@ -200,19 +152,19 @@ def test_scenario_2(page: Page) -> None:
200152
"S10 - Invitation & Test Kit Sent",
201153
True,
202154
)
203-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
155+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI")
204156

205157
# Then my subject has been updated as follows:
206-
batch_processing(
207-
page,
208-
"S9",
209-
"Invitation & Test Kit (FIT)",
210-
"S10 - Invitation & Test Kit Sent",
211-
True,
158+
subject_assertion(
159+
nhs_no,
160+
{
161+
"latest event status": "S10 - Invitation & Test Kit Sent",
162+
},
212163
)
213-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
164+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
214165

215-
# TODO: When I log my subject's latest unlogged FIT kit
166+
# When I log my subject's latest unlogged FIT kit
167+
fit_kit = FitKitLogged().log_fit_kit(page, nhs_no)
216168

217169
# Then my subject has been updated as follows:
218170
subject_assertion(
@@ -221,18 +173,19 @@ def test_scenario_2(page: Page) -> None:
221173
"latest event status": "S43 Kit Returned and Logged (Initial Test)",
222174
},
223175
)
224-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
176+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
225177

226-
# Navigate to subject profile in UI
227-
navigate_to_subject_profile(page, nhs_no)
178+
# Navigate to subject summary page in UI
179+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
228180

229181
# Assert subject details in the UI
230182
summary_page.assert_latest_event_status(
231-
"S43 Kit Returned and Logged (Initial Test)"
183+
"S43 - Kit Returned and Logged (Initial Test)"
232184
)
233-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
185+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
234186

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

237190
# Then my subject has been updated as follows:
238191
subject_assertion(
@@ -241,53 +194,53 @@ def test_scenario_2(page: Page) -> None:
241194
"latest event status": "S2 Normal",
242195
},
243196
)
244-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
197+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
245198

246-
# Navigate to subject profile in UI
247-
navigate_to_subject_profile(page, nhs_no)
199+
# Navigate to subject summary page in UI
200+
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
248201

249202
# Assert subject details in the UI
250-
summary_page.assert_latest_event_status("S2 Normal")
251-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
203+
summary_page.assert_latest_event_status("S2 - Normal")
204+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI")
252205

253206
# And there is a "S2" letter batch for my subject with the exact title "Subject Result (Normal)"
254-
navigate_to_active_batch_list(page)
207+
BatchListPage(page).navigate_to_active_batch_list_page()
255208
ActiveBatchListPage(page).is_batch_present("S2 - Subject Result (Normal)")
256-
logging.info("[ASSERTIONS COMPLETE]S2 Letter batch exists")
209+
logging.info("[UI ASSERTIONS COMPLETE] S2 Letter batch exists")
257210

258211
# When I process the open "S2" letter batch for my subject
259-
batch_processing(page, "S2", "Normal", "S158 Subject Discharge Sent (Normal)", True)
260-
261-
# Then my subject has been updated as follows:
262212
batch_processing(
263213
page,
264214
"S2",
265215
"Subject Result (Normal)",
266-
"S158 Subject Discharge Sent (Normal)",
216+
"S158 - Subject Discharge Sent (Normal)",
267217
True,
268218
)
269-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB")
270-
271-
# Navigate to subject profile in UI
272-
navigate_to_subject_profile(page, nhs_no)
219+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI")
273220

274-
# Assert subject details in the UI
275-
summary_page.assert_latest_event_status("S158 Subject Discharge Sent (Normal)")
276-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
221+
# Then my subject has been updated as follows:
222+
subject_assertion(
223+
nhs_no,
224+
{
225+
"latest event status": "S158 Subject Discharge Sent (Normal)",
226+
},
227+
)
228+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
277229

278230
# And there is a "S158" letter batch for my subject with the exact title "GP Result (Normal)"
279-
navigate_to_active_batch_list(page)
231+
BatchListPage(page).navigate_to_active_batch_list_page()
280232
ActiveBatchListPage(page).is_batch_present("S158 - GP Result (Normal)")
281-
logging.info("[ASSERTIONS COMPLETE]S158 Letter batch exists")
233+
logging.info("[UI ASSERTIONS COMPLETE] S158 Letter batch exists")
282234

283235
# When I process the open "S158" letter batch for my subject
284236
batch_processing(
285237
page,
286238
"S158",
287239
"GP Result (Normal)",
288-
"S159 GP Discharge Sent (Normal)",
240+
"S159 - GP Discharge Sent (Normal)",
289241
True,
290242
)
243+
logging.info("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI")
291244

292245
# Then my subject has been updated as follows:
293246
subject_assertion(
@@ -320,11 +273,6 @@ def test_scenario_2(page: Page) -> None:
320273
"surveillance due date reason": "Unchanged",
321274
},
322275
)
323-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
276+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
324277

325-
# Navigate to subject profile in UI
326-
navigate_to_subject_profile(page, nhs_no)
327-
328-
# Assert subject details in the UI
329-
summary_page.assert_latest_event_status("S159 GP Discharge Sent (Normal)")
330-
logging.info("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI")
278+
logging.info("[TEST COMPLETE] Scenario 2 passed all assertions")

0 commit comments

Comments
 (0)