Skip to content

Commit 3ae5cb5

Browse files
committed
More refactoring of reports
1 parent 19ff575 commit 3ae5cb5

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

pages/reports_page.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ def __init__(self, page):
1313
self.cancer_waiting_times_reports_page = self.page.get_by_role("link", name="Cancer Waiting Times Reports")
1414
self.dashboard = self.page.get_by_role("link", name="Dashboard")
1515
self.qa_report_dataset_completion_page = self.page.get_by_role("link", name="QA Report : Dataset Completion")
16-
# Reports pages shared buttons
16+
# Reports pages shared buttons & links
1717
self.refresh_page_button = self.page.get_by_role("button", name="Refresh")
1818
self.generate_report_button = self.page.get_by_role("button", name="Generate Report")
1919
self.reports_update_button = self.page.get_by_role("button", name="Update")
20+
self.report_timestamp_element = self.page.locator("b")
2021
# Failsafe Reports menu links
2122
self.date_report_last_requested_page = self.page.get_by_role("link", name="Date Report Last Requested")
2223
self.screening_subjects_with_inactive_open_episode_link_page = self.page.get_by_role("link", name="Screening Subjects With")

tests/test_reports_page.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
import pytest
22
from playwright.sync_api import Page, expect
3-
3+
from sys import platform
44
from pages.base_page import BasePage
55
from pages.reports_page import ReportsPage
66
from utils.click_helper import click
77
from utils.date_time_utils import DateTimeUtils
88
from utils.user_tools import UserTools
9+
from jproperties import Properties
10+
11+
12+
@pytest.fixture
13+
def tests_properties() -> dict:
14+
"""
15+
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
16+
Returns a dictionary of properties for use in tests.
17+
18+
Returns:
19+
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
20+
"""
21+
configs = Properties()
22+
if platform == "win32": # File path from content root is required on Windows OS
23+
with open('tests/bcss_tests.properties', 'rb') as read_prop:
24+
configs.load(read_prop)
25+
elif platform == "darwin": # Only the filename is required on macOS
26+
with open('bcss_tests.properties', 'rb') as read_prop:
27+
configs.load(read_prop)
28+
return configs.properties
929

1030

1131
@pytest.fixture(scope="function", autouse=True)
@@ -97,13 +117,12 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
97117
expect(report_timestamp_element).to_contain_text(report_timestamp)
98118

99119

100-
@pytest.mark.only
101120
def test_failsafe_reports_screening_subjects_with_inactive_open_episode(page: Page) -> None:
102121
"""
103122
Confirms 'screening_subjects_with_inactive_open_episode' page loads, 'generate report' button works as expected
104123
and that a screening subject record can be opened
105124
"""
106-
nhs_number_link = page.get_by_role("cell", name="7652")
125+
nhs_number_link = page.get_by_role("cell", name="7652") # This value is specific to this test only
107126

108127
# Go to failsafe reports page
109128
ReportsPage(page).go_to_failsafe_reports_page()
@@ -159,7 +178,9 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
159178
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Subject Demographic")
160179

161180

162-
def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries(page: Page) -> None:
181+
@pytest.mark.only
182+
def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries(page: Page,
183+
tests_properties: dict) -> None:
163184
"""
164185
Confirms 'allocate_sc_for_patient_movements_within_hub_boundaries' page loads,
165186
the 'generate report' button works as expected
@@ -169,9 +190,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
169190
"""
170191

171192
report_timestamp_element = page.locator("b")
172-
173193
nhs_number_link = page.locator("//*[@id='listReportDataTable']/tbody/tr[3]/td[1]")
174-
coventry_and_warwickshire_bcs_centre = "23643"
175194

176195
# Go to failsafe reports page
177196
ReportsPage(page).go_to_failsafe_reports_page()
@@ -197,13 +216,13 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
197216
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Set Patient's Screening Centre")
198217

199218
# Select another screening centre
200-
page.locator("#cboScreeningCentre").select_option(coventry_and_warwickshire_bcs_centre)
219+
page.locator("#cboScreeningCentre").select_option(tests_properties["coventry_and_warwickshire_bcs_centre"])
201220

202221
# Click update
203222
ReportsPage(page).click_reports_pages_update_button()
204223

205224
# Verify new screening centre has saved
206-
expect(page.locator("#cboScreeningCentre")).to_have_value(coventry_and_warwickshire_bcs_centre)
225+
expect(page.locator("#cboScreeningCentre")).to_have_value(tests_properties["coventry_and_warwickshire_bcs_centre"])
207226

208227

209228
def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page: Page) -> None:
@@ -413,7 +432,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
413432

414433
coventry_and_warwickshire_bcs_centre = "23643"
415434
screening_practitioner_named_another_stubble = "1982"
416-
generate_report_button = page.locator("#submitThisForm") #The locator appears to be unique to this button
435+
generate_report_button = page.locator("#submitThisForm") # The locator appears to be unique to this button
417436
report_timestamp_element = page.locator("b")
418437

419438
# Go to operational reports page

0 commit comments

Comments
 (0)