Skip to content

Commit

Permalink
Refactoring, added pom for reports and added more reports test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyg79 committed Nov 22, 2024
1 parent 6c54e3c commit faa5114
Show file tree
Hide file tree
Showing 18 changed files with 512 additions and 87 deletions.
57 changes: 55 additions & 2 deletions pages/bcss_home_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


class BcssHomePage:

def __init__(self, page: Page):
self.page = page
# Homepage links
self.sub_menu_link = self.page.get_by_role("link", name="Show Sub-menu")
self.hide_sub_menu_link = self.page.get_by_role("link", name="Hide Sub-menu")
self.select_org_link = self.page.get_by_role("link", name="Select Org")
Expand All @@ -14,7 +14,6 @@ def __init__(self, page: Page):
self.user_guide_link = self.page.get_by_role("link", name="User guide")
self.help_link = self.page.get_by_role("link", name="Help")


def click_sub_menu_link(self):
self.sub_menu_link.click()

Expand All @@ -38,3 +37,57 @@ def click_user_guide_link(self):

def click_help_link(self):
self.help_link.click()


class MainMenu:
def __init__(self, page: Page):
self.page = page
# Main menu - page links
self.contacts_list_page = self.page.get_by_role("link", name="Contacts List")
self.bowel_scope_page = self.page.get_by_role("link", name="Bowel Scope")
self.call_and_recall_page = self.page.get_by_role("link", name="Call and Recall")
self.communications_production_page = self.page.get_by_role("link", name="Communications Production")
self.download_page = self.page.get_by_role("link", name="Download")
self.fit_test_kits_page = self.page.get_by_role("link", name="FIT Test Kits")
self.gfob_test_kits_page = self.page.get_by_role("link", name="gFOBT Test Kits")
self.lynch_surveillance_page = self.page.get_by_role("link", name="Lynch Surveillance")
self.organisations_page = self.page.get_by_role("link", name="Organisations")
self.reports_page = self.page.get_by_role("link", name="Reports")
self.screening_practitioner_appointments_page = self.page.get_by_role("link", name="Screening Practitioner")
self.screening_subject_search_page = self.page.get_by_role("link", name="Screening Subject Search")

def go_to_contacts_list_page(self):
self.contacts_list_page.click()

def go_to_bowel_scope_page(self):
self.bowel_scope_page.click()

def go_to_call_and_recall_page(self):
self.call_and_recall_page.click()

def go_to_communications_production_page(self):
self.communications_production_page.click()

def go_to_download_page(self):
self.download_page.click()

def go_to_fit_test_kits_page(self):
self.fit_test_kits_page.click()

def go_to_gfob_test_kits_page(self):
self.gfob_test_kits_page.click()

def go_to_lynch_surveillance_page(self):
self.lynch_surveillance_page.click()

def go_to_organisations_page(self):
self.organisations_page.click()

def go_to_reports_page(self):
self.reports_page.click()

def go_to_screening_practitioner_appointments_page(self):
self.screening_practitioner_appointments_page.click()

def go_to_screening_subject_search_page(self):
self.screening_subject_search_page.click()
4 changes: 3 additions & 1 deletion pages/login.py → pages/login_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from playwright.sync_api import Page, expect
from playwright.sync_api import Page


class BcssLoginPage:

def __init__(self, page: Page):
Expand Down
109 changes: 109 additions & 0 deletions pages/reports_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from datetime import datetime
from utils import date_time_utils
from playwright.sync_api import Page


class ReportsPageUtils:
def __init__(self):
pass


# Timestamp Date Formatting
def report_timestamp_date_format() -> str:
"""Gets the current date time and converts it to the timestamp format used on the report pages
Returns:
date report last requested (str): The current datetime in the "date report last requested" timestamp format.
"""
dtu = date_time_utils.DateTimeUtils
return dtu.format_date(datetime.now(), "%d/%m/%Y" + " at " + "%H:%M:%S")


def fobt_kits_logged_but_not_read_report_timestamp_date_format() -> str:
"""Gets the current date time and converts it to the timestamp format used on the fobt_kits_logged_but_not_read report page
Returns:
fobt_kits_logged_but_not_read timestamp (str): The current datetime in the "fobt_kits_logged_but_not_read report" timestamp format.
"""
dtu = date_time_utils.DateTimeUtils
return dtu.format_date(datetime.now(), "%d %b %Y %H:%M:%S")


def screening_practitioner_appointments_report_timestamp_date_format() -> str:
"""Gets the current date time and converts it to the timestamp format used on the screening practitioner appointments report page
Returns:
screening practitioner appointments timestamp (str): The current datetime in the "screening practitioner appointments report" timestamp format.
"""
dtu = date_time_utils.DateTimeUtils
return dtu.format_date(datetime.now(), "%d.%m.%Y" + " at " + "%H:%M:%S")


# Reports page main menu links
def go_to_failsafe_reports_page(page: Page) -> None:
page.get_by_role("link", name="Failsafe Reports").click()


def go_to_operational_reports_page(page: Page) -> None:
page.get_by_role("link", name="Operational Reports").click()


def go_to_strategic_reports_page(page: Page) -> None:
page.get_by_role("link", name="Strategic Reports").click()


def go_to_cancer_waiting_times_reports_page(page: Page) -> None:
page.get_by_role("link", name="Cancer Waiting Times Reports").click()


def go_to_dashboard(page: Page) -> None:
page.get_by_role("link", name="Dashboard").click()


# Failsafe Reports menu links
def go_to_date_report_last_requested_page(page: Page) -> None:
page.get_by_role("link", name="Date Report Last Requested").click()


def go_to_screening_subjects_with_inactive_open_episode_link_page(page: Page) -> None:
page.get_by_role("link", name="Screening Subjects With").click()


def go_to_subjects_ceased_due_to_date_of_birth_changes_page(page: Page) -> None:
page.get_by_role("link", name="Subjects Ceased Due to Date").click()


def go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page(page: Page) -> None:
page.get_by_role("link", name="Allocate SC for Patient Movements within Hub Boundaries").click()


def go_to_allocate_sc_for_patient_movements_into_your_hub_page(page: Page) -> None:
page.get_by_role("link", name="Allocate SC for Patient Movements into your Hub").click()


def go_to_identify_and_link_new_gp_page(page: Page) -> None:
page.get_by_role("link", name="Identify and link new GP").click()


# Operational Reports menu links
def go_to_appointment_attendance_not_updated_page(page: Page) -> None:
page.get_by_role("link", name="Appointment Attendance Not").click()


def go_to_fobt_kits_logged_but_not_read_page(page: Page) -> None:
page.get_by_role("link", name="FOBT Kits Logged but Not Read").click()


def go_to_demographic_update_inconsistent_with_manual_update_page(page: Page) -> None:
page.get_by_role("link", name="Demographic Update").click()


def go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page(page: Page) -> None:
page.get_by_role("link", name="Screening Practitioner 6").click()


def go_to_screening_practitioner_appointments_page(page: Page) -> None:
page.get_by_role("link", name="Screening Practitioner Appointments").click()
11 changes: 5 additions & 6 deletions tests/test_bowel_scope_page.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to bowel scope page
page.get_by_role("link", name="Bowel Scope").click()
expect(page.locator("#ntshPageTitle")).to_contain_text("Bowel Scope")

MainMenu(page).go_to_bowel_scope_page()

@pytest.mark.smoke
def test_bowel_scope_page_navigation(page: Page) -> None:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_call_and_recall_page.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to call and recall page
page.get_by_role("link", name="Call and Recall").click()
expect(page.locator("#ntshPageTitle")).to_contain_text("Call and Recall")
MainMenu(page).go_to_call_and_recall_page()


@pytest.mark.smoke
Expand Down
9 changes: 4 additions & 5 deletions tests/test_communications_production_page.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage
from pages.login_page import BcssLoginPage
from pages.bcss_home_page import MainMenu


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to communications production page
page.get_by_role("link", name="Communications Production").click()

MainMenu(page).go_to_communications_production_page()

@pytest.mark.smoke
def test_communications_production_page_navigation(page: Page) -> None:
Expand Down
9 changes: 5 additions & 4 deletions tests/test_contacts_list_page.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to contacts list page
page.get_by_role("link", name="Contacts List").click()
MainMenu(page).go_to_contacts_list_page()


@pytest.mark.smoke
Expand Down
9 changes: 5 additions & 4 deletions tests/test_download_page.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to download page
page.get_by_role("link", name="Download").click()
MainMenu(page).go_to_download_page()


@pytest.mark.smoke
Expand Down
9 changes: 5 additions & 4 deletions tests/test_fit_test_kits_page.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to fit test kits page
page.get_by_role("link", name="FIT Test Kits").click()
MainMenu(page).go_to_fit_test_kits_page()


@pytest.mark.smoke
Expand Down
9 changes: 5 additions & 4 deletions tests/test_gfobt_test_kits_page.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage

from pages.bcss_home_page import MainMenu
from pages.login_page import BcssLoginPage


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()

# Go to gFOBT test kits page
page.get_by_role("link", name="gFOBT Test Kits").click()
MainMenu(page).go_to_gfob_test_kits_page()


@pytest.mark.smoke
Expand Down
9 changes: 4 additions & 5 deletions tests/test_home_page_links.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import pytest
from playwright.sync_api import Page, expect
from pages.login import BcssLoginPage
from pages.login_page import BcssLoginPage
from pages.bcss_home_page import BcssHomePage
from utils.date_time_utils import DateTimeUtils


@pytest.fixture(scope="function", autouse=True)
def before_each(page: Page):
# Log in to BCSS
login_page = BcssLoginPage(page)
login_page.login_as_user_bcss401()
BcssLoginPage(page).login_as_user_bcss401()


@pytest.mark.smoke
Expand Down Expand Up @@ -51,14 +50,14 @@ def test_home_page_links_navigation(page: Page) -> None:

# Click the user guide link
with page.expect_popup() as page1_info:
# Check the user guide link works
# Check the user guide link works
page.get_by_role("link", name="User guide").click()
# Check that the user guide page can be accessed
page1 = page1_info.value

# Click 'help' link
with page.expect_popup() as page2_info:
# Check the help link works
# Check the help link works
page.get_by_role("link", name="Help").click()
# Check that the help page can be accessed
page2 = page2_info.value
Loading

0 comments on commit faa5114

Please sign in to comment.