Skip to content

Commit 9b4a104

Browse files
authored
Merge pull request #1008 from NHSDigital/rework-clinic-sessions
Rework clinic sessions to be created dynamically
2 parents 69cfe7c + 1f6ec3f commit 9b4a104

File tree

5 files changed

+32
-91
lines changed

5 files changed

+32
-91
lines changed

mavis/test/pages/add_session_wizard_page.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212

1313

1414
class AddSessionWizardPage:
15-
def __init__(
16-
self,
17-
page: Page,
18-
) -> None:
15+
def __init__(self, page: Page) -> None:
1916
self.page = page
2017
self.header = HeaderComponent(page)
2118

@@ -27,24 +24,13 @@ def __init__(
2724
"button",
2825
name="Add another date",
2926
)
30-
self.school_session_radio = self.page.get_by_role(
31-
"radio",
32-
name="School session",
33-
)
34-
self.community_clinic_radio = self.page.get_by_role(
35-
"radio",
36-
name="Community clinic",
37-
)
3827
self.select_a_school_combobox = self.page.get_by_role(
3928
"combobox",
4029
name="Search for a school",
4130
)
4231
self.keep_session_dates_button = self.page.get_by_role(
4332
"button", name="Keep session dates"
4433
)
45-
self.session_type_heading = self.page.get_by_role(
46-
"heading", name="What type of session is this?"
47-
)
4834
self.standard_consent_style_radio = self.page.get_by_role(
4935
"radio",
5036
name="Standard request",
@@ -57,15 +43,6 @@ def __init__(
5743
"heading", name="Check and confirm"
5844
)
5945

60-
@step("Select School session")
61-
def select_school_session(self) -> None:
62-
expect(self.session_type_heading).to_be_visible()
63-
64-
self.school_session_radio.check()
65-
self.page.wait_for_load_state()
66-
67-
self.click_continue()
68-
6946
@step("Select Community clinic")
7047
def select_community_clinic(self) -> None:
7148
expect(self.session_type_heading).to_be_visible()
@@ -142,8 +119,7 @@ def schedule_school_session(
142119
date_offset: int | None,
143120
consent_style: str = "Standard",
144121
) -> None:
145-
if school is not None:
146-
self.select_school_session()
122+
if school:
147123
self.select_school(school)
148124

149125
self.choose_programmes(programmes)
@@ -183,19 +159,6 @@ def check_confirmation_page(
183159
f"{consent_style} request",
184160
)
185161

186-
def schedule_clinic_session(
187-
self,
188-
programmes: list[Programme],
189-
date_offset: int,
190-
) -> None:
191-
self.select_community_clinic()
192-
self.choose_programmes(programmes)
193-
194-
self.fill_date_fields(get_offset_date_compact_format(date_offset))
195-
self.click_continue()
196-
197-
self.click_continue()
198-
199162
@step("Keep session dates if necessary")
200163
def keep_session_dates_if_necessary(self) -> None:
201164
self.page.wait_for_load_state()

mavis/test/pages/children/child_programme_page.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from playwright.sync_api import Locator, Page, expect
44

55
from mavis.test.annotations import step
6-
from mavis.test.data_models import Location
6+
from mavis.test.data_models import Location, Programme
77
from mavis.test.pages.header_component import HeaderComponent
88
from mavis.test.utils import get_todays_date, reload_until_element_is_visible
99

@@ -30,6 +30,11 @@ def __init__(self, page: Page) -> None:
3030
"Consent response manually matched with child record",
3131
)
3232

33+
def click_record_new_vaccination(self, programme: Programme) -> None:
34+
self.page.get_by_role(
35+
"button", name=f"Record a new {programme.name} vaccination"
36+
).click()
37+
3338
def _link_for_vaccination_record(self, date: datetime.date) -> Locator:
3439
return self.vaccination_record_card.filter(
3540
has_text=str(date.strftime("%-d %B %Y"))

mavis/test/pages/utils.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ConsentMethod,
66
Programme,
77
)
8-
from mavis.test.data_models import Child, Clinic, School, VaccinationRecord
8+
from mavis.test.data_models import Child, School, VaccinationRecord
99
from mavis.test.pages import (
1010
AddSessionWizardPage,
1111
DashboardPage,
@@ -38,20 +38,6 @@ def schedule_school_session_if_needed( # noqa: PLR0913
3838
)
3939

4040

41-
def schedule_community_clinic_session_if_needed(
42-
page: Page,
43-
programmes: list[Programme],
44-
date_offset: int = 0,
45-
) -> None:
46-
DashboardPage(page).header.click_mavis()
47-
DashboardPage(page).click_sessions()
48-
if not SessionsSearchPage(page).click_session_if_exists(
49-
Clinic("community clinic"), programmes, [], date_offset
50-
):
51-
SessionsSearchPage(page).click_add_a_new_session()
52-
AddSessionWizardPage(page).schedule_clinic_session(programmes, date_offset)
53-
54-
5541
def prepare_child_for_vaccination(
5642
page: Page,
5743
school: School,

tests/test_invite_to_clinic.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
SchoolInviteToClinicPage,
1414
SchoolsSearchPage,
1515
)
16-
from mavis.test.pages.utils import schedule_community_clinic_session_if_needed
1716

1817
pytestmark = pytest.mark.clinics
1918

@@ -26,11 +25,10 @@ def test_single_from_child_record(
2625
Test: Invite a single child to the clinic from their child record.
2726
2827
Steps:
29-
1. Schedule a community clinic session for the future.
30-
2. Import a child with parent details via child records.
31-
3. Find the child's record.
32-
4. Click on "Invite to community clinic"
33-
5. Check the activity log for an invitation having been sent.
28+
1. Import a child with parent details via child records.
29+
2. Find the child's record.
30+
3. Click on "Invite to community clinic"
31+
4. Check the child has been invited.
3432
"""
3533

3634
programme = Programme.HPV
@@ -44,8 +42,6 @@ def test_single_from_child_record(
4442
child_programme_page = ChildProgrammePage(page)
4543
child_record_page = ChildRecordPage(page)
4644

47-
schedule_community_clinic_session_if_needed(page, [programme])
48-
4945
# Import a child with parent details via child records.
5046
imports_page.header.click_imports()
5147
imports_page.click_upload_records()
@@ -60,11 +56,11 @@ def test_single_from_child_record(
6056
# Click on "Invite to community clinic"
6157
child_record_page.click_programme(programme)
6258
child_programme_page.click_invite_to_community_clinic()
59+
child_programme_page.header.click_children()
6360

64-
# Check the activity log for an invitation having been sent.
65-
child_programme_page.expect_activity_log_entry(
66-
"Added to the session at Community Clinic"
67-
)
61+
# Check the child has been invited.
62+
children_search_page.search.search_invited_to_clinic()
63+
children_search_page.search.click_child(child)
6864

6965
# TODO: We can't check for the entry from the notifications log as no
7066
# emails actually get sent from the end to end test environments.
@@ -90,13 +86,12 @@ def test_bulk_home_educated_or_unknown_school(
9086
Test: Invite a single child to the clinic from their child record.
9187
9288
Steps:
93-
1. Schedule a community clinic session for the future.
94-
2. Import a home-educated or unknown school child with parent details via child
89+
1. Import a home-educated or unknown school child with parent details via child
9590
records.
96-
3. Click on "Invite to community clinic" from the home-educated or unknown school.
97-
4. Choose a programme and submit the request to send invitations
98-
5. Find the child's record.
99-
6. Check the activity log for an invitation having been sent.
91+
2. Click on "Invite to community clinic" from the home-educated or unknown school.
92+
3. Choose a programme and submit the request to send invitations
93+
4. Find the child's record.
94+
5. Check the activity log for an invitation having been sent.
10095
"""
10196

10297
programme = Programme.HPV

tests/test_sessions.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from mavis.test.annotations import issue
55
from mavis.test.constants import ConsentMethod, Programme, Vaccine
66
from mavis.test.data import ClassFileMapping
7-
from mavis.test.data_models import Clinic, VaccinationRecord
7+
from mavis.test.data_models import VaccinationRecord
88
from mavis.test.helpers.accessibility_helper import AccessibilityHelper
99
from mavis.test.pages import (
1010
ChildProgrammePage,
@@ -24,10 +24,7 @@
2424
SessionsSearchPage,
2525
SessionsVaccinationWizardPage,
2626
)
27-
from mavis.test.pages.utils import (
28-
schedule_community_clinic_session_if_needed,
29-
schedule_school_session_if_needed,
30-
)
27+
from mavis.test.pages.utils import schedule_school_session_if_needed
3128
from mavis.test.utils import expect_alert_text, expect_details
3229

3330
pytestmark = pytest.mark.sessions
@@ -359,7 +356,7 @@ def test_consent_refused_and_activity_log(
359356
@pytest.mark.bug
360357
@pytest.mark.clinics
361358
@pytest.mark.rav
362-
def test_verify_excel_export_and_clinic_invitation(
359+
def test_add_child_to_community_clinic_session(
363360
setup_fixed_child,
364361
add_vaccine_batch,
365362
schools,
@@ -368,36 +365,31 @@ def test_verify_excel_export_and_clinic_invitation(
368365
children,
369366
):
370367
"""
371-
Test: Export session data to Excel and send clinic invitations,
372-
then verify vaccination record.
368+
Test: Add a child to a community clinic session, record a vaccination, and
369+
verify outcome and Excel export.
370+
373371
Steps:
374-
1. Schedule session, import class list, and send clinic invitations.
372+
1. Import a child and click on "Record a new vaccination".
375373
2. Record verbal consent and register child as attending.
376374
3. Record vaccination for the child at the clinic.
377375
4. Verify vaccination outcome and Excel export.
376+
378377
Verification:
379378
- Vaccination outcome is recorded and session Excel export is available.
380379
"""
380+
381381
child = children[Programme.HPV][0]
382382
school = schools[Programme.HPV][0]
383383
batch_name = add_vaccine_batch(Vaccine.GARDASIL_9)
384-
generic_clinic = Clinic(name="Community clinic")
385-
386-
schedule_community_clinic_session_if_needed(page, [Programme.HPV])
387384

388385
SessionsOverviewPage(page).header.click_mavis()
389386
DashboardPage(page).click_children()
390387
ChildrenSearchPage(page).search.search_for_a_child_name(str(child))
391388
ChildrenSearchPage(page).search.click_child(child)
392389

393390
ChildRecordPage(page).click_programme(Programme.HPV)
394-
# TODO: Replace this with importing an unknown school child without
395-
# needing to manually invite them to the clinic. Inviting to a clinic
396-
# is covered by other tests.
397-
ChildProgrammePage(page).click_invite_to_community_clinic()
398-
ChildRecordPage(page).click_programme(Programme.HPV)
391+
ChildProgrammePage(page).click_record_new_vaccination(Programme.HPV)
399392

400-
ChildProgrammePage(page).click_session(generic_clinic)
401393
SessionsPatientPage(page).click_record_a_new_consent_response()
402394
NurseConsentWizardPage(page).select_parent(child.parents[0])
403395
NurseConsentWizardPage(page).select_consent_method(ConsentMethod.IN_PERSON)

0 commit comments

Comments
 (0)