Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
},
"cSpell.words": [
"addopts",
"analyser",
"Analysers",
"autouse",
"BCSS",
"behaviour",
"codegen",
"colonoscopist",
"customisable",
"customised",
"initialise",
Expand Down
9 changes: 9 additions & 0 deletions pages/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ def go_to_screening_subject_search_page(self) -> None:
"""Click the Base Page 'Screening Subject Search' link."""
self.click(self.screening_subject_search_page)

def go_to_page(self, navigation_steps: list[str]) -> None:
"""Clicks the navigation links in the list provided.
Args:
navigation_steps (list[str]): the links you want to navigate through in order
"""
for intended_page in navigation_steps:
self.page.get_by_role("link", name=intended_page).click()
logging.info(f"navigated to {intended_page}")

def click(self, locator: Locator) -> None:
# Alerts table locator
alerts_table = locator.get_by_role("table", name="cockpitalertbox")
Expand Down
18 changes: 14 additions & 4 deletions pages/contacts_list/view_contacts_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from playwright.sync_api import Page, expect
import logging
from playwright.sync_api import Page
from pages.base_page import BasePage


Expand All @@ -12,6 +13,15 @@ def __init__(self, page: Page):

def verify_view_contacts_title(self) -> None:
"""Verify the View Contacts page title is displayed correctly"""
self.bowel_cancer_screening_page_title_contains_text(
"View Contacts"
)
self.bowel_cancer_screening_page_title_contains_text("View Contacts")

def search_by_job_role_and_organisation_code(
self, job_role: str, org_code: str
) -> None:
"""
search by provided job role and organisation
"""
self.page.locator('input[name="selJobRole"]').fill(job_role)
self.page.locator('input[name="selOrganisationCode"]').fill(org_code)
self.page.get_by_role("button", name="Search").click()
logging.info(f"input {job_role} and {org_code} and click on search")
34 changes: 34 additions & 0 deletions pages/fit_test_kits/create_new_analyser_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from playwright.sync_api import Page
from pages.base_page import BasePage


class CreateNewAnalyserPage(BasePage):
"""Create New Analyser page locators and methods for interacting with the page."""

def __init__(self, page: Page):
super().__init__(page)
self.page = page
# Create New Analyser - page locators, methods
self.analyser_code_textbox = page.get_by_role("textbox", name="Analyser Code")
self.analyser_name_textbox = page.get_by_role("textbox", name="Analyser Name")
self.serial_number_textbox = page.get_by_role("textbox", name="Serial Number")
self.start_date_textbox = page.get_by_role("textbox", name="Start Date")
self.software_version_textbox = page.get_by_role(
"textbox", name="Software Version"
)
self.software_start_date_textbox = page.locator("#softwareStartDate")
self.software_start_time_textbox = page.locator("#softwarestarttime")
self.end_date_textbox = page.get_by_role("textbox", name="End Date")
self.lookup_link = page.get_by_role("link", name="Lookup")
self.save_button = page.get_by_role("button", name="Save")

def verify_create_new_analyser_title(self) -> None:
"""Verify the Create New Analyser page title is displayed correctly."""
self.bowel_cancer_screening_page_title_contains_text("Create New Analyser")

def select_analyser_from_lookup(self, analyser_type: str) -> None:
"""Presses lookup link and selects the Analyser Type specified"""
self.lookup_link.click()
self.page.locator(
f"input[type='radio'][onclick*=\"'{analyser_type}'\"]"
).check()
14 changes: 14 additions & 0 deletions pages/fit_test_kits/edit_analyser_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from playwright.sync_api import Page
from pages.fit_test_kits.create_new_analyser_page import CreateNewAnalyserPage


class EditAnalyserPage(CreateNewAnalyserPage):
"""Edit Analyser page locators and methods for interacting with the page."""

def __init__(self, page: Page):
super().__init__(page)
self.page = page

def verify_edit_analyser_title(self) -> None:
"""Verify the Edit Analyser page title is displayed correctly."""
self.bowel_cancer_screening_page_title_contains_text("Edit Analyser")
6 changes: 5 additions & 1 deletion pages/fit_test_kits/maintain_analysers_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from playwright.sync_api import Page, expect
from playwright.sync_api import Page
from pages.base_page import BasePage


Expand All @@ -9,6 +9,10 @@ def __init__(self, page: Page):
super().__init__(page)
self.page = page
# Maintain Analysers - page locators, methods
self.analysers_table = page.locator("#analyserTableDiv")
self.create_new_analyser_button = page.get_by_role(
"button", name="Create New Analyser"
)

def verify_maintain_analysers_title(self) -> None:
"""Verify the Maintain Analysers page title is displayed correctly."""
Expand Down
19 changes: 18 additions & 1 deletion pages/lynch_surveillance/set_lynch_invitation_rates_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from playwright.sync_api import Page, expect
import logging
from playwright.sync_api import Page, expect, Locator
from pages.base_page import BasePage


Expand All @@ -15,3 +16,19 @@ def verify_set_lynch_invitation_rates_title(self) -> None:
self.bowel_cancer_screening_page_title_contains_text(
"Set Lynch Surveillance Invitation Rates"
)

def get_lynch_invitation_rate(self, screening_centre_id: str) -> Locator:
return self.page.locator(f'[id="{screening_centre_id}"]')

def set_lynch_invitation_rate(self, screening_centre_id: str, rate: str) -> None:
"""
set lynch invitation rate
"""
self.get_lynch_invitation_rate(screening_centre_id).fill(rate)

logging.info(f"input {rate } for screening centre id {screening_centre_id} ")

def click_set_rates(self) -> None:
self.page.get_by_role("button", name="Set Rates").click()
expect(self.page.locator("#alert")).to_contain_text("×Successfully updated")
logging.info("click set rates")
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import logging
from playwright.sync_api import Page, expect

class CommunicationTypeByGpPracticePage:

def __init__(self,page:Page):
self.page=page

def select_screening_centre(self,screening_centre:str) -> None:
"""
selects a screening centre and verifies the report has been generated
"""

self.page.get_by_label("Screening Centre").select_option(screening_centre)
logging.info(f"{screening_centre} selected")
expect(self.page.locator("#ntshPageTitle")).to_contain_text("Communication Type for GP Practices")
expect(self.page.locator("#displayInputParameters")).to_contain_text("Report generated on:")


Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def search_subject_with_args(
# Only click search if at least one field was filled
if any([surname, forename, screening_status, episode_status]):
self.click(self.search_button)
self.click(self.back_link)



class ScreeningStatusSearchOptions(Enum):
Expand Down
25 changes: 24 additions & 1 deletion tests/test_contacts_list_page.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import pytest
from playwright.sync_api import Page
from playwright.sync_api import Page, expect
from pages.base_page import BasePage
from pages.contacts_list.contacts_list_page import ContactsListPage
from pages.contacts_list.view_contacts_page import ViewContactsPage
Expand Down Expand Up @@ -54,3 +55,25 @@ def test_contacts_list_page_navigation(page: Page) -> None:
# Return to main menu
BasePage(page).click_main_menu_link()
BasePage(page).main_menu_header_is_displayed()


def test_view_contacts_accredited_screening_colonoscopist(page: Page) -> None:
"""
Navigate to contact list, search for Accredited* role and BCS001 organisation and select the role link next to a contact.
Expects the View Details page to have the role Accredited Screening Colonoscopist.
"""

BasePage(page).go_to_page(["View Contacts"])
ViewContactsPage(page).search_by_job_role_and_organisation_code(
"Accredited*", "BCS001"
)

page.get_by_role(
"row",
name="Legroom Sensitive Accredited Screening Colonoscopist BCS001 Wolverhampton Bowel Cancer Screening Centre",
exact=True,
).get_by_role("link").click()
expect(page.locator('form[name="frm"]')).to_contain_text(
"Accredited Screening Colonoscopist"
)
logging.info("results contain name Legroom Sensitive")
50 changes: 49 additions & 1 deletion tests/test_fit_test_kits_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import datetime
import uuid
import pytest
from playwright.sync_api import Page
from playwright.sync_api import Page, expect
from pages.base_page import BasePage
from pages.fit_test_kits.create_new_analyser_page import CreateNewAnalyserPage
from pages.fit_test_kits.edit_analyser_page import EditAnalyserPage
from pages.fit_test_kits.fit_test_kits_page import FITTestKitsPage
from pages.fit_test_kits.fit_rollout_summary_page import FITRolloutSummaryPage
from pages.fit_test_kits.log_devices_page import LogDevicesPage
Expand Down Expand Up @@ -98,3 +102,47 @@ def test_fit_test_kits_page_navigation(page: Page, general_properties: dict) ->
# Return to main menu
BasePage(page).click_main_menu_link()
BasePage(page).main_menu_header_is_displayed()


def test_add_and_edit_a_new_analyser(page: Page) -> None:
"""Create a new analyser and then edit it to have an end date of tomorrow"""
today = datetime.date.today()
unique_id = str(uuid.uuid4())[:8]
analyser_code = f"AUTO{unique_id}"
analyser_name = f"Autotest{unique_id}"
serial_number = f"SN{unique_id}"
BasePage(page).go_to_page(["Maintain Analysers"])

maintain_analysers_page = MaintainAnalysersPage(page)
maintain_analysers_page.create_new_analyser_button.click()
create_new_analyser_page = CreateNewAnalyserPage(page)
create_new_analyser_page.analyser_code_textbox.fill(analyser_code)
create_new_analyser_page.analyser_name_textbox.fill(analyser_name)
create_new_analyser_page.serial_number_textbox.fill(serial_number)
create_new_analyser_page.start_date_textbox.fill(today.strftime("%d/%m/%Y"))
create_new_analyser_page.select_analyser_from_lookup("PLEDIA")
create_new_analyser_page.software_version_textbox.fill("1")
create_new_analyser_page.software_start_date_textbox.fill(
today.strftime("%d/%m/%Y")
)
create_new_analyser_page.software_start_time_textbox.fill("08:00")
create_new_analyser_page.save_button.click()

expect(maintain_analysers_page.analysers_table).to_contain_text(analyser_code)
edit_button = page.get_by_role(
"row",
name=f"BCS01 {analyser_code} {analyser_name} {today.strftime("%d %b %Y")} End Date Edit",
exact=True,
).locator("#edit")
edit_button.click()
tomorrow = today + datetime.timedelta(days=1)
edit_analyser_page = EditAnalyserPage(page)
edit_analyser_page.end_date_textbox.fill(tomorrow.strftime("%d/%m/%Y"))
edit_analyser_page.save_button.click()
expect(
page.get_by_role(
"row",
name=f"BCS01 {analyser_code} {analyser_name} {today.strftime("%d %b %Y")} {tomorrow.strftime("%d %b %Y")} Edit",
exact=True,
)
).to_be_visible()
55 changes: 53 additions & 2 deletions tests/test_lynch_surveillance_page.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import random
from typing import Generator
import pytest
from playwright.sync_api import Page
from playwright.sync_api import Page, expect
from pages.base_page import BasePage
from pages.lynch_surveillance.lynch_invitation_page import LynchInvitationPage
from pages.lynch_surveillance.set_lynch_invitation_rates_page import SetLynchInvitationRatesPage
from pages.lynch_surveillance.set_lynch_invitation_rates_page import (
SetLynchInvitationRatesPage,
)
from utils.user_tools import UserTools


Expand All @@ -19,6 +23,20 @@ def before_each(page: Page):
BasePage(page).go_to_lynch_surveillance_page()


@pytest.fixture
def reset_lynch_invitation_rate(page: Page) -> Generator[None, None, None]:
"""
Teardown fixture for resetting Lynch invitation Rates to environment defaults
"""
yield
page.get_by_role("link", name="Main Menu").click()
BasePage(page).go_to_page(["Lynch Surveillance", "Set Lynch Invitation Rates"])
set_lynch_invitation_rate_page = SetLynchInvitationRatesPage(page)
set_lynch_invitation_rate_page.set_lynch_invitation_rate("2", "10")
set_lynch_invitation_rate_page.set_lynch_invitation_rate("3", "5")
set_lynch_invitation_rate_page.click_set_rates()


@pytest.mark.smoke
def test_lynch_surveillance_page_navigation(page: Page) -> None:
"""
Expand All @@ -32,3 +50,36 @@ def test_lynch_surveillance_page_navigation(page: Page) -> None:
# Return to main menu
BasePage(page).click_main_menu_link()
BasePage(page).main_menu_header_is_displayed()


def test_set_lynch_invitation_rate(
page: Page, reset_lynch_invitation_rate: None
) -> None:
"""
Navigate to Lynch Surveillance Set Lynch Invitation Rates page, set random invitation rates for Wolverhampton and Coventry centres.
Verify the rates are saved correctly by navigating back and checking the values match what was set.
"""

LynchInvitationPage(page).go_to_page(["Set Lynch Invitation Rates"])

set_lynch_invitation_rate_page = SetLynchInvitationRatesPage(page)

wolverhampton_invitation_rate = str(random.randrange(1, 9))
coventry_invitation_rate = str(random.randrange(1, 9))

set_lynch_invitation_rate_page.set_lynch_invitation_rate(
"2", wolverhampton_invitation_rate
)
set_lynch_invitation_rate_page.set_lynch_invitation_rate(
"3", coventry_invitation_rate
)
set_lynch_invitation_rate_page.click_set_rates()

page.get_by_role("link", name="Back").click()
page.get_by_role("link", name="Set Lynch Invitation Rates").click()
expect(set_lynch_invitation_rate_page.get_lynch_invitation_rate("2")).to_have_value(
wolverhampton_invitation_rate
)
expect(set_lynch_invitation_rate_page.get_lynch_invitation_rate("3")).to_have_value(
coventry_invitation_rate
)
20 changes: 20 additions & 0 deletions tests/test_reports_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import logging
import pytest
from playwright.sync_api import Page, expect
from pages.base_page import BasePage
from pages.reports.operational.communication_type_by_gp_practice_page import (
CommunicationTypeByGpPracticePage,
)
from pages.reports.reports_page import ReportsPage
from utils.date_time_utils import DateTimeUtils
from utils.user_tools import UserTools
Expand Down Expand Up @@ -517,3 +521,19 @@ def test_operational_reports_screening_practitioner_appointments(
expect(ReportsPage(page).common_report_timestamp_element).to_contain_text(
report_timestamp
)


def test_report_communication_type_for_gp_practices(page: Page) -> None:
"""
Navigate to the Operational Reports and Communication Type for GP, select Wolverhampton Bowel Cancer Screening Centre.
On the results page assert the page title and report generated on and selected GP Practices
"""
BasePage(page).go_to_page(["Operational Reports", "Communication Type for GP"])

CommunicationTypeByGpPracticePage(page).select_screening_centre(
"Wolverhampton Bowel Cancer Screening Centre"
)

for gp_practice_code in ["C81002", "M87041"]:
expect(page.locator("#listReportDataTable")).to_contain_text(gp_practice_code)
logging.info(f"results include the GP practice code {gp_practice_code}")
Loading