Skip to content

Commit 9cdc583

Browse files
authored
Feature/migrate tests and utils from blueprint 1 (#5)
* Moved to new branch for signed commit * Added .env to gitignore
1 parent 7d0b923 commit 9cdc583

25 files changed

+1887
-92
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DO NOT COMMIT THIS FILE
2+
3+
BCSS_PASS=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ __pycache__/
1616
.pytest_cache/
1717
test-results/
1818
axe-reports/
19+
.env

pages/bcss_home_page.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from playwright.sync_api import Page
2+
3+
4+
class BcssHomePage:
5+
def __init__(self, page: Page):
6+
self.page = page
7+
# Homepage links
8+
self.sub_menu_link = self.page.get_by_role("link", name="Show Sub-menu")
9+
self.hide_sub_menu_link = self.page.get_by_role("link", name="Hide Sub-menu")
10+
self.select_org_link = self.page.get_by_role("link", name="Select Org")
11+
self.back_button = self.page.get_by_role("link", name="Back")
12+
self.release_notes_link = self.page.get_by_role("link", name="- Release Notes")
13+
self.refresh_alerts_link = self.page.get_by_role("link", name="Refresh alerts")
14+
self.user_guide_link = self.page.get_by_role("link", name="User guide")
15+
self.help_link = self.page.get_by_role("link", name="Help")
16+
17+
def click_sub_menu_link(self):
18+
self.sub_menu_link.click()
19+
20+
def click_hide_sub_menu_link(self):
21+
self.hide_sub_menu_link.click()
22+
23+
def click_select_org_link(self):
24+
self.select_org_link.click()
25+
26+
def click_back_button(self):
27+
self.back_button.click()
28+
29+
def click_release_notes_link(self):
30+
self.release_notes_link.click()
31+
32+
def click_refresh_alerts_link(self):
33+
self.refresh_alerts_link.click()
34+
35+
def click_user_guide_link(self):
36+
self.user_guide_link.click()
37+
38+
def click_help_link(self):
39+
self.help_link.click()
40+
41+
42+
class MainMenu:
43+
def __init__(self, page: Page):
44+
self.page = page
45+
# Main menu - page links
46+
self.contacts_list_page = self.page.get_by_role("link", name="Contacts List")
47+
self.bowel_scope_page = self.page.get_by_role("link", name="Bowel Scope")
48+
self.call_and_recall_page = self.page.get_by_role("link", name="Call and Recall")
49+
self.communications_production_page = self.page.get_by_role("link", name="Communications Production")
50+
self.download_page = self.page.get_by_role("link", name="Download")
51+
self.fit_test_kits_page = self.page.get_by_role("link", name="FIT Test Kits")
52+
self.gfob_test_kits_page = self.page.get_by_role("link", name="gFOBT Test Kits")
53+
self.lynch_surveillance_page = self.page.get_by_role("link", name="Lynch Surveillance")
54+
self.organisations_page = self.page.get_by_role("link", name="Organisations")
55+
self.reports_page = self.page.get_by_role("link", name="Reports")
56+
self.screening_practitioner_appointments_page = self.page.get_by_role("link", name="Screening Practitioner")
57+
self.screening_subject_search_page = self.page.get_by_role("link", name="Screening Subject Search")
58+
59+
def go_to_contacts_list_page(self):
60+
self.contacts_list_page.click()
61+
62+
def go_to_bowel_scope_page(self):
63+
self.bowel_scope_page.click()
64+
65+
def go_to_call_and_recall_page(self):
66+
self.call_and_recall_page.click()
67+
68+
def go_to_communications_production_page(self):
69+
self.communications_production_page.click()
70+
71+
def go_to_download_page(self):
72+
self.download_page.click()
73+
74+
def go_to_fit_test_kits_page(self):
75+
self.fit_test_kits_page.click()
76+
77+
def go_to_gfob_test_kits_page(self):
78+
self.gfob_test_kits_page.click()
79+
80+
def go_to_lynch_surveillance_page(self):
81+
self.lynch_surveillance_page.click()
82+
83+
def go_to_organisations_page(self):
84+
self.organisations_page.click()
85+
86+
def go_to_reports_page(self):
87+
self.reports_page.click()
88+
89+
def go_to_screening_practitioner_appointments_page(self):
90+
self.screening_practitioner_appointments_page.click()
91+
92+
def go_to_screening_subject_search_page(self):
93+
self.screening_subject_search_page.click()

pages/cognito_login_page.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from playwright.sync_api import Page
4+
5+
6+
class CognitoLoginPage:
7+
8+
def __init__(self, page: Page):
9+
self.page = page
10+
self.username = page.get_by_role("textbox", name="Username")
11+
self.password = page.get_by_role("textbox", name="Password")
12+
self.submit_button = page.get_by_role("button", name="submit")
13+
14+
def login_as_user(self, username: str, password: str) -> None:
15+
"""Logs in to bcss with specified user credentials
16+
Args:
17+
username (str) enter a username that exists in users.json
18+
password (str) the password for the user provided
19+
"""
20+
# Retrieve and enter username from users.json
21+
self.username.fill(username)
22+
# Retrieve and enter password from .env file
23+
self.password.fill(password)
24+
# Click Submit
25+
self.submit_button.click()

pages/reports_page.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
from datetime import datetime
2+
from utils import date_time_utils
3+
from playwright.sync_api import Page
4+
5+
6+
class ReportsPageUtils:
7+
def __init__(self):
8+
pass
9+
10+
11+
# Timestamp Date Formatting
12+
def report_timestamp_date_format() -> str:
13+
"""Gets the current date time and converts it to the timestamp format used on the report pages
14+
15+
Returns:
16+
date report last requested (str): The current datetime in the "date report last requested" timestamp format.
17+
18+
"""
19+
dtu = date_time_utils.DateTimeUtils
20+
return dtu.format_date(datetime.now(), "%d/%m/%Y" + " at " + "%H:%M:%S")
21+
22+
23+
def fobt_kits_logged_but_not_read_report_timestamp_date_format() -> str:
24+
"""Gets the current date time and converts it to the timestamp format used on the fobt_kits_logged_but_not_read report page
25+
26+
Returns:
27+
fobt_kits_logged_but_not_read timestamp (str): The current datetime in the "fobt_kits_logged_but_not_read report" timestamp format.
28+
29+
"""
30+
dtu = date_time_utils.DateTimeUtils
31+
return dtu.format_date(datetime.now(), "%d %b %Y %H:%M:%S")
32+
33+
34+
def screening_practitioner_appointments_report_timestamp_date_format() -> str:
35+
"""Gets the current date time and converts it to the timestamp format used on the screening practitioner appointments report page
36+
37+
Returns:
38+
screening practitioner appointments timestamp (str): The current datetime in the "screening practitioner appointments report" timestamp format.
39+
40+
"""
41+
dtu = date_time_utils.DateTimeUtils
42+
return dtu.format_date(datetime.now(), "%d.%m.%Y" + " at " + "%H:%M:%S")
43+
44+
45+
# Reports page main menu links
46+
def go_to_failsafe_reports_page(page: Page) -> None:
47+
page.get_by_role("link", name="Failsafe Reports").click()
48+
49+
50+
def go_to_operational_reports_page(page: Page) -> None:
51+
page.get_by_role("link", name="Operational Reports").click()
52+
53+
54+
def go_to_strategic_reports_page(page: Page) -> None:
55+
page.get_by_role("link", name="Strategic Reports").click()
56+
57+
58+
def go_to_cancer_waiting_times_reports_page(page: Page) -> None:
59+
page.get_by_role("link", name="Cancer Waiting Times Reports").click()
60+
61+
62+
def go_to_dashboard(page: Page) -> None:
63+
page.get_by_role("link", name="Dashboard").click()
64+
65+
66+
# Failsafe Reports menu links
67+
def go_to_date_report_last_requested_page(page: Page) -> None:
68+
page.get_by_role("link", name="Date Report Last Requested").click()
69+
70+
71+
def go_to_screening_subjects_with_inactive_open_episode_link_page(page: Page) -> None:
72+
page.get_by_role("link", name="Screening Subjects With").click()
73+
74+
75+
def go_to_subjects_ceased_due_to_date_of_birth_changes_page(page: Page) -> None:
76+
page.get_by_role("link", name="Subjects Ceased Due to Date").click()
77+
78+
79+
def go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page(page: Page) -> None:
80+
page.get_by_role("link", name="Allocate SC for Patient Movements within Hub Boundaries").click()
81+
82+
83+
def go_to_allocate_sc_for_patient_movements_into_your_hub_page(page: Page) -> None:
84+
page.get_by_role("link", name="Allocate SC for Patient Movements into your Hub").click()
85+
86+
87+
def go_to_identify_and_link_new_gp_page(page: Page) -> None:
88+
page.get_by_role("link", name="Identify and link new GP").click()
89+
90+
91+
# Operational Reports menu links
92+
def go_to_appointment_attendance_not_updated_page(page: Page) -> None:
93+
page.get_by_role("link", name="Appointment Attendance Not").click()
94+
95+
96+
def go_to_fobt_kits_logged_but_not_read_page(page: Page) -> None:
97+
page.get_by_role("link", name="FOBT Kits Logged but Not Read").click()
98+
99+
100+
def go_to_demographic_update_inconsistent_with_manual_update_page(page: Page) -> None:
101+
page.get_by_role("link", name="Demographic Update").click()
102+
103+
104+
def go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page(page: Page) -> None:
105+
page.get_by_role("link", name="Screening Practitioner 6").click()
106+
107+
108+
def go_to_screening_practitioner_appointments_page(page: Page) -> None:
109+
page.get_by_role("link", name="Screening Practitioner Appointments").click()
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
from playwright.sync_api import Page
2+
3+
4+
class ScreeningStatusSearchOptions:
5+
CALL_STATUS = "4001"
6+
INACTIVE_STATUS = "4002"
7+
RECALL_STATUS = "4004"
8+
OPT_IN_STATUS = "4003"
9+
SELF_REFERRAL_STATUS = "4005"
10+
SURVEILLANCE_STATUS = "4006"
11+
SEEKING_FURTHER_DATA_STATUS = "4007"
12+
CEASED_STATUS = "4008"
13+
BOWEL_SCOPE_STATUS = "4009"
14+
LYNCH_SURVEILLANCE_STATUS = "306442"
15+
LYNCH_SELF_REFERRAL_STATUS = "307129"
16+
17+
def __init__(self, page: Page):
18+
self.page = page
19+
20+
# Locate screening status dropdown list
21+
self.select_status = self.page.locator("#A_C_ScreeningStatus")
22+
23+
# Select screening status options
24+
def select_status_call(self):
25+
self.select_status.select_option(self.CALL_STATUS)
26+
27+
def select_status_inactive(self):
28+
self.select_status.select_option(self.INACTIVE_STATUS)
29+
30+
def select_status_recall(self):
31+
self.select_status.select_option(self.RECALL_STATUS)
32+
33+
def select_status_opt_in(self):
34+
self.select_status.select_option(self.OPT_IN_STATUS)
35+
36+
def select_status_self_referral(self):
37+
self.select_status.select_option(self.SELF_REFERRAL_STATUS)
38+
39+
def select_status_surveillance(self):
40+
self.select_status.select_option(self.SURVEILLANCE_STATUS)
41+
42+
def select_status_seeking_further_data(self):
43+
self.select_status.select_option(self.SEEKING_FURTHER_DATA_STATUS)
44+
45+
def select_status_ceased(self):
46+
self.select_status.select_option(self.CEASED_STATUS)
47+
48+
def select_status_bowel_scope(self):
49+
self.select_status.select_option(self.BOWEL_SCOPE_STATUS)
50+
51+
def select_status_lynch_surveillance(self):
52+
self.select_status.select_option(self.LYNCH_SURVEILLANCE_STATUS)
53+
54+
def select_status_lynch_self_referral(self):
55+
self.select_status.select_option(self.LYNCH_SELF_REFERRAL_STATUS)
56+
57+
58+
class LatestEpisodeStatusSearchOptions:
59+
OPEN_PAUSED_STATUS = "1"
60+
CLOSED_STATUS = "2"
61+
NO_EPISODE_STATUS = "3"
62+
63+
def __init__(self, page: Page):
64+
self.page = page
65+
66+
# Locate latest episode status status dropdown list
67+
self.select_status = self.page.locator("#A_C_EpisodeStatus")
68+
69+
# Select latest episode status options
70+
def select_status_open_paused(self):
71+
self.select_status.select_option(self.OPEN_PAUSED_STATUS)
72+
73+
def select_status_closed(self):
74+
self.select_status.select_option(self.CLOSED_STATUS)
75+
76+
def select_status_no_episode(self):
77+
self.select_status.select_option(self.NO_EPISODE_STATUS)
78+
79+
80+
class SearchAreaSearchOptions:
81+
SEARCH_AREA_HOME_HUB = "01"
82+
SEARCH_AREA_GP_PRACTICE = "02"
83+
SEARCH_AREA_CCG = "03"
84+
SEARCH_AREA_SCREENING_CENTRE = "05"
85+
SEARCH_AREA_OTHER_HUB = "06"
86+
SEARCH_AREA_WHOLE_DATABASE = "07"
87+
88+
def __init__(self, page: Page):
89+
self.page = page
90+
91+
# Locate search area dropdown list
92+
self.select_area = self.page.locator("#A_C_SEARCH_DOMAIN")
93+
94+
# Select search area options
95+
def select_search_area_home_hub(self):
96+
self.select_area.select_option(self.SEARCH_AREA_HOME_HUB)
97+
98+
def select_search_area_gp_practice(self):
99+
self.select_area.select_option(self.SEARCH_AREA_GP_PRACTICE)
100+
101+
def select_search_area_ccg(self):
102+
self.select_area.select_option(self.SEARCH_AREA_CCG)
103+
104+
def select_search_area_screening_centre(self):
105+
self.select_area.select_option(self.SEARCH_AREA_SCREENING_CENTRE)
106+
107+
def select_search_area_other_hub(self):
108+
self.select_area.select_option(self.SEARCH_AREA_OTHER_HUB)
109+
110+
def select_search_area_whole_database(self):
111+
self.select_area.select_option(self.SEARCH_AREA_WHOLE_DATABASE)

pytest.ini

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ addopts =
1212
--json-report-file=test-results/results.json
1313
--json-report-omit=collectors
1414
--tracing=retain-on-failure
15+
--base-url=https://bcss-bcss-18680-ddc-bcss.k8s-nonprod.texasplatform.uk/
1516

1617
# Allows pytest to identify the base of this project as the pythonpath
1718
pythonpath = .
1819

1920
# These are the tags that pytest will recognise when using @pytest.mark
2021
markers =
21-
example: tests used for example purposes by this blueprint
22-
utils: tests for utility classes provided by this blueprint
23-
branch: tests designed to run at a branch level
24-
main: tests designed to run against the main branch
25-
release: tests designed to run specifically against a release branch
22+
#example: tests used for example purposes by this blueprint
23+
#utils: tests for utility classes provided by this blueprint
24+
#branch: tests designed to run at a branch level
25+
#main: tests designed to run against the main branch
26+
#release: tests designed to run specifically against a release branch
27+
utils: test setup and support methods
28+
smoke: tests designed to run as part of the smokescreen regression test suite
29+
wip: tests that are currently in progress

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pytest-playwright>=0.5.1
22
pytest-html>=4.1.1
33
pytest-json-report>=1.5.0
4+
python-dotenv~=1.0.1

0 commit comments

Comments
 (0)