Skip to content

Commit 56a2624

Browse files
authored
Merge pull request #844 from NHSDigital/add-batch-page-init
Make some tests more reliable
2 parents ece0f67 + 96718e6 commit 56a2624

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

mavis/test/fixtures/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def wrapper(school: School, *programmes: Programme):
6363

6464
LogInPage(page).navigate()
6565
LogInPage(page).log_in_and_choose_team_if_necessary(nurse, team)
66+
6667
schedule_school_session_if_needed(
6768
page, school, list(programmes), [year_group], date_offset=7
6869
)

mavis/test/pages/sessions/sessions_patient_page.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ def confirm_pre_screening_checks(
218218
locator = self.pre_screening_listitem.get_by_text(check)
219219
expect(locator).to_be_visible()
220220
self.page.wait_for_load_state()
221+
expect(self.pre_screening_checkbox).to_be_editable()
221222
self.pre_screening_checkbox.check()
222223

224+
self.page.wait_for_load_state()
225+
expect(self.pre_screening_checkbox).to_be_checked()
226+
223227
def expect_conflicting_consent_text(self) -> None:
224228
expect(
225229
self.page.get_by_text(

mavis/test/pages/sessions/sessions_vaccination_wizard_page.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from mavis.test.utils import (
1111
expect_alert_text,
1212
expect_details,
13+
reload_until_element_is_visible,
1314
)
1415

1516

@@ -47,7 +48,13 @@ def expect_consent_refused_text(self, parent: Parent) -> None:
4748

4849
@step("Choose batch {1}")
4950
def choose_batch(self, batch_name: str) -> None:
50-
self.page.get_by_role("radio", name=batch_name).check()
51+
batch_radio = self.page.get_by_role("radio", name=batch_name)
52+
53+
reload_until_element_is_visible(
54+
self.page,
55+
batch_radio,
56+
)
57+
batch_radio.check()
5158
self.click_continue_button()
5259

5360
def record_vaccination(

mavis/test/pages/vaccines/batch_expiry_date.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class BatchExpiryDate:
99
def __init__(self, page: Page) -> None:
10+
self.page = page
1011
self.expiry_day_textbox = page.get_by_role("textbox", name="Day")
1112
self.expiry_month_textbox = page.get_by_role("textbox", name="Month")
1213
self.expiry_year_textbox = page.get_by_role("textbox", name="Year")

tests/test_tallying.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@
3030

3131

3232
@pytest.fixture
33-
def setup_tests(log_in_as_nurse, page):
34-
DashboardPage(page).click_sessions()
35-
36-
37-
@pytest.fixture
38-
def setup_session_with_file_upload(
39-
setup_tests,
33+
def setup_flu_vaccination(
34+
log_in_as_nurse,
4035
add_vaccine_batch,
4136
schools,
4237
page,
@@ -47,6 +42,7 @@ def setup_session_with_file_upload(
4742
year_group = year_groups[Programme.FLU]
4843

4944
def _setup(class_list_file):
45+
DashboardPage(page).click_sessions()
5046
batch_names = {
5147
vaccine: add_vaccine_batch(vaccine)
5248
for vaccine in [Vaccine.SEQUIRUS, Vaccine.FLUENZ]
@@ -65,8 +61,8 @@ def _setup(class_list_file):
6561

6662

6763
@pytest.fixture
68-
def setup_fixed_child(setup_session_with_file_upload):
69-
yield from setup_session_with_file_upload(ClassFileMapping.FIXED_CHILD)
64+
def setup_fixed_child(setup_flu_vaccination):
65+
yield from setup_flu_vaccination(ClassFileMapping.FIXED_CHILD)
7066

7167

7268
@issue("MAV-1669")
@@ -170,9 +166,12 @@ def test_tallying( # noqa: PLR0915
170166
"programme", list(Programme), ids=lambda p: f"Programme: {p.value}"
171167
)
172168
def test_tallying_totals_match_eligible_patients(
173-
setup_fixed_child,
169+
log_in_as_nurse,
174170
page,
175171
programme,
172+
year_groups,
173+
schools,
174+
file_generator,
176175
):
177176
"""
178177
Test: Verify that tallying totals match the number of eligible patients.
@@ -183,6 +182,17 @@ def test_tallying_totals_match_eligible_patients(
183182
- Sum of tally totals should equal the number of eligible children shown
184183
on the children tab.
185184
"""
185+
school = schools[programme.group][0]
186+
year_group = year_groups[programme.group]
187+
188+
DashboardPage(page).click_schools()
189+
SchoolsSearchPage(page).click_school(school)
190+
SchoolsChildrenPage(page).click_import_class_lists()
191+
ImportRecordsWizardPage(page, file_generator).import_class_list(
192+
ClassFileMapping.FIXED_CHILD, year_group, programme.group
193+
)
194+
schedule_school_session_if_needed(page, school, [programme], [year_group])
195+
186196
# Get tally totals for the programme
187197
tally_totals = SessionsOverviewPage(page).get_all_totals(programme)
188198
sum_of_tally_totals = sum(tally_totals.values())

0 commit comments

Comments
 (0)