forked from nhs-england-tools/playwright-python-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/bcss 22325 lynchregressiontests scenario 2 #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adrianoaru-nhs
merged 6 commits into
main
from
feature/BCSS-22325-lynchregressiontests-scenario-2
Jan 6, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91a2f3d
scenario 1
mepr1 ba1efb7
Migrating Scenario 2
adrianoaru-nhs 77249ae
Delete tests/regression/regression_tests/lynch_regression_tests/test_…
adrianoaru-nhs dca8212
Adding docstrings and typing to methods
adrianoaru-nhs c6038c8
Merge branch 'main' into feature/BCSS-22325-lynchregressiontests-scen…
adrianoaru-nhs dd4e2fb
Merge branch 'main' into feature/BCSS-22325-lynchregressiontests-scen…
adrianoaru-nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
278 changes: 278 additions & 0 deletions
278
tests/regression/regression_tests/lynch_regression_tests/test_lynch_scenario_2.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,278 @@ | ||
| import logging | ||
| import pytest | ||
| from playwright.sync_api import Page | ||
| from classes.repositories.general_repository import GeneralRepository | ||
| from pages.base_page import BasePage | ||
| from pages.logout.log_out_page import LogoutPage | ||
| from pages.screening_practitioner_appointments.appointment_detail_page import ( | ||
| AppointmentDetailPage, | ||
| ) | ||
| from pages.screening_subject_search.episode_events_and_notes_page import ( | ||
| EpisodeEventsAndNotesPage, | ||
| ) | ||
| from pages.screening_subject_search.subject_screening_summary_page import ( | ||
| SubjectScreeningSummaryPage, | ||
| ) | ||
| from utils import screening_subject_page_searcher | ||
| from utils.appointments import book_appointments | ||
| from utils.batch_processing import batch_processing | ||
| from utils.lynch_utils import LynchUtils | ||
| from utils.oracle.oracle import OracleDB | ||
| from utils.subject_assertion import subject_assertion | ||
| from utils.user_tools import UserTools | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("setup_org_and_appointments") | ||
| @pytest.mark.vpn_required | ||
| @pytest.mark.regression | ||
| @pytest.mark.lynch_regression_tests | ||
| def test_scenario_2(page: Page) -> None: | ||
adrianoaru-nhs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| Scenario: 2 - Screening Centre discharges patient prior to colonoscopy assessment | ||
| G1-G2-G3-A183-A25-J24-J25-J26-C203 in age range [SSCL4b(J26)] | ||
| This scenario tests where the screening centre discharges the patient before the colonoscopy assessment appointment takes place. | ||
| Scenario summary: | ||
| > Process Lynch diagnosis for a new in-age subject suitable for immediate invitation | ||
| > Run Lynch invitations > G1 (5.1) | ||
| > Process G1 letter batch > G2 (5.1) | ||
| > Run timed events > G3 (5.1) | ||
| > Book appointment > A183 (1.11) | ||
| > Process A183 letter batch > A25 (1.11) | ||
| > SC discharges patient > J24 (1.11) | ||
| > Process J24 letter batch > J25 (1.11) | ||
| > Process J25 letter batch > J26 (1.11) | ||
| > Check recall [SSCL4b(J26)] | ||
| """ | ||
| # Given I log in to BCSS "England" as user role "Hub Manager" | ||
| user_role = UserTools.user_login( | ||
| page, "Hub Manager State Registered at BCS01", return_role_type=True | ||
| ) | ||
| if user_role is None: | ||
| raise ValueError("User cannot be assigned to a UserRoleType") | ||
|
|
||
| # When I receive Lynch diagnosis "EPCAM" for a new subject in my hub aged "25" with diagnosis date "1 year ago" and no last colonoscopy date | ||
| nhs_no = LynchUtils(page).insert_validated_lynch_patient_from_new_subject_with_age( | ||
| age="25", | ||
| gene="EPCAM", | ||
| when_diagnosis_took_place="1 year ago", | ||
| when_last_colonoscopy_took_place="unknown", | ||
| user_role=user_role, | ||
| ) | ||
|
|
||
| # Then Comment: NHS number | ||
| assert nhs_no is not None | ||
| logging.info(f"[SUBJECT CREATION] Created Lynch subject with NHS number: {nhs_no}") | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "Calculated FOBT due date": "Null", | ||
| "Calculated lynch due date": "Null", | ||
| "Calculated surveillance due date": "Null", | ||
| "Lynch due date": "Null", | ||
| "Lynch due date date of change": "Null", | ||
| "Lynch due date reason": "Null", | ||
| "Previous screening status": "Null", | ||
| "Screening due date": "Null", | ||
| "Screening due date date of change": "Null", | ||
| "Screening due date reason": "Null", | ||
| "Subject has lynch diagnosis": "Yes", | ||
| "Subject lower FOBT age": "Default", | ||
| "Subject lower lynch age": "25", | ||
| "Screening status": "Lynch Surveillance", | ||
| "Screening status date of change": "Today", | ||
| "Screening status reason": "Eligible for Lynch Surveillance", | ||
| "Subject age": "25", | ||
| "Surveillance due date": "Null", | ||
| "Surveillance due date date of change": "Null", | ||
| "Surveillance due date reason": "Null", | ||
| }, | ||
| user_role, | ||
| ) | ||
|
|
||
| # When I set the Lynch invitation rate for all screening centres to 50 | ||
| LynchUtils(page).set_lynch_invitation_rate(rate=50) | ||
|
|
||
| # And I run the Lynch invitations process | ||
| GeneralRepository().run_lynch_invitations() | ||
|
|
||
| # And my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "Calculated FOBT due date": "Null", | ||
| "Calculated lynch due date": "Unchanged", | ||
| "Calculated surveillance due date": "Null", | ||
| "Lynch due date": "25th birthday", | ||
| "Lynch due date date of change": "Today", | ||
| "Lynch due date reason": "Selected for Lynch Surveillance", | ||
| "Previous screening status": "Null", | ||
| "Screening due date": "Null", | ||
| "Screening due date date of change": "Null", | ||
| "Screening due date reason": "Null", | ||
| "Subject has an open episode": "Yes", | ||
| "Subject has lynch diagnosis": "Yes", | ||
| "Subject lower FOBT age": "Default", | ||
| "Subject lower lynch age": "25", | ||
| "Screening status": "Lynch Surveillance", | ||
| "Screening status date of change": "Today", | ||
| "Screening status reason": "Eligible for Lynch Surveillance", | ||
| "Subject age": "25", | ||
| "Surveillance due date": "Null", | ||
| "Surveillance due date date of change": "Null", | ||
| "Surveillance due date reason": "Null", | ||
| }, | ||
| ) | ||
|
|
||
| # And there is a "G1" letter batch for my subject with the exact title "Lynch Surveillance Pre-invitation" | ||
| # When I process the open "G1" letter batch for my subject | ||
| batch_processing(page, "G1", "Lynch Surveillance Pre-invitation") | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion(nhs_no, {"latest event status": "G2 Lynch Pre-invitation Sent"}) | ||
|
|
||
| # When I run Timed Events for my subject | ||
| OracleDB().exec_bcss_timed_events(nhs_number=nhs_no) | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "latest event status": "G3 Lynch Surveillance Colonoscopy Assessment Appointment Required" | ||
| }, | ||
| ) | ||
|
|
||
| logging.info("Progress the episode through the required pathway") | ||
|
|
||
| # When I view the subject | ||
| screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no) | ||
|
|
||
| # And I view the practitioner appointment booking screen | ||
| SubjectScreeningSummaryPage(page).click_book_practitioner_clinic_button() | ||
|
|
||
| # And I select "BCS001" as the screening centre where the practitioner appointment will be held | ||
| # And I set the practitioner appointment date to "tomorrow" | ||
| # And I book the "earliest" available practitioner appointment on this date | ||
| book_appointments( | ||
| page, | ||
| "BCS001 - Wolverhampton Bowel Cancer Screening Centre", | ||
| "The Royal Hospital (Wolverhampton)", | ||
| ) | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "latest event status": "A183 1st Colonoscopy Assessment Appointment Requested", | ||
| }, | ||
| ) | ||
|
|
||
| # And there is a "A183" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment (Lynch)" | ||
| # When I process the open "A183" letter batch for my subject | ||
| batch_processing(page, "A183", "Practitioner Clinic 1st Appointment (Lynch)") | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "latest event status": "A25 1st Colonoscopy Assessment Appointment Booked, letter sent", | ||
| }, | ||
| ) | ||
|
|
||
| # When I switch users to BCSS "England" as user role "Screening Centre Manager" | ||
| LogoutPage(page).log_out(close_page=False) | ||
| BasePage(page).go_to_log_in_page() | ||
| UserTools.user_login(page, "Screening Centre Manager at BCS001") | ||
|
|
||
| # And I view the subject | ||
| screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no) | ||
|
|
||
| # And I view the event history for the subject's latest episode | ||
| SubjectScreeningSummaryPage(page).expand_episodes_list() | ||
| SubjectScreeningSummaryPage(page).click_first_lynch_surveillance_episode_link() | ||
|
|
||
| # And I view the latest practitioner appointment in the subject's episode | ||
| EpisodeEventsAndNotesPage(page).click_most_recent_view_appointment_link() | ||
|
|
||
| # And The Screening Centre cancels the practitioner appointment with reason "Patient Unsuitable - Recently Screened" | ||
| AppointmentDetailPage(page).check_cancel_radio() | ||
| AppointmentDetailPage(page).select_reason_for_cancellation_option( | ||
| "Patient Unsuitable - Recently Screened" | ||
| ) | ||
|
|
||
| # And I press OK on my confirmation prompt | ||
| AppointmentDetailPage(page).click_save_button(accept_dialog=True) | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "latest event status": "J24 Screening Centre Discharge Patient", | ||
| }, | ||
| ) | ||
|
|
||
| # And there is a "J24" letter batch for my subject with the exact title "Subject Discharge (Screening Centre) (Lynch)" | ||
| # When I process the open "J24" letter batch for my subject | ||
| batch_processing(page, "J24", "Subject Discharge (Screening Centre) (Lynch)") | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "latest event status": "J25 Patient discharge sent (Screening Centre discharge patient)", | ||
| }, | ||
| ) | ||
|
|
||
| # When I switch users to BCSS "England" as user role "Hub Manager" | ||
| LogoutPage(page).log_out(close_page=False) | ||
| BasePage(page).go_to_log_in_page() | ||
| UserTools.user_login(page, "Hub Manager State Registered at BCS01") | ||
|
|
||
| # And there is a "J25" letter batch for my subject with the exact title "GP Discharge (Discharged By Screening Centre) (Lynch)" | ||
| # When I process the open "J25" letter batch for my subject | ||
| batch_processing( | ||
| page, "J25", "GP Discharge (Discharged By Screening Centre) (Lynch)" | ||
| ) | ||
|
|
||
| logging.info("Check subject details against closure scenario SSCL4b(J26)") | ||
|
|
||
| # Then my subject has been updated as follows: | ||
| subject_assertion( | ||
| nhs_no, | ||
| { | ||
| "calculated fobt due date": "Null", | ||
| "calculated lynch due date": "2 years from latest J25 event", | ||
| "calculated surveillance due date": "Null", | ||
| "ceased confirmation date": "Null", | ||
| "ceased confirmation details": "Null", | ||
| "ceased confirmation user id": "Null", | ||
| "clinical reason for cease": "Null", | ||
| "latest episode accumulated result": "Lynch non-participation", | ||
| "latest episode recall calculation method": "Date of last patient letter", | ||
| "latest episode recall episode type": "Lynch Surveillance", | ||
| "latest episode recall surveillance type": "Null", | ||
| "latest episode status": "Closed", | ||
| "latest episode status reason": "Discharged", | ||
| "latest event status": "J26 GP Discharge letter sent (Discharge by Screening centre)", | ||
| "lynch due date": "Calculated Lynch due date", | ||
| "lynch due date date of change": "Today", | ||
| "lynch due date reason": "Lynch Surveillance", | ||
| "lynch incident episode": "Null", | ||
| "screening due date": "Null", | ||
| "screening due date date of change": "Unchanged", | ||
| "screening due date reason": "Unchanged", | ||
| "screening status": "Lynch Surveillance", | ||
| "screening status date of change": "Unchanged", | ||
| "screening status reason": "Lynch Surveillance", | ||
| "surveillance due date": "Null", | ||
| "surveillance due date date of change": "Unchanged", | ||
| "surveillance due date reason": "Unchanged", | ||
| }, | ||
| ) | ||
|
|
||
| LogoutPage(page).log_out() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.