Skip to content

Commit c52740a

Browse files
Copying over changes from the smokescreen_compartment_3 branch
1 parent bfc2784 commit c52740a

15 files changed

+244
-180
lines changed

pages/cognito_login_page.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from playwright.sync_api import Page
4+
5+
6+
class CognitoLoginPage:
7+
8+
def __init__(self, page: Page):
9+
self.page = page
10+
self.username = page.get_by_role("textbox", name="Username")
11+
self.password = page.get_by_role("textbox", name="Password")
12+
self.submit_button = page.get_by_role("button", name="submit")
13+
14+
def login_as_user(self, username: str, password: str) -> None:
15+
"""Logs in to bcss with specified user credentials
16+
Args:
17+
username (str) enter a username that exists in users.json
18+
password (str) the password for the user provided
19+
"""
20+
# Retrieve and enter username from users.json
21+
self.username.fill(username)
22+
# Retrieve and enter password from .env file
23+
self.password.fill(password)
24+
# Click Submit
25+
self.submit_button.click()

pages/generate_invitations_page.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from playwright.sync_api import Page, expect
22
import pytest
33
from utils.click_helper import click
4-
4+
import logging
55

66
class GenerateInvitations:
77
def __init__(self, page: Page):
@@ -33,21 +33,27 @@ def wait_for_invitation_generation_complete(self):
3333
elapsed = 0
3434

3535
# Loop until the table no longer contains "Queued"
36+
logging.info(f"Waiting for successful generation")
3637
while elapsed < timeout: # there may be a stored procedure to speed this process up
3738
table_text = self.displayRS.text_content()
38-
if "Queued" in table_text or "In Progress" in table_text:
39+
if "Failed" in table_text:
40+
pytest.fail("Invitation has failed to generate")
41+
elif "Queued" in table_text or "In Progress" in table_text:
3942
# Click the Refresh button
4043
self.click_refresh_button()
4144
self.page.wait_for_timeout(wait_interval)
4245
elapsed += wait_interval
43-
elif "Failed" in table_text:
44-
pytest.fail("Invitation has failed to generate")
4546
else:
4647
break
4748

4849
# Final check: ensure that the table now contains "Completed"
49-
expect(self.displayRS).to_contain_text("Completed")
50+
try:
51+
expect(self.displayRS).to_contain_text("Completed")
52+
logging.info("Invitations successfully generated")
53+
logging.info(f"Invitations took {elapsed/1000} seconds to generate")
54+
except Exception as e:
55+
pytest.fail("Invitations not generated successfully")
5056

5157
value = self.planned_invitations_total.text_content().strip() # Get text and remove extra spaces
52-
if int(value) <= 5:
53-
pytest.fail("There are less than 5 invitations generated")
58+
if int(value) < 5:
59+
pytest.fail("There are less than 5 invitations generated")

pages/log_out_page.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from playwright.sync_api import Page,expect
2-
2+
from pages.navigation_bar_links import NavigationBar
3+
import logging
34
class Logout:
45
def __init__(self, page: Page):
56
self.page = page
@@ -9,7 +10,8 @@ def __init__(self, page: Page):
910
def verify_log_out_page(self):
1011
expect(self.log_out_msg).to_be_visible()
1112

12-
13-
14-
15-
13+
def log_out(self):
14+
logging.info("Test Complete - Logging Out")
15+
NavigationBar(self.page).click_log_out_link()
16+
expect(self.log_out_msg).to_be_visible()
17+
self.page.close()

pages/subject_screening_page.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def __init__(self, page: Page):
2323
self.laboratory_test_date_filter = self.page.get_by_role("textbox", name="Laboratory Test Date")
2424
self.diagnostic_test_actual_date_filter = self.page.get_by_role("textbox", name="Diagnostic Test Actual Date")
2525
self.search_button = self.page.get_by_role("button", name="Search")
26+
self.search_area = self.page.locator("#A_C_SEARCH_DOMAIN")
27+
28+
def select_whole_database_search_area(self):
29+
self.search_area.select_option("07")
2630

2731
def click_search_button(self):
2832
click(self.page, self.search_button)

pytest.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ addopts =
1717
# Allows pytest to identify the base of this project as the pythonpath
1818
pythonpath = .
1919

20-
2120
# These are the tags that pytest will recognise when using @pytest.mark
2221
markers =
2322
#example: tests used for example purposes by this blueprint
@@ -28,4 +27,7 @@ markers =
2827
utils: test setup and support methods
2928
smoke: tests designed to run as part of the smokescreen regression test suite
3029
wip: tests that are currently in progress
31-
smokescreen: test containing the compartment smokescreen tests
30+
smokescreen: all compartments to be run as part of the smokescreen
31+
compartment1: only for compartment 1
32+
compartment2: only for compartment 2
33+
compartment3: only for compartment 3

tests/Smokescreen/test_compartment_1.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,54 @@
55
from utils.oracle import OracleDB
66

77
@pytest.mark.smoke
8-
@pytest.mark.smokescreen
98
@pytest.mark.compartment1
10-
def test_compartment_1(page: Page) -> None:
11-
12-
page.goto("/")
13-
BcssLoginPage(page).login_as_user("BCSS401")
14-
9+
def test_create_invitations_plan(page: Page) -> None:
10+
logging.info("Compartment 1 - Create Invitations Plan")
11+
UserTools.user_login(page, "Hub Manager State Registered")
1512
# Create plan - England
1613
MainMenu(page).go_to_call_and_recall_page()
1714
CallAndRecall(page).go_to_planning_and_monitoring_page()
1815
InvitationsMonitoring(page).go_to_bcss001_invitations_plan_page()
1916
InvitationsPlans(page).go_to_create_a_plan_page()
17+
logging.info("Setting daily invitation rate")
2018
CreateAPlan(page).click_set_all_button()
2119
CreateAPlan(page).fill_daily_invitation_rate_field("10")
2220
CreateAPlan(page).click_update_button()
23-
if CreateAPlan(page).confirm_button.is_visible():
24-
CreateAPlan(page).click_confirm_button()
21+
CreateAPlan(page).click_confirm_button()
2522
CreateAPlan(page).click_save_button()
2623
CreateAPlan(page).fill_note_field("test data")
2724
CreateAPlan(page).click_save_note_button()
2825
InvitationsPlans(page).invitations_plans_title.wait_for()
26+
logging.info("Invitation plan created")
27+
28+
@pytest.mark.smoke
29+
@pytest.mark.smokescreen
30+
@pytest.mark.compartment1
31+
def test_compartment_1(page: Page) -> None:
32+
logging.info("Compartment 1 - Generate Invitations")
33+
UserTools.user_login(page, "Hub Manager State Registered")
2934

3035
# Generate Invitations
31-
NavigationBar(page).click_main_menu_link()
3236
MainMenu(page).go_to_call_and_recall_page()
3337
CallAndRecall(page).go_to_generate_invitations_page()
38+
logging.info("Generating invitations based on the invitations plan")
3439
GenerateInvitations(page).click_generate_invitations_button()
3540
GenerateInvitations(page).wait_for_invitation_generation_complete()
3641

3742
# Print the batch of Pre-Invitation Letters - England
43+
logging.info("Compartment 1 - Process S1 Batch")
3844
batch_processing(page, "S1", "Pre-invitation (FIT) (digital leaflet)", "S9 - Pre-invitation Sent")
3945
nhs_number_df = batch_processing(page, "S1", "Pre-invitation (FIT)", "S9 - Pre-invitation Sent")
40-
for index, row in nhs_number_df.iterrows():
41-
OracleDB().exec_bcss_timed_events(row["subject_nhs_number"])
46+
OracleDB().exec_bcss_timed_events(nhs_number_df)
4247

4348
# Print the batch of Invitation & Test Kit Letters - England
49+
logging.info("Compartment 1 - Process S9 Batch")
4450
nhs_number_df = batch_processing(page, "S9", "Invitation & Test Kit (FIT)", "S10 - Invitation & Test Kit Sent")
45-
for index, row in nhs_number_df.iterrows():
46-
OracleDB().exec_bcss_timed_events(row["subject_nhs_number"])
51+
OracleDB().exec_bcss_timed_events(nhs_number_df)
4752

4853
# Print a set of reminder letters
54+
logging.info("Compartment 1 - Process S10 Batch")
4955
batch_processing(page, "S10", "Test Kit Reminder", "S19 - Reminder of Initial Test Sent")
5056

5157
# Log out
52-
NavigationBar(page).click_log_out_link()
53-
Logout(page).verify_log_out_page()
54-
page.close()
58+
Logout(page).log_out()

tests/Smokescreen/test_compartment_2.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,55 @@
55
from datetime import datetime
66
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
77
from utils.fit_kit_generation import create_fit_id_df
8+
import logging
89

9-
@pytest.mark.wip2
10+
@pytest.mark.smoke
1011
@pytest.mark.smokescreen
12+
@pytest.mark.compartment2
1113
def test_compartment_2(page: Page) -> None:
12-
page.goto("/")
13-
BcssLoginPage(page).login_as_user("BCSS401")
14+
UserTools.user_login(page, "Hub Manager State Registered")
1415

1516
MainMenu(page).go_to_fit_test_kits_page()
1617
FITTestKits(page).go_to_log_devices_page()
1718
subjectdf = create_fit_id_df()
1819

19-
for subject in range(4):
20+
for subject in range(9):
2021
fit_device_id = subjectdf["fit_device_id"].iloc[subject]
22+
logging.info(f"Logging FIT Device ID: {fit_device_id}")
2123
LogDevices(page).fill_fit_device_id_field(fit_device_id)
22-
sample_date = datetime.now().strftime("%d %b %Y")
24+
sample_date = datetime.now().strftime("%#d %b %Y")
25+
logging.info("Setting sample date to todays date")
2326
LogDevices(page).fill_sample_date_field(sample_date)
24-
LogDevices(page).verify_successfully_logged_device_text()
27+
try:
28+
LogDevices(page).verify_successfully_logged_device_text()
29+
logging.info(f"{fit_device_id} Successfully logged")
30+
except:
31+
pytest.fail(f"{fit_device_id} unsuccessfully logged")
2532

26-
nhs_no = subjectdf["nhs_number"].iloc[0]
27-
verify_subject_event_status_by_nhs_no(page, nhs_no, "S43 - Kit Returned and Logged (Initial Test)")
33+
nhs_no = subjectdf["subject_nhs_number"].iloc[0]
34+
try:
35+
verify_subject_event_status_by_nhs_no(page, nhs_no, "S43 - Kit Returned and Logged (Initial Test)")
36+
logging.info(f"Successfully verified NHS number {nhs_no} with status S43 - Kit Returned and Logged (Initial Test)")
37+
except Exception as e:
38+
pytest.fail(f"Verification failed for NHS number {nhs_no}: {str(e)}")
2839

2940
NavigationBar(page).click_main_menu_link()
3041
MainMenu(page).go_to_fit_test_kits_page()
3142
FITTestKits(page).go_to_log_devices_page()
3243
spoilt_fit_device_id = subjectdf["fit_device_id"].iloc[-1]
44+
logging.info(f"Logging Spoilt FIT Device ID: {spoilt_fit_device_id}")
3345
LogDevices(page).fill_fit_device_id_field(spoilt_fit_device_id)
3446
LogDevices(page).click_device_spoilt_button()
3547
LogDevices(page).select_spoilt_device_dropdown_option()
3648
LogDevices(page).click_log_as_spoilt_button()
37-
LogDevices(page).verify_successfully_logged_device_text()
49+
try:
50+
LogDevices(page).verify_successfully_logged_device_text()
51+
logging.info(f"{spoilt_fit_device_id} Successfully logged")
52+
except:
53+
pytest.fail(f"{spoilt_fit_device_id} unsuccessfully logged")
54+
3855

3956
batch_processing(page, "S3", "Retest (Spoilt) (FIT)", "S11 - Retest Kit Sent (Spoilt)")
4057

4158
# Log out
42-
NavigationBar(page).click_log_out_link()
43-
Logout(page).verify_log_out_page()
44-
page.close()
59+
Logout(page).log_out()

users.json

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
{
22
"_comment": "This file can be used to store data on users for your application, and then pulled through using the utils.user_tools UserTools utility. The documentation for this utility explains how this file is read.",
33

4-
"BCSS401": {
4+
"Hub Manager State Registered": {
55
"username": "BCSS401",
66
"roles": [
77
"Hub Manager State Registered, Midlands and North West"
88
]
99
},
10-
"BCSS118": {
10+
"Screening Centre Manager": {
1111
"username": "BCSS118",
1212
"roles": [
1313
"Screening Centre Manager for Wolverhampton, Midlands and North West"
1414
]
15-
},
16-
"BCSS402": {
17-
"username": "BCSS402",
18-
"roles": [
19-
"Hub Manager"
20-
]
21-
},
22-
"BCSS33": {
23-
"username": "BCSS33",
24-
"roles": [
25-
"BCSS Bureau Staff"
26-
]
27-
},
28-
"BCSS406": {
29-
"username": "BCSS406",
30-
"roles": [
31-
"Assistant Laboratory Lead - state registered"
32-
]
3315
}
34-
}
16+
}

0 commit comments

Comments
 (0)