Skip to content

Commit 17696f5

Browse files
Andyg79adrianoaru-nhsvictor-soares-ibm
committed
Refactoring reports_page and test_reports_page (2nd Attempt) (#19)
<!-- markdownlint-disable-next-line first-line-heading --> refactor reports pages and tests <!-- Describe your changes in detail. --> The reports pages have a lot of different locators that perform the same function. I have removed locators and test data from the tests and added them to the page object, and created a function for clicking on NHS number links. <!-- Why is this change required? What problem does it solve? --> The tests are generally cleaner and more readable. All of the tests can now call the same function to click on an NHS number link. <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes. --------- Co-authored-by: adrianoaru-nhs <[email protected]> Co-authored-by: victor-soares-ibm <[email protected]> Co-authored-by: Adriano Aru <[email protected]>
1 parent 7d5e14a commit 17696f5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pages/reports/reports_page.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ def click_nhs_number_link(self, page: Page) -> None:
197197
"//*[@id='listReportDataTable']/tbody/tr[3]/td[2]",
198198
"#listReportDataTable > tbody > tr:nth-child(3) > td:nth-child(1) > a",
199199
"#subjInactiveOpenEpisodes > tbody > tr:nth-child(1) > td.NHS_NUMBER.dt-type-numeric > a",
200-
"# subjInactiveOpenEpisodes > tbody > tr:nth-child(1) > td.NHS_NUMBER.dt-type-numeric > a",
201-
"//*[@id=\"subjInactiveOpenEpisodes\"]/tbody/tr[1]/td[1]/a",
202200
]
203201

204202
for locator_string in locators:

tests/test_reports_page.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,18 +449,22 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
449449

450450
# Verify timestamp has updated to current date and time
451451
report_timestamp = DateTimeUtils.report_timestamp_date_format()
452-
expect(
453-
ReportsPage(page).six_weeks_availability_not_set_up_report_timestamp_element
454-
).to_contain_text(report_timestamp)
452+
ReportsPage(
453+
page
454+
).six_weeks_availability_not_set_up_report_timestamp_element.to_contain_text(
455+
report_timestamp
456+
)
455457

456458
# Click "Refresh" button
457459
ReportsPage(page).click_refresh_button()
458460

459461
# Verify timestamp has updated to current date and time
460462
report_timestamp = DateTimeUtils.report_timestamp_date_format()
461-
expect(
462-
ReportsPage(page).six_weeks_availability_not_set_up_report_timestamp_element
463-
).to_contain_text(report_timestamp)
463+
ReportsPage(
464+
page
465+
).six_weeks_availability_not_set_up_report_timestamp_element.to_contain_text(
466+
report_timestamp
467+
)
464468

465469

466470
def test_operational_reports_screening_practitioner_appointments(
@@ -503,6 +507,6 @@ def test_operational_reports_screening_practitioner_appointments(
503507
report_timestamp = (
504508
DateTimeUtils.screening_practitioner_appointments_report_timestamp_date_format()
505509
)
506-
expect(ReportsPage(page).common_report_timestamp_element).to_contain_text(
510+
expect(ReportsPage(Page).common_report_timestamp_element).to_contain_text(
507511
report_timestamp
508512
)

0 commit comments

Comments
 (0)