|
| 1 | +import logging |
| 2 | +import pytest |
| 3 | +from playwright.sync_api import Page, expect |
| 4 | +from pages.logout.log_out_page import Logout |
| 5 | +from pages.base_page import BasePage |
| 6 | +from utils.user_tools import UserTools |
| 7 | +from utils.load_properties_file import PropertiesFile |
| 8 | +from utils.calendar_picker import CalendarPicker |
| 9 | +from utils.batch_processing import batch_processing |
| 10 | +from datetime import datetime |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture |
| 14 | +def smokescreen_properties() -> dict: |
| 15 | + return PropertiesFile().get_smokescreen_properties() |
| 16 | + |
| 17 | + |
| 18 | +@pytest.mark.smokescreen |
| 19 | +@pytest.mark.compartment3 |
| 20 | +def test_compartment_3(page: Page, smokescreen_properties: dict) -> None: |
| 21 | + """ |
| 22 | + This is the main compartment 4 method |
| 23 | + """ |
| 24 | + |
| 25 | + # Add method of getting test data |
| 26 | + """select tk.kitid, ss.subject_nhs_number, se.screening_subject_id |
| 27 | + from tk_items_t tk |
| 28 | + inner join ep_subject_episode_t se on se.screening_subject_id = tk.screening_subject_id |
| 29 | + inner join screening_subject_t ss on ss.screening_subject_id = se.screening_subject_id |
| 30 | + inner join sd_contact_t c on c.nhs_number = ss.subject_nhs_number |
| 31 | + where se.latest_event_status_id = 11132 |
| 32 | + and tk.logged_in_flag = 'Y' |
| 33 | + and se.episode_status_id = 11352 |
| 34 | + and ss.screening_status_id != 4008 |
| 35 | + and tk.logged_in_at = 23159 |
| 36 | + and c.hub_id = 23159 |
| 37 | + and tk.tk_type_id = 2 |
| 38 | + and tk.datestamp > add_months(sysdate,-24) |
| 39 | + order by ss.subject_nhs_number desc""" |
| 40 | + |
| 41 | + UserTools.user_login(page, "Screening Centre Manager at BCS001") |
| 42 | + BasePage(page).go_to_screening_practitioner_appointments_page() |
| 43 | + page.get_by_role("link", name="Set Availability").click() |
| 44 | + page.get_by_role("link", name="Practitioner Availability -").click() |
| 45 | + page.locator("#UI_SITE_ID").select_option(index=1) |
| 46 | + page.locator("#UI_PRACTITIONER_ID").select_option(index=1) |
| 47 | + page.get_by_role("button", name="Calendar").click() |
| 48 | + CalendarPicker(page).select_day( |
| 49 | + datetime.today() |
| 50 | + ) # This will make it so that we can only run this test once a day, or we need to restore the DB back to the snapshot |
| 51 | + page.get_by_role("button", name="Show").dblclick() |
| 52 | + page.get_by_role("textbox", name="From:").click() |
| 53 | + page.get_by_role("textbox", name="From:").fill("09:00") |
| 54 | + page.get_by_role("textbox", name="To:").click() |
| 55 | + page.get_by_role("textbox", name="To:").fill("17:15") |
| 56 | + page.get_by_role("button", name="Calculate Slots").click() |
| 57 | + page.locator("#FOR_WEEKS").click() |
| 58 | + page.locator("#FOR_WEEKS").fill("6") |
| 59 | + page.locator("#FOR_WEEKS").press("Enter") |
| 60 | + page.get_by_role("button", name="Save").click() |
| 61 | + expect(page.get_by_text("Slots Updated for 6 Weeks")).to_be_visible() |
| 62 | + Logout(page).log_out() |
| 63 | + |
| 64 | + page.get_by_role("button", name="Log in").click() |
| 65 | + UserTools.user_login(page, "Hub Manager State Registered at BCS01") |
| 66 | + BasePage(page).go_to_screening_practitioner_appointments_page() |
| 67 | + page.get_by_role("link", name="Patients that Require").click() |
| 68 | + # Add for loop to loop x times (depends on how many we want to run it for) 70 - 79 |
| 69 | + page.locator("#nhsNumberFilter").click() |
| 70 | + page.locator("#nhsNumberFilter").fill("9991406131") |
| 71 | + page.locator("#nhsNumberFilter").press("Enter") |
| 72 | + page.get_by_role("link", name="999 140 6131").click() |
| 73 | + page.get_by_label("Screening Centre ( All)").select_option("23162") |
| 74 | + page.locator("#UI_NEW_SITE").select_option("42808") |
| 75 | + page.locator('input[name="fri2"]').click() # Todays date if available |
| 76 | + page.locator("#UI_NEW_SLOT_SELECTION_ID_359119").check() |
| 77 | + page.get_by_role("button", name="Save").click() |
| 78 | + expect(page.get_by_text("Appointment booked")).to_be_visible() |
| 79 | + |
| 80 | + batch_processing( |
| 81 | + page, |
| 82 | + "A183", |
| 83 | + "Practitioner Clinic 1st Appointment", |
| 84 | + "A25 - 1st Colonoscopy Assessment Appointment Booked, letter sent", |
| 85 | + ) |
| 86 | + |
| 87 | + batch_processing( |
| 88 | + page, |
| 89 | + "A183", |
| 90 | + "GP Result (Abnormal)", |
| 91 | + "A25 - 1st Colonoscopy Assessment Appointment Booked, letter sent", |
| 92 | + ) |
| 93 | + page.locator("#ID_LINK_EPISODES_img").click() |
| 94 | + page.get_by_role("link", name="FOBT Screening").click() |
| 95 | + expect( |
| 96 | + page.get_by_role("cell", name="A167 - GP Abnormal FOBT Result Sent", exact=True) |
| 97 | + ).to_be_visible() |
| 98 | + Logout(page).log_out() |
0 commit comments