Skip to content

Commit fb7ed62

Browse files
committed
remove main text expectations from children_page
1 parent 7696c6f commit fb7ed62

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

mavis/test/pages/children.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ def fill_nhs_no_for_child(self, child: Child, nhs_no: str) -> None:
167167
def click_invite_to_community_clinic(self) -> None:
168168
self.invite_to_community_clinic_button.click()
169169

170-
def expect_text_in_main(self, text: str) -> None:
171-
expect(self.page.get_by_role("main")).to_contain_text(text)
170+
def expect_vaccination_details(self, key: str, value: str) -> None:
171+
detail_key = self.page.locator(".nhsuk-summary-list__key", has_text=key)
172+
detail_value = detail_key.locator("xpath=following-sibling::*[1]")
172173

173-
def expect_text_in_heading(self, text: str) -> None:
174-
expect(self.page.get_by_role("heading")).to_contain_text(text)
174+
expect(detail_value).to_contain_text(value)
175175

176176
def expect_text_in_alert(self, text: str) -> None:
177177
expect(self.page.get_by_role("alert")).to_contain_text(text)
@@ -214,12 +214,18 @@ def verify_activity_log_for_created_or_matched_child(
214214

215215
self.click_record_for_child(child)
216216
self.click_activity_log()
217-
self.expect_text_in_main("Consent given")
218-
self.expect_text_in_main(f"Added to the session at {location}")
217+
self.expect_activity_log_header("Consent given")
218+
self.expect_activity_log_header(f"Added to the session at {location}", any=True)
219219

220220
# FIXME: Update this text when MAVIS-1896/MAV-253 is closed
221221
self.check_log_updates_with_match()
222222

223+
def expect_activity_log_header(self, header: str, any: bool = False):
224+
if any:
225+
expect(self.page.get_by_role("heading", name=header).first).to_be_visible()
226+
else:
227+
expect(self.page.get_by_role("heading", name=header)).to_be_visible()
228+
223229
def archive_child_record(self):
224230
self.click_archive_child_record()
225231
self.click_imported_in_error()

tests/test_children.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ def test_details_mav_853(setup_mav_853, children_page, schools, children):
131131
children_page.click_record_for_child(child)
132132
# Verify activity log
133133
children_page.click_activity_log()
134-
children_page.expect_text_in_main("Vaccinated with Gardasil 9")
134+
children_page.expect_activity_log_header("Vaccinated with Gardasil 9")
135135
# Verify vaccination record
136136
children_page.click_child_record()
137137
children_page.click_vaccination_details(school)
138-
children_page.expect_text_in_main("OutcomeVaccinated")
138+
children_page.expect_vaccination_details("Outcome", "Vaccinated")
139139

140140

141141
@pytest.mark.bug
@@ -148,7 +148,7 @@ def test_change_nhsno(setup_change_nhsno, children_page, children):
148148
children_page.click_change_nhs_no()
149149
children_page.fill_nhs_no_for_child(child, "9123456789")
150150
children_page.click_continue()
151-
children_page.expect_text_in_main("Enter a valid NHS number")
151+
children_page.expect_text_in_alert("Enter a valid NHS number")
152152

153153

154154
@pytest.mark.children

tests/test_import_records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def test_vaccs_historic_no_urn_mav_855(
349349
children_page.search_with_all_filters_for_child_name(str(child))
350350
children_page.click_record_for_child(child)
351351
children_page.click_vaccination_details(school)
352-
children_page.expect_text_in_main(str(school))
352+
children_page.expect_vaccination_details("Location", str(school))
353353

354354

355355
@pytest.mark.vaccinations

0 commit comments

Comments
 (0)