Skip to content

Commit a97a1ae

Browse files
Addressing issues mentioned by Dave in PR #6 Feature/smokescreen compartment 1
1 parent c52740a commit a97a1ae

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

pages/generate_invitations_page.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self, page: Page):
1111
self.displayRS = self.page.locator("#displayRS")
1212
self.refresh_button = self.page.get_by_role("button", name="Refresh")
1313
self.planned_invitations_total = self.page.locator("#col8_total")
14+
self.self_referrals_total = self.page.locator("#col9_total")
1415

1516
def click_generate_invitations_button(self):
1617
click(self.page, self.generate_invitations_button)
@@ -54,6 +55,11 @@ def wait_for_invitation_generation_complete(self):
5455
except Exception as e:
5556
pytest.fail("Invitations not generated successfully")
5657

58+
self_referrals_total = int(self.self_referrals_total.text_content().strip())
59+
if self_referrals_total >= 1:
60+
logging.warning("No S1 Digital Leaflet batch will be generated")
61+
return True
62+
5763
value = self.planned_invitations_total.text_content().strip() # Get text and remove extra spaces
5864
if int(value) < 5:
59-
pytest.fail("There are less than 5 invitations generated")
65+
pytest.fail("There are less than 5 invitations generated")

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pytest-playwright>=0.5.1
22
pytest-html>=4.1.1
33
pytest-json-report>=1.5.0
4-
pypdf>=5.3.0
54
oracledb>=2.5.1
65
pandas>=2.2.3
76
python-dotenv~=1.0.1

tests/Smokescreen/test_compartment_1.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def test_compartment_1(page: Page) -> None:
3737
CallAndRecall(page).go_to_generate_invitations_page()
3838
logging.info("Generating invitations based on the invitations plan")
3939
GenerateInvitations(page).click_generate_invitations_button()
40-
GenerateInvitations(page).wait_for_invitation_generation_complete()
40+
self_referrals_available = GenerateInvitations(page).wait_for_invitation_generation_complete()
4141

4242
# Print the batch of Pre-Invitation Letters - England
4343
logging.info("Compartment 1 - Process S1 Batch")
44-
batch_processing(page, "S1", "Pre-invitation (FIT) (digital leaflet)", "S9 - Pre-invitation Sent")
44+
if self_referrals_available:
45+
batch_processing(page, "S1", "Pre-invitation (FIT) (digital leaflet)", "S9 - Pre-invitation Sent")
46+
else:
47+
logging.warning("Skipping S1 Pre-invitation (FIT) (digital leaflet) as no self referral invitations were generated")
4548
nhs_number_df = batch_processing(page, "S1", "Pre-invitation (FIT)", "S9 - Pre-invitation Sent")
4649
OracleDB().exec_bcss_timed_events(nhs_number_df)
4750

@@ -55,4 +58,4 @@ def test_compartment_1(page: Page) -> None:
5558
batch_processing(page, "S10", "Test Kit Reminder", "S19 - Reminder of Initial Test Sent")
5659

5760
# Log out
58-
Logout(page).log_out()
61+
Logout(page).log_out()

utils/batch_processing.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
2020

2121
batch_description_cells = page.locator(f"//td[text()='{batch_description}']")
2222

23-
if batch_description_cells.count() == 0 and batch_description == "Pre-invitation (FIT) (digital leaflet)":
24-
logging.warning("No S1 Pre-invitation (FIT) (digital leaflet) batch found. Skipping to next step")
25-
return
26-
elif batch_description_cells.count() == 0 and page.locator("td", has_text="No matching records found"):
23+
if batch_description_cells.count() == 0 and page.locator("td", has_text="No matching records found"):
2724
pytest.fail(f"No {batch_type} {batch_description} batch found")
2825

2926
for i in range(batch_description_cells.count()):
@@ -58,8 +55,8 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
5855
logging.info(f"Clicking retrieve button {retrieve_button_count}")
5956
# Start waiting for the pdf download
6057
with page.expect_download() as download_info:
61-
# Perform the action that initiates download
62-
ManageActiveBatch(page).retrieve_button.nth(retrieve_button-1).click()
58+
# Perform the action that initiates download. The line below is running in a FOR loop to click every retrieve button as in some cases more than 1 is present
59+
ManageActiveBatch(page).retrieve_button.nth(retrieve_button).click()
6360
download_file = download_info.value
6461
file = download_file.suggested_filename
6562
# Wait for the download process to complete and save the downloaded file in a temp folder
@@ -99,4 +96,4 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
9996
logging.info(f"Successfully verified NHS number {first_nhs_no} with status {latest_event_status}")
10097
except Exception as e:
10198
pytest.fail(f"Verification failed for NHS number {first_nhs_no}: {str(e)}")
102-
return nhs_no_df
99+
return nhs_no_df

0 commit comments

Comments
 (0)