Skip to content

Commit

Permalink
Ravs 961 update record a vaccine tests (#31)
Browse files Browse the repository at this point in the history
* Fixed failing add existing batch test

* Fixed fa

* Fixed assessment page fields

* Fixed consent page fields and site vaccine, batch fields

* Fixed vaccinated page field, giving a first stan now to see if all tests pass

* Fixed failing age based warning tests

* Sorted record a vaccine tests hopefully

* Sorted record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

* Sorted most of record a vaccine tests hopefully

---------

Co-authored-by: root <root@FA-0817>
  • Loading branch information
neelimaguntupalli1-nhs and root authored Nov 6, 2024
1 parent dd655e7 commit 55bfb1a
Show file tree
Hide file tree
Showing 32 changed files with 609 additions and 449 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"cSpell.words": [
"CAREHOME",
"immunisation",
"organisation"
"organisation",
"WHITESTONES"
]
}
86 changes: 21 additions & 65 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pages.add_vaccines_page import *
# from pages.add_vaccines_page import *
from pages.settings_page import *
from pages.site_vaccine_batches_page import *
from pages.vaccines_page import *
Expand Down Expand Up @@ -107,46 +107,6 @@ def navigate_to_ravs(request):
navigate_to_ravs_login_page(url)
return True

# Fixture for clicking back button
@pytest.fixture(scope='function')
def click_back_button_recording_consent(request):
click_back_button()

def set_vaccinator_location(site, care_model):
select_site(site)
select_care_model(care_model)
if care_model == "Care Home":
enter_carehome_name("WHITESTONES CARE HOME")
click_continue_to_record_a_vaccination_homepage()

@pytest.fixture(scope='function')
def login_and_navigate_to_homepage(request, navigate_and_login):
click_continue_to_record_a_vaccination_homepage()

# Fixture for logging in and navigating to appointments open first patient
@pytest.fixture(scope='function')
def login_and_navigate_to_appointments_open_first_patient(request, navigate_and_login):
attach_screenshot("user_has_logged_in")
site = "ST JOHN'S HOUSE"
care_model = "Vaccination Centre"
select_site(site)
attach_screenshot("user_has_selected_site")
select_care_model(care_model)
if care_model == "Care Home":
enter_carehome_name("WHITESTONES CARE HOME")
attach_screenshot("user_has_selected_site")
attach_screenshot("user_has_selected_care_model")
click_continue_to_record_a_vaccination_homepage()
attach_screenshot("user_has_clicked_continue_to_ravs_homepage")
current_date = datetime.now()
fromDate = datetime(2023, 12, 1)
set_from_date(fromDate)
click_active_from_date()
toDate = datetime.today()
set_to_date(toDate)
click_active_to_date_today()
click_first_patient()

# Fixture for logging in and navigating to find a patient
@pytest.fixture(scope='function')
def login_and_navigate_to_find_a_patient(request):
Expand Down Expand Up @@ -242,13 +202,13 @@ def check_site_vaccine_type_has_active_batch(site, vaccine, vaccine_type, batch_
# If the batch does NOT currently exist, add a batch
# This adds an active batch, so we don't need to do further checks
click_view_product(site, vaccine_type)
if not check_batch_number_exists(batch_number, True):
if not check_batch_number_and_expiry_date_exists(batch_number, expiry_date, True):
add_vaccine_type_batch(batch_number, expiry_date)
return True

# If we get this far, the batch does exists but is currently INACTIVE
# This reactivates the batch
if not check_batch_number_is_active(batch_number, True):
if not check_batch_number_is_active_with_date(batch_number, expiry_date, True):
click_reactivate_batch_link(batch_number)
click_reactivate_batch_confirmation_button()

Expand All @@ -259,30 +219,29 @@ def add_site_vaccine(site, vaccine, vaccine_type, batch_number, expiry_date):
# vaccines_choose_site_page
enter_site_name(site)
select_site_from_list(site)
click_continue_button()
click_continue_to_add_vaccine_button()

# choose_vaccine_page
click_vaccine_radiobutton(vaccine)
click_vaccine_type_radiobutton(vaccine_type)
click_continue_button()
click_vaccine_radiobutton_on_add_vaccine_screen(vaccine)
click_vaccine_type_radiobutton_on_add_vaccine_screen(vaccine_type)
click_continue_to_add_batch_button()

# vaccines_add_batch_page
enter_batch_number(batch_number)
enter_expiry_date(expiry_date)
click_continue_button()
click_continue_to_confirm_batch_details_button()

# vaccines_check_and_confirm_page
click_confirm_button()
click_confirm_add_vaccine_and_batch_button()

def add_vaccine_type_batch(batch_number, expiry_date):
click_add_batch_link()
# vaccines_add_batch_page
enter_batch_number(batch_number)
enter_expiry_date(expiry_date)
click_continue_button()
click_continue_to_confirm_batch_details_button()

# vaccines_check_and_confirm_page
click_confirm_button()
click_confirm_add_vaccine_and_batch_button()

def assess_patient_with_details_and_click_continue_to_consent(eligible_decision, eligibility_type, staff_role, assessing_clinician, due_date, assessment_date, legal_mechanism, assessment_outcome, assessment_comments, eligibility_assessment_no_vaccine_given_reason=None):

Expand Down Expand Up @@ -324,9 +283,11 @@ def assess_patient_with_details_and_click_continue_to_consent(eligible_decision,
attach_screenshot("clicked_continue_to_record_consent_button")


def record_consent_details_and_click_continue_to_vaccinate(consent_decision, consent_given_by, person_consenting_name, relationship_to_patient, consent_clinician, no_consent_reason=None):
def record_consent_details_and_click_continue_to_vaccinate(consent_decision, consent_given_by, person_consenting_name, relationship_to_patient, consent_clinician, legal_mechanism, no_consent_reason=None):
attach_screenshot("before_selecting_consent_clinician")
select_consent_clinician_with_name_and_council(consent_clinician)

if (legal_mechanism) != "Patient Group Direction (PGD)":
select_consent_clinician_with_name_and_council(consent_clinician)

if consent_decision.lower() == 'yes':
click_yes_to_consent()
Expand All @@ -347,22 +308,17 @@ def record_consent_details_and_click_continue_to_vaccinate(consent_decision, co
click_save_and_return_button_on_record_consent_page()
attach_screenshot("patient_decided_to_not_consent_saved_and_returned")

def enter_vaccine_details_and_click_continue_to_check_and_confirm(vaccinate_decision, care_model, vaccination_date, vaccine, vaccine_type2, vaccination_site, batch_number, batch_expiry_date, dose_amount, vaccinator, vaccination_comments, no_vaccination_reason=None):
def enter_vaccine_details_and_click_continue_to_check_and_confirm(vaccinate_decision, care_model, vaccination_date, vaccine, vaccine_type2, vaccination_site, batch_number, batch_expiry_date, dose_amount, vaccinator, vaccination_comments, legal_mechanism, no_vaccination_reason=None):
if vaccinate_decision.lower() == 'yes':
click_yes_vaccinated_radiobutton()

if "covid" in (vaccine).lower():
click_covid_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2)
elif "flu" in (vaccine).lower():
click_flu_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2)
elif "rsv" in (vaccine).lower():
click_rsv_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2)
elif "pertussis" in (vaccine).lower():
click_pertussis_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2)

click_vaccine_type(vaccine_type2)
set_vaccination_date(vaccination_date)
click_care_model_option(care_model)
select_vaccinator_name_and_council(vaccinator)
if care_model == "Care home":
enter_care_home_details("WHITESTONES CARE HOME")
if (legal_mechanism) != "Patient Group Direction (PGD)":
select_vaccinator_name_and_council(vaccinator)
enter_vaccination_comments(vaccination_comments)
select_vaccination_site(vaccination_site)
batch_number_to_select = batch_number.upper() + " - " + batch_expiry_date
Expand Down
12 changes: 6 additions & 6 deletions features/record_a_vaccine_for_patient_with_nhs_number.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ Feature: Record vaccine
| 12 | 9437540233 | ALBERT HOUSE | Hospital Hub | yes | today-15 | yes | yes | today-7 | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | SDYY2-18E | 19/10/2026 |
| 8 | 9474376638 | BECCLES HOUSE | Care Home | yes | today-32 | yes | yes | today-30 | PHYLLIDA ZYLKO | 6/2/1968 | BELL FARM BUNGALOW, CATON GREEN, BROOKHOUSE, LANCASTER, LA2 9JG | Flu | SDYY2-18F | 19/10/2026 |
| 9 | 9474405174 | BIRCH HOUSE | Home Of Housebound Patient | yes | today | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-19A | 19/10/2026 |
| 10 | 9474405174 | ALBERT HOUSE | Off-site Outreach Event | yes | today-2 | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-14B | 19/10/2026 |
| 10 | 9474405174 | ALBERT HOUSE | Off-site Outreach Event | yes | today-2 | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-14B | 5/5/2025 |
| 11 | 9450134391 | BECCLES HOUSE | Vaccination Centre | yes | today-3 | yes | yes | today | MARIAN PIESSE | 17/7/1994 | 2 BIRCH STREET, LYTHAM ST. ANNES, LANCS, FY8 5DT | Flu | SDYY2-14C | 19/10/2026 |
| 12 | 9450140960 | BIRCH HOUSE | Hospital Hub | yes | today-1 | yes | yes| today | DEANA GAMBLES | 5/9/1993 | 10 GRASMERE ROAD, LYTHAM ST. ANNES, LANCS, FY8 2HZ | Flu | SDYY2-20A | 19/10/2026 |
| 1 | 9450141444 | ALBERT HOUSE | Care Home | yes | today-4 | yes | yes | today-2 | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | SDYY2-21A | 19/10/2026 |
| 2 | 9450141711 | BECCLES HOUSE | Home Of Housebound Patient | yes | today-2| yes | yes | today-1 | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | SDYY2-22A | 19/10/2026 |
| 1 | 9450141444 | ALBERT HOUSE | Care Home | yes | today-4 | yes | yes | today-2 | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | SDYY2-21A | 5/5/2025 |
| 2 | 9450141711 | BECCLES HOUSE | Home Of Housebound Patient | yes | today-2| yes | yes | today-1 | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | SDYY2-22A | 5/5/2025 |
| 3 | 9450144699 | BIRCH HOUSE | Off-site Outreach Event | yes | today-1 | yes | yes | today-1 | HOPE TULLY | 10/1/1993 | 2 CHAPEL CLOSE, WESHAM, PRESTON, PR4 3HB | Flu | SDYY2-23A | 19/10/2026 |
| 4 | 9437541817 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | SDYY2-24A | 19/10/2026 |
| 4 | 9437541817 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | SDYY2-24A | 5/5/2025 |

@recordvaccine
Scenario Outline: Record a maternity vaccine with nhs number
Given I login to RAVS and set vaccinator details with <site> and <care_model> and get patient details for <nhs_number> with option <index> and choose to vaccinate with vaccine details as <chosen_vaccine>, <vaccine_type>, <batch_number> with <batch_expiry_date>
And I search for a patient with the NHS number in the find a patient screen
And I open the patient record by clicking on patient <name>
When I click choose vaccine button and choose the <chosen_vaccine>, <vaccine_type>, <batch_number> with <batch_expiry_date> and click continue
And I assess the pregnant patient's <eligibility> with the details and date as <assess_date> and click continue to record consent screen button
And I assess the pregnant patient's <eligibility> with the details of due date as <due_date> and assessment date as <assess_date> and click continue to record consent screen button
And I record <consent> with the details and click continue to vaccinate button
And I record <vaccination> details and date as <vaccination_date> and click Continue to Check and confirm screen
Then I need to be able to see the patient <name>, <dob>, <address> and vaccination details on the check and confirm screen
Expand All @@ -57,7 +57,7 @@ Feature: Record vaccine

Examples:
| index | nhs_number | site | care_model | eligibility | due_date | assess_date | consent | vaccination | vaccination_date | name | dob | address | chosen_vaccine | vaccine_type | batch_number | batch_expiry_date |
| 4 | 9473629885 | KINGSTON HOUSE | Off-site Outreach Event | yes | today+50 | today-4 | yes | yes | today-3 | MARGIE PUCKEY | 27/5/1924 | MANSART COURT, 10 OLIVE SHAPLEY AVENUE, MANCHESTER, M20 6QB | Respiratory syncytial virus (RSV) | Arexvy | AREX2-01A | 19/10/2026 |
| 4 | 9473629885 | KINGSTON HOUSE | Off-site Outreach Event | yes | today+50 | today-4 | yes | yes | today-3 | MARGIE PUCKEY | 27/5/1924 | MANSART COURT, 10 OLIVE SHAPLEY AVENUE, MANCHESTER, M20 6QB | Respiratory syncytial virus (RSV) | Arexvy | RSVTEST2 | 31/12/2025 |
# | 0 | 9693632109 | ALBERT HOUSE | Vaccination Centre | yes | today | today | yes | yes | today | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | Pertussis | Adacel vaccine suspension | ADAC1-27 | 19/10/2027 |
# | 1 | 9693632109 | BECCLES HOUSE | Vaccination Centre | yes | today+100 | today-1 | yes | yes | today-1 | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | Pertussis | Boostrix-IPV suspension | BST01-28B | 19/10/2028 |
# | 2 | 9470040228 | BIRCH HOUSE | Hospital Hub | yes | today+290 | today-1 | yes | yes | today | HERBERT HAAG | 14/12/1922 | 10 COASTAL ROAD, HEST BANK, LANCASTER, LA2 6HN | Pertussis | Repevax vaccine suspension | REPE11-29A | 19/2/2029 |
Expand Down
17 changes: 17 additions & 0 deletions helpers/datetimeHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ def date_format_with_name_of_month(date_str):
year = parsed_date.year
return f"{day} {month} {year}"

@staticmethod
def date_format_with_name_of_month_shortened(date_str):
try:
# Try parsing the date as '%d/%m/%Y'
parsed_date = datetime.strptime(date_str, "%d/%m/%Y")
except ValueError:
try:
# If parsing fails, try parsing as '%m/%d/%Y'
parsed_date = datetime.strptime(date_str, "%m/%d/%Y")
except ValueError:
# If parsing as both formats fails, return the original string
return date_str.strftime("%d %b %Y")

day = parsed_date.day
month = parsed_date.strftime('%b')
year = parsed_date.year
return f"{day} {month} {year}"

class DatetimeHelper(BaseDatetimeHelper):
def __init__(self):
Expand Down
45 changes: 33 additions & 12 deletions helpers/playwrightHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ def navigate_to_url(self,url):
self.page.wait_for_load_state()

def wait_for_page_to_load(self, timeout=0.1):
self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 1000)
self.page.wait_for_selector('*', timeout=timeout * 1000)
try:
self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 1000)
self.page.wait_for_selector('*', timeout=timeout * 1000)
except Exception as e:
print(f"Page did not fully load within {timeout} seconds. Proceeding anyway.")

def find_elements(self, selector):
return self.page.query_selector_all(selector)
Expand Down Expand Up @@ -161,6 +164,20 @@ def wait_for_element_to_appear(self, locator_or_element, timeout=10):

time.sleep(0.5) # Check every 0.5 seconds

def wait_for_element_to_disappear(self, locator_or_element, timeout=10):
start_time = time.time()
while True:
if time.time() - start_time > timeout:
print(f"Timeout: Element '{locator_or_element}' did not appear.")
return None

element = self.get_element(locator_or_element, wait=True)
if not element or not element.is_visible():
print(f"Element with locator '{locator_or_element}' appeared on the page.")
return True

time.sleep(0.5) # Check every 0.5 seconds

def check_element_exists(self, locator_or_element, wait=False, timeout=5):
element = self.get_element(locator_or_element, wait=wait, timeout=timeout)
if element:
Expand Down Expand Up @@ -226,8 +243,12 @@ def find_element_and_perform_action(self, locator_or_element, action, inputValue
print("Checkbox is already checked.")
elif action.lower() == "select_option":
if element.is_visible():
element.select_option(inputValue)
print(f"Selected option '{inputValue}' successfully.")
if isinstance(inputValue, int):
element.select_option(index=inputValue)
print(f"Selected option by index '{inputValue}' successfully.")
else:
element.select_option(value=inputValue)
print(f"Selected option by label '{inputValue}' successfully.")
elif action.lower() == "clear":
element.fill('')
print(f"Cleared text from the element: {element}.")
Expand Down Expand Up @@ -292,7 +313,7 @@ def release_mouse(self):
self.page.mouse.down()
self.page.mouse.up()

def get_element_by_type(self, locator_type_or_selector, locator_value=None, name=None):
def get_element_by_type(self, locator_type_or_selector, locator_value=None, name=None, exact=False):
# If locator_type_or_selector is just a string, return it as a selector
if isinstance(locator_type_or_selector, Locator):
return locator_type_or_selector # Directly return the Locator object
Expand All @@ -303,23 +324,23 @@ def get_element_by_type(self, locator_type_or_selector, locator_value=None, name

# Handle known locator types
if locator_type_or_selector == "role":
return self.page.get_by_role(locator_value, name=name)
return self.page.get_by_role(locator_value, name=name, exact=exact)
elif locator_type_or_selector == "text":
return self.page.get_by_text(locator_value)
return self.page.get_by_text(locator_value, exact=exact)
elif locator_type_or_selector == "label":
return self.page.get_by_label(locator_value)
return self.page.get_by_label(locator_value, exact=exact)
elif locator_type_or_selector == "placeholder":
return self.page.get_by_placeholder(locator_value)
elif locator_type_or_selector == "xpath":
return self.page.locator(locator_value)
elif locator_type_or_selector == "link":
return self.page.get_by_role("link", name=locator_value)
return self.page.get_by_role("link", name=locator_value, exact=exact)
elif locator_type_or_selector == "title":
return self.page.get_by_title(locator_value)
return self.page.get_by_title(locator_value, exact=exact)
elif locator_type_or_selector == "row":
return self.page.get_by_role("row", name=locator_value)
return self.page.get_by_role("row", name=locator_value, exact=exact)
elif locator_type_or_selector == "cell":
return self.page.get_by_role("cell", name=locator_value)
return self.page.get_by_role("cell", name=locator_value, exact=exact)
else:
# Log a warning for unsupported locator types
print(f"Warning: Unsupported locator type '{locator_type_or_selector}'. Assuming it is a selector.")
Expand Down
Loading

0 comments on commit 55bfb1a

Please sign in to comment.