Skip to content

Commit 7e29105

Browse files
Enhance tests and settings: add new navigation method, update cSpell words, and improve Lynch invitation rate tests
1 parent 951937e commit 7e29105

File tree

7 files changed

+171
-17
lines changed

7 files changed

+171
-17
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
},
77
"cSpell.words": [
88
"addopts",
9+
"analyser",
10+
"Analysers",
911
"autouse",
1012
"BCSS",
1113
"behaviour",
1214
"codegen",
15+
"colonoscopist",
1316
"customisable",
1417
"customised",
1518
"initialise",

pages/base_page.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ def go_to_screening_subject_search_page(self) -> None:
205205
"""Click the Base Page 'Screening Subject Search' link."""
206206
self.click(self.screening_subject_search_page)
207207

208+
def go_to_page(self, navigation_steps: list[str]) -> None:
209+
"""Clicks the navigation links in the list provided.
210+
Args:
211+
navigation_steps (list[str]): the links you want to navigate through in order
212+
"""
213+
for intended_page in navigation_steps:
214+
self.page.get_by_role("link", name=intended_page).click()
215+
logging.info(f"navigated to {intended_page}")
216+
208217
def click(self, locator: Locator) -> None:
209218
# Alerts table locator
210219
alerts_table = locator.get_by_role("table", name="cockpitalertbox")

tests/test_contacts_list_page.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import logging
12
import pytest
2-
from playwright.sync_api import Page
3+
from playwright.sync_api import Page, expect
34
from pages.base_page import BasePage
45
from pages.contacts_list.contacts_list_page import ContactsListPage
56
from pages.contacts_list.view_contacts_page import ViewContactsPage
@@ -54,3 +55,25 @@ def test_contacts_list_page_navigation(page: Page) -> None:
5455
# Return to main menu
5556
BasePage(page).click_main_menu_link()
5657
BasePage(page).main_menu_header_is_displayed()
58+
59+
60+
def test_view_contacts_accredited_screening_colonoscopist(page: Page) -> None:
61+
"""
62+
Navigate to contact list, search for Accredited* role and BCS001 organisation and select the role link next to a contact.
63+
Expects the View Details page to have the role Accredited Screening Colonoscopist.
64+
"""
65+
66+
BasePage(page).go_to_page(["View Contacts"])
67+
ViewContactsPage(page).search_by_job_role_and_organisation_code(
68+
"Accredited*", "BCS001"
69+
)
70+
71+
page.get_by_role(
72+
"row",
73+
name="Legroom Sensitive Accredited Screening Colonoscopist BCS001 Wolverhampton Bowel Cancer Screening Centre",
74+
exact=True,
75+
).get_by_role("link").click()
76+
expect(page.locator('form[name="frm"]')).to_contain_text(
77+
"Accredited Screening Colonoscopist"
78+
)
79+
logging.info("results contain name Legroom Sensitive")

tests/test_fit_test_kits_page.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import datetime
2+
import uuid
13
import pytest
2-
from playwright.sync_api import Page
4+
from playwright.sync_api import Page, expect
35
from pages.base_page import BasePage
6+
from pages.fit_test_kits.create_new_analyser_page import CreateNewAnalyserPage
7+
from pages.fit_test_kits.edit_analyser_page import EditAnalyserPage
48
from pages.fit_test_kits.fit_test_kits_page import FITTestKitsPage
59
from pages.fit_test_kits.fit_rollout_summary_page import FITRolloutSummaryPage
610
from pages.fit_test_kits.log_devices_page import LogDevicesPage
@@ -98,3 +102,47 @@ def test_fit_test_kits_page_navigation(page: Page, general_properties: dict) ->
98102
# Return to main menu
99103
BasePage(page).click_main_menu_link()
100104
BasePage(page).main_menu_header_is_displayed()
105+
106+
107+
def test_add_and_edit_a_new_analyser(page: Page) -> None:
108+
"""Create a new analyser and then edit it to have an end date of tomorrow"""
109+
today = datetime.date.today()
110+
unique_id = str(uuid.uuid4())[:8]
111+
analyser_code = f"AUTO{unique_id}"
112+
analyser_name = f"Autotest{unique_id}"
113+
serial_number = f"SN{unique_id}"
114+
BasePage(page).go_to_page(["Maintain Analysers"])
115+
116+
maintain_analysers_page = MaintainAnalysersPage(page)
117+
maintain_analysers_page.create_new_analyser_button.click()
118+
create_new_analyser_page = CreateNewAnalyserPage(page)
119+
create_new_analyser_page.analyser_code_textbox.fill(analyser_code)
120+
create_new_analyser_page.analyser_name_textbox.fill(analyser_name)
121+
create_new_analyser_page.serial_number_textbox.fill(serial_number)
122+
create_new_analyser_page.start_date_textbox.fill(today.strftime("%d/%m/%Y"))
123+
create_new_analyser_page.select_analyser_from_lookup("PLEDIA")
124+
create_new_analyser_page.software_version_textbox.fill("1")
125+
create_new_analyser_page.software_start_date_textbox.fill(
126+
today.strftime("%d/%m/%Y")
127+
)
128+
create_new_analyser_page.software_start_time_textbox.fill("08:00")
129+
create_new_analyser_page.save_button.click()
130+
131+
expect(maintain_analysers_page.analysers_table).to_contain_text(analyser_code)
132+
edit_button = page.get_by_role(
133+
"row",
134+
name=f"BCS01 {analyser_code} {analyser_name} {today.strftime("%d %b %Y")} End Date Edit",
135+
exact=True,
136+
).locator("#edit")
137+
edit_button.click()
138+
tomorrow = today + datetime.timedelta(days=1)
139+
edit_analyser_page = EditAnalyserPage(page)
140+
edit_analyser_page.end_date_textbox.fill(tomorrow.strftime("%d/%m/%Y"))
141+
edit_analyser_page.save_button.click()
142+
expect(
143+
page.get_by_role(
144+
"row",
145+
name=f"BCS01 {analyser_code} {analyser_name} {today.strftime("%d %b %Y")} {tomorrow.strftime("%d %b %Y")} Edit",
146+
exact=True,
147+
)
148+
).to_be_visible()

tests/test_lynch_surveillance_page.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import random
2+
from typing import Generator
13
import pytest
2-
from playwright.sync_api import Page
4+
from playwright.sync_api import Page, expect
35
from pages.base_page import BasePage
46
from pages.lynch_surveillance.lynch_invitation_page import LynchInvitationPage
5-
from pages.lynch_surveillance.set_lynch_invitation_rates_page import SetLynchInvitationRatesPage
7+
from pages.lynch_surveillance.set_lynch_invitation_rates_page import (
8+
SetLynchInvitationRatesPage,
9+
)
610
from utils.user_tools import UserTools
711

812

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

2125

26+
@pytest.fixture
27+
def reset_lynch_invitation_rate(page: Page) -> Generator[None, None, None]:
28+
"""
29+
Teardown fixture for resetting Lynch invitation Rates to environment defaults
30+
"""
31+
yield
32+
page.get_by_role("link", name="Main Menu").click()
33+
BasePage(page).go_to_page(["Lynch Surveillance", "Set Lynch Invitation Rates"])
34+
set_lynch_invitation_rate_page = SetLynchInvitationRatesPage(page)
35+
set_lynch_invitation_rate_page.set_lynch_invitation_rate("2", "10")
36+
set_lynch_invitation_rate_page.set_lynch_invitation_rate("3", "5")
37+
set_lynch_invitation_rate_page.click_set_rates()
38+
39+
2240
@pytest.mark.smoke
2341
def test_lynch_surveillance_page_navigation(page: Page) -> None:
2442
"""
@@ -32,3 +50,36 @@ def test_lynch_surveillance_page_navigation(page: Page) -> None:
3250
# Return to main menu
3351
BasePage(page).click_main_menu_link()
3452
BasePage(page).main_menu_header_is_displayed()
53+
54+
55+
def test_set_lynch_invitation_rate(
56+
page: Page, reset_lynch_invitation_rate: None
57+
) -> None:
58+
"""
59+
Navigate to Lynch Surveillance Set Lynch Invitation Rates page, set random invitation rates for Wolverhampton and Coventry centres.
60+
Verify the rates are saved correctly by navigating back and checking the values match what was set.
61+
"""
62+
63+
LynchInvitationPage(page).go_to_page(["Set Lynch Invitation Rates"])
64+
65+
set_lynch_invitation_rate_page = SetLynchInvitationRatesPage(page)
66+
67+
wolverhampton_invitation_rate = str(random.randrange(1, 9))
68+
coventry_invitation_rate = str(random.randrange(1, 9))
69+
70+
set_lynch_invitation_rate_page.set_lynch_invitation_rate(
71+
"2", wolverhampton_invitation_rate
72+
)
73+
set_lynch_invitation_rate_page.set_lynch_invitation_rate(
74+
"3", coventry_invitation_rate
75+
)
76+
set_lynch_invitation_rate_page.click_set_rates()
77+
78+
page.get_by_role("link", name="Back").click()
79+
page.get_by_role("link", name="Set Lynch Invitation Rates").click()
80+
expect(set_lynch_invitation_rate_page.get_lynch_invitation_rate("2")).to_have_value(
81+
wolverhampton_invitation_rate
82+
)
83+
expect(set_lynch_invitation_rate_page.get_lynch_invitation_rate("3")).to_have_value(
84+
coventry_invitation_rate
85+
)

tests/test_reports_page.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import logging
12
import pytest
23
from playwright.sync_api import Page, expect
34
from pages.base_page import BasePage
5+
from pages.reports.operational.communication_type_by_gp_practice_page import (
6+
CommunicationTypeByGpPracticePage,
7+
)
48
from pages.reports.reports_page import ReportsPage
59
from utils.date_time_utils import DateTimeUtils
610
from utils.user_tools import UserTools
@@ -517,3 +521,19 @@ def test_operational_reports_screening_practitioner_appointments(
517521
expect(ReportsPage(page).common_report_timestamp_element).to_contain_text(
518522
report_timestamp
519523
)
524+
525+
526+
def test_report_communication_type_for_gp_practices(page: Page) -> None:
527+
"""
528+
Navigate to the Operational Reports and Communication Type for GP, select Wolverhampton Bowel Cancer Screening Centre.
529+
On the results page assert the page title and report generated on and selected GP Practices
530+
"""
531+
BasePage(page).go_to_page(["Operational Reports", "Communication Type for GP"])
532+
533+
CommunicationTypeByGpPracticePage(page).select_screening_centre(
534+
"Wolverhampton Bowel Cancer Screening Centre"
535+
)
536+
537+
for gp_practice_code in ["C81002", "M87041"]:
538+
expect(page.locator("#listReportDataTable")).to_contain_text(gp_practice_code)
539+
logging.info(f"results include the GP practice code {gp_practice_code}")

tests/test_screening_subject_search_page.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_search_screening_subject_by_status_call(page: Page) -> None:
179179
@pytest.mark.smoke
180180
def test_search_screening_subject_by_status_inactive(page: Page) -> None:
181181
"""
182-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
182+
Confirms screening subjects can be searched for, using the screening status (Inactive) by doing the following:
183183
- Clear filters
184184
- Select status from dropdown
185185
- Pressing Tab is required after text input, to make the search button become active.
@@ -195,7 +195,7 @@ def test_search_screening_subject_by_status_inactive(page: Page) -> None:
195195
@pytest.mark.smoke
196196
def test_search_screening_subject_by_status_opt_in(page: Page) -> None:
197197
"""
198-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
198+
Confirms screening subjects can be searched for, using the screening status (opt-in) by doing the following:
199199
- Clear filters
200200
- Select status from dropdown
201201
- Pressing Tab is required after text input, to make the search button become active.
@@ -211,7 +211,7 @@ def test_search_screening_subject_by_status_opt_in(page: Page) -> None:
211211
@pytest.mark.smoke
212212
def test_search_screening_subject_by_status_recall(page: Page) -> None:
213213
"""
214-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
214+
Confirms screening subjects can be searched for, using the screening status (recall) by doing the following:
215215
- Clear filters
216216
- Select status from dropdown
217217
- Pressing Tab is required after text input, to make the search button become active.
@@ -227,7 +227,7 @@ def test_search_screening_subject_by_status_recall(page: Page) -> None:
227227
@pytest.mark.smoke
228228
def test_search_screening_subject_by_status_self_referral(page: Page) -> None:
229229
"""
230-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
230+
Confirms screening subjects can be searched for, using the screening status (self-referral) by doing the following:
231231
- Clear filters
232232
- Select status from dropdown
233233
- Pressing Tab is required after text input, to make the search button become active.
@@ -245,7 +245,7 @@ def test_search_screening_subject_by_status_self_referral(page: Page) -> None:
245245
@pytest.mark.smoke
246246
def test_search_screening_subject_by_status_surveillance(page: Page) -> None:
247247
"""
248-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
248+
Confirms screening subjects can be searched for, using the screening status (surveillance) by doing the following:
249249
- Clear filters
250250
- Select status from dropdown
251251
- Pressing Tab is required after text input, to make the search button become active.
@@ -263,7 +263,7 @@ def test_search_screening_subject_by_status_surveillance(page: Page) -> None:
263263
@pytest.mark.smoke
264264
def test_search_screening_subject_by_status_seeking_further_data(page: Page) -> None:
265265
"""
266-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
266+
Confirms screening subjects can be searched for, using the screening status (seeking further data) by doing the following:
267267
- Clear filters
268268
- Select status from dropdown
269269
- Pressing Tab is required after text input, to make the search button become active.
@@ -281,7 +281,7 @@ def test_search_screening_subject_by_status_seeking_further_data(page: Page) ->
281281
@pytest.mark.smoke
282282
def test_search_screening_subject_by_status_ceased(page: Page) -> None:
283283
"""
284-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
284+
Confirms screening subjects can be searched for, using the screening status (ceased) by doing the following:
285285
- Clear filters
286286
- Select status from dropdown
287287
- Pressing Tab is required after text input, to make the search button become active.
@@ -297,7 +297,7 @@ def test_search_screening_subject_by_status_ceased(page: Page) -> None:
297297
@pytest.mark.smoke
298298
def test_search_screening_subject_by_status_lynch_surveillance(page: Page) -> None:
299299
"""
300-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
300+
Confirms screening subjects can be searched for, using the screening status (lynch surveillance) by doing the following:
301301
- Clear filters
302302
- Select status from dropdown
303303
- Pressing Tab is required after text input, to make the search button become active.
@@ -315,7 +315,7 @@ def test_search_screening_subject_by_status_lynch_surveillance(page: Page) -> No
315315
@pytest.mark.smoke
316316
def test_search_screening_subject_by_status_lynch_self_referral(page: Page) -> None:
317317
"""
318-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
318+
Confirms screening subjects can be searched for, using the screening status (lynch self referral) by doing the following:
319319
- Clear filters
320320
- Select status from dropdown
321321
- Pressing Tab is required after text input, to make the search button become active.
@@ -336,7 +336,7 @@ def test_search_screening_subject_by_latest_episode_status_open_paused(
336336
page: Page,
337337
) -> None:
338338
"""
339-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
339+
Confirms screening subjects can be searched for, using the episode status (open/paused) by doing the following:
340340
- Clear filters
341341
- Select status from dropdown
342342
- Pressing Tab is required after text input, to make the search button become active.
@@ -354,7 +354,7 @@ def test_search_screening_subject_by_latest_episode_status_open_paused(
354354
@pytest.mark.smoke
355355
def test_search_screening_subject_by_latest_episode_status_closed(page: Page) -> None:
356356
"""
357-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
357+
Confirms screening subjects can be searched for, using the episode status (closed) by doing the following:
358358
- Clear filters
359359
- Select status from dropdown
360360
- Pressing Tab is required after text input, to make the search button become active.
@@ -374,7 +374,7 @@ def test_search_screening_subject_by_latest_episode_status_no_episode(
374374
page: Page,
375375
) -> None:
376376
"""
377-
Confirms screening subjects can be searched for, using the screening status (call) by doing the following:
377+
Confirms screening subjects can be searched for, using the episode status (no episode) by doing the following:
378378
- Clear filters
379379
- Select status from dropdown
380380
- Pressing Tab is required after text input, to make the search button become active.
@@ -415,7 +415,7 @@ def test_search_screening_subject_by_gp_practice(
415415
page: Page, general_properties: dict
416416
) -> None:
417417
"""
418-
Confirms screening subjects can be searched for, using the search area (home hub) by doing the following:
418+
Confirms screening subjects can be searched for, using the search area (gp practice) by doing the following:
419419
- Clear filters
420420
- Select screening status "recall" (searching by search area requires another search option to be selected)
421421
- Select "GP Practice" option from dropdown

0 commit comments

Comments
 (0)