Skip to content

Commit 660c695

Browse files
Adding the two scenarios from RegressionTestSetupSteps.feature
1 parent a9d1fa6 commit 660c695

File tree

8 files changed

+346
-30
lines changed

8 files changed

+346
-30
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
from utils.table_util import TableUtils
4+
5+
6+
class EditContactPage(BasePage):
7+
"""Edit Contact Page locators, and methods for interacting with the page"""
8+
9+
def __init__(self, page: Page):
10+
super().__init__(page)
11+
self.page = page
12+
# Edit Contact - page locators, methods
13+
self.view_resect_and_discard_link = self.page.get_by_role(
14+
"link", name="View Resect and Discard"
15+
)
16+
17+
self.edit_contact_table = TableUtils(self.page, "#displayRS")
18+
19+
def click_view_resect_and_discard_link(self) -> None:
20+
"""Clicks on the 'View Resect and Discard' link"""
21+
self.click(self.view_resect_and_discard_link)
22+
23+
def assert_value_for_label_in_edit_contact_table(
24+
self, label_text: str, expected_text: str
25+
) -> None:
26+
"""
27+
Asserts that the vlaue for a label is as expected in the edit contact table
28+
29+
Args:
30+
label_text (str): The label text to look for in the first cell of a row.
31+
expected_text (str): The text expected inside the adjacent cell.
32+
"""
33+
self.edit_contact_table.verify_value_for_label(label_text, expected_text)

pages/contacts_list/maintain_contacts_page.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from playwright.sync_api import Page, expect
1+
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3+
from utils.table_util import TableUtils
34

45

56
class MaintainContactsPage(BasePage):
@@ -10,6 +11,61 @@ def __init__(self, page: Page):
1011
self.page = page
1112
# Maintain Contacts - page locators, methods
1213

14+
self.surname_input_field = self.page.locator("#selPersonSurname")
15+
self.forenames_input_field = self.page.locator("#selPersonForenames")
16+
self.user_code_input_field = self.page.locator("#selUserCode")
17+
self.search_button = self.page.get_by_role("button", name="Search")
18+
19+
self.search_table = TableUtils(self.page, "#displayRS")
20+
1321
def verify_maintain_contacts_title(self) -> None:
1422
"""Verify the Maintain Contacts page title is displayed correctly"""
1523
self.bowel_cancer_screening_page_title_contains_text("Maintain Contacts")
24+
25+
def fill_surname_input_field(self, surname: str) -> None:
26+
"""
27+
Fill the surname input field with the provided surname
28+
Args:
29+
surname (str): The surname of the subject
30+
"""
31+
self.surname_input_field.fill(surname)
32+
33+
def fill_forenames_input_field(self, forenames: str) -> None:
34+
"""
35+
Fill the forenames input field with the provided forenames
36+
Args:
37+
forenames (str): The forenames of the subject
38+
"""
39+
self.forenames_input_field.fill(forenames)
40+
41+
def fill_user_code_input_field(self, user_code: str) -> None:
42+
"""
43+
Fill the user code input field with the provided user code
44+
Args:
45+
user_code (str): The user code of the subject
46+
"""
47+
self.user_code_input_field.fill(user_code)
48+
49+
def click_search_button(self) -> None:
50+
"""Click the search button to perform a search"""
51+
self.click(self.search_button)
52+
53+
def click_person_link_from_suranme(self, surname: str) -> None:
54+
"""
55+
Clicks on the link containing the person's surname to go to the edit contact page
56+
Args:
57+
surname (str): The surname of the subject
58+
"""
59+
self.click(self.page.get_by_role("link", name=surname))
60+
61+
def click_person_link_from_forename(self, forename: str) -> None:
62+
"""
63+
Clicks on the link containing the person's surname to go to the edit contact page
64+
Args:
65+
forename (str): The forename of the subject
66+
"""
67+
self.click(self.page.get_by_role("link", name=forename))
68+
69+
def click_first_correct_link(self) -> None:
70+
"""Clicks on the first link in the search results that is a BCSS user and has a code"""
71+
self.search_table.click_surname_if_bcss_user_and_has_code()
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from playwright.sync_api import Page, expect
2+
from datetime import datetime
3+
from pages.base_page import BasePage
4+
from utils.calendar_picker import CalendarPicker
5+
6+
7+
class ResectAndDiscardAccreditationHistoryPage(BasePage):
8+
"""Resect And Discard Accreditation History Page locators, and methods for interacting with the page"""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
13+
# Resect And Discard Accreditation History - page locators, methods
14+
self.heading = self.page.get_by_role("heading", name="Resect and Discard")
15+
self.add_accreditation_button = self.page.get_by_role("button", name="+ Add Accreditation")
16+
self.save_button = self.page.get_by_role("button", name="Save")
17+
self.changes_saved_text = self.page.get_by_text("×Saved Changes")
18+
19+
def verify_heading_is_correct(self) -> None:
20+
"""Verifies the heading is visible and contains 'View Resect and Discard'"""
21+
expect(self.heading).to_be_visible()
22+
23+
def verify_add_accreditation_button_exists(self) -> None:
24+
"""Verifies that the 'Add Accreditation' button exists"""
25+
expect(self.add_accreditation_button).to_be_visible()
26+
27+
def click_add_accreditation_button(self) -> None:
28+
"""Clicks the 'Add Accreditation' button"""
29+
self.click(self.add_accreditation_button)
30+
31+
def click_save_button(self) -> None:
32+
"""Clicks the 'Save' button"""
33+
self.click(self.save_button)
34+
35+
def verify_changes_saved(self) -> None:
36+
"""Verifies the new period added has been saved"""
37+
expect(self.changes_saved_text).to_be_visible()
38+
39+
def add_new_period_of_resect_and_discard_accerditation(self, date: datetime) -> None:
40+
"""
41+
Adds a new period of resect and discard accreditation
42+
Args:
43+
date (datetime): The date the period starts
44+
"""
45+
self.click_add_accreditation_button()
46+
CalendarPicker(self.page).v2_calendar_picker(date)
47+
self.click_save_button()
48+
self.verify_changes_saved()
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import pytest
2+
import logging
3+
from datetime import datetime, timedelta
4+
from dateutil.relativedelta import relativedelta
5+
from playwright.sync_api import Page
6+
from pages.base_page import BasePage
7+
from pages.contacts_list.contacts_list_page import ContactsListPage
8+
from pages.contacts_list.maintain_contacts_page import MaintainContactsPage
9+
from pages.contacts_list.edit_contact_page import EditContactPage
10+
from pages.contacts_list.resect_and_discard_accreditation_history_page import (
11+
ResectAndDiscardAccreditationHistoryPage,
12+
)
13+
from pages.logout.log_out_page import LogoutPage
14+
from utils.user_tools import UserTools
15+
from utils.oracle.oracle_specific_functions import (
16+
set_org_parameter_value,
17+
check_parameter,
18+
)
19+
from utils.dataset_field_util import DatasetFieldUtil
20+
21+
from utils.oracle.oracle import OracleDB
22+
23+
24+
def test_allow_10_minute_colonsocopy_assessment_Appointments(page: Page) -> None:
25+
"""
26+
Scenario: 1: Allow 10 minute colonoscopy assessment appointments between 7am and 8pm at BCS001
27+
28+
Given I log in to BCSS "England" as user role "Screening Centre Manager"
29+
And I set the value of parameter 12 to "10" for my organisation with immediate effect
30+
And I set the value of parameter 28 to "07:00" for my organisation with immediate effect
31+
And I set the value of parameter 29 to "20:00" for my organisation with immediate effect
32+
"""
33+
UserTools.user_login(page, "Screening Centre Manager at BCS001")
34+
param_12_set_correctly = check_parameter(12, "23162", "10")
35+
param_28_set_correctly = check_parameter(28, "23162", "07:00")
36+
param_29_set_correctly = check_parameter(29, "23162", "20:00")
37+
if not param_12_set_correctly:
38+
set_org_parameter_value(12, "10", "23162")
39+
if not param_28_set_correctly:
40+
set_org_parameter_value(28, "07:00", "23162")
41+
if not param_29_set_correctly:
42+
set_org_parameter_value(29, "20:00", "23162")
43+
44+
LogoutPage(page).log_out()
45+
46+
47+
def test_ensure_the_is_accredited_screening_colonoscopist_with_current_resect_and_discard_accreditation(
48+
page: Page,
49+
) -> None:
50+
"""
51+
Scenario: 2: Ensure there is an Accredited Screening Colonoscopist with current Resect & Discard accreditation
52+
"""
53+
UserTools.user_login(page, "BCSS Bureau Staff at X26")
54+
BasePage(page).go_to_contacts_list_page()
55+
ContactsListPage(page).go_to_maintain_contacts_page()
56+
query = """
57+
SELECT
58+
prs.prs_id,
59+
prs.person_family_name,
60+
prs.person_given_name,
61+
prs.gmc_code,
62+
pio.pio_id,
63+
pio.role_id,
64+
org.org_code,
65+
org.org_name
66+
FROM person prs
67+
INNER JOIN person_in_org pio ON prs.prs_id = pio.prs_id
68+
INNER JOIN org ON org.org_id = pio.org_id
69+
WHERE 1=1
70+
AND pio.role_id = (SELECT valid_value_id FROM valid_values WHERE description = 'Accredited Screening Colonoscopist')
71+
AND org.org_code = 'BCS001'
72+
AND TRUNC(SYSDATE) BETWEEN TRUNC(pio.start_date) AND NVL(pio.end_date, SYSDATE)
73+
AND pio.is_bcss_user = 1
74+
ORDER BY prs.prs_id
75+
FETCH FIRST 1 ROWS ONLY
76+
"""
77+
person_df = OracleDB().execute_query(query)
78+
surname = person_df.iloc[0]["person_family_name"]
79+
forename = person_df.iloc[0]["person_given_name"]
80+
MaintainContactsPage(page).fill_surname_input_field(surname)
81+
MaintainContactsPage(page).fill_forenames_input_field(forename)
82+
MaintainContactsPage(page).click_search_button()
83+
MaintainContactsPage(page).click_first_correct_link()
84+
EditContactPage(page).click_view_resect_and_discard_link()
85+
ResectAndDiscardAccreditationHistoryPage(page).verify_heading_is_correct()
86+
ResectAndDiscardAccreditationHistoryPage(
87+
page
88+
).verify_add_accreditation_button_exists()
89+
yesterday = datetime.today() - timedelta(days=1)
90+
ResectAndDiscardAccreditationHistoryPage(
91+
page
92+
).add_new_period_of_resect_and_discard_accerditation(date=yesterday)
93+
BasePage(page).click_back_button()
94+
end_date = yesterday + relativedelta(years=2)
95+
EditContactPage(page).assert_value_for_label_in_edit_contact_table(
96+
"Resect & Discard Accreditation?",
97+
f"Current: ends {end_date.strftime('%d/%m/%Y')}",
98+
)
99+
logging.info(f"Test person used in this scenario is: {forename} {surname}")

tests/regression/subject/episodes/datasets/investigation/endoscopy/polypcategories/test_setup.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
update_kit_service_management_entity,
5151
execute_fit_kit_stored_procedures,
5252
set_org_parameter_value,
53-
get_org_parameter_value,
53+
check_parameter,
5454
)
5555
from utils.oracle.subject_selection_query_builder import SubjectSelectionQueryBuilder
5656
from utils.screening_subject_page_searcher import (
@@ -173,30 +173,6 @@ def test_setup_subjects_as_a259(page: Page, subjects_to_run_for: int) -> None:
173173
LogoutPage(page).log_out()
174174

175175

176-
def check_parameter(param_id: int, org_id: str, expected_param_value: str) -> bool:
177-
"""
178-
Check if the organization parameter is set correctly.
179-
Args:
180-
param_id (int): The ID of the parameter to check.
181-
org_id (str): The ID of the organization.
182-
expected_param_value (str): The expected value of the parameter.
183-
184-
Returns:
185-
bool: True if the parameter is set correctly, False otherwise.
186-
"""
187-
df = get_org_parameter_value(param_id, org_id)
188-
for _, row in df.iterrows():
189-
val_matches = str(row["val"]) == expected_param_value
190-
audit_reason_matches = row["audit_reason"] == "AUTOMATED TESTING - ADD"
191-
192-
if val_matches and audit_reason_matches:
193-
logging.info(f"Parameter {param_id} is set correctly: {row['val']}")
194-
return True
195-
196-
logging.warning(f"Parameter {param_id} is not set correctly, updating parameter.")
197-
return False
198-
199-
200176
def setup_appointments(page: Page) -> None:
201177
"""
202178
Set up appointments for multiple practitioners at a screening centre.

users.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,11 @@
110110
"roles": [
111111
"Wolverhampton SC"
112112
]
113+
},
114+
"BCSS Bureau Staff at X26": {
115+
"username": "BCSS33",
116+
"roles": [
117+
"BCSS Bureau Staff at X26"
118+
]
113119
}
114120
}

utils/oracle/oracle_specific_functions.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,30 @@ def get_org_parameter_value(param_id: int, org_id: str) -> pd.DataFrame:
643643
return df
644644

645645

646+
def check_parameter(param_id: int, org_id: str, expected_param_value: str) -> bool:
647+
"""
648+
Check if the organization parameter is set correctly.
649+
Args:
650+
param_id (int): The ID of the parameter to check.
651+
org_id (str): The ID of the organization.
652+
expected_param_value (str): The expected value of the parameter.
653+
654+
Returns:
655+
bool: True if the parameter is set correctly, False otherwise.
656+
"""
657+
df = get_org_parameter_value(param_id, org_id)
658+
for _, row in df.iterrows():
659+
val_matches = str(row["val"]) == expected_param_value
660+
audit_reason_matches = row["audit_reason"] == "AUTOMATED TESTING - ADD"
661+
662+
if val_matches and audit_reason_matches:
663+
logging.info(f"Parameter {param_id} is set correctly: {row['val']}")
664+
return True
665+
666+
logging.warning(f"Parameter {param_id} is not set correctly, updating parameter.")
667+
return False
668+
669+
646670
def get_investigation_dataset_polyp_category(
647671
dataset_id: int, polyp_number: int
648672
) -> Optional[str]:
@@ -758,6 +782,6 @@ def get_subject_for_manual_cease(criteria: dict) -> str:
758782
if result_df.empty:
759783
raise ValueError("No subject found for manual cease.")
760784

761-
nhs_number = result_df.iloc[0]["subject_nhs_number"]
785+
nhs_number = result_df["subject_nhs_number"].iloc[0]
762786
logging.info(f"[SUBJECT SELECTOR] Found subject NHS number: {nhs_number}")
763787
return nhs_number

0 commit comments

Comments
 (0)