Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mavis/test/pages/import_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def verify_upload_output(self, file_path: Path) -> None:
else:
expect(self.page.get_by_role("main")).to_contain_text(_msg)

@step("Select year groups {1}")
def select_year_groups(self, *year_groups: int) -> None:
for year_group in year_groups:
if year_group == 0:
Expand Down
35 changes: 19 additions & 16 deletions mavis/test/pages/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def __init__(
name="Archived records",
)

def _get_patient_card_locator(self, child: Child) -> Locator:
return self.page.locator(
f'div.nhsuk-card.app-card.app-card--compact:has(h4:has-text("{child!s}"))'
)

@step("Search for {1}")
def search_for(self, name: str) -> None:
self.search_textbox.fill(name)
Expand All @@ -65,13 +70,17 @@ def verify_search(self) -> None:

def search_and_click_child(self, child: Child) -> None:
self.search_for(str(child))
child_locator = self.page.get_by_role("link", name=str(child))
child_locator = self._get_patient_card_locator(child).get_by_role(
"link", name=str(child)
)
reload_until_element_is_visible(self.page, child_locator)
child_locator.click()

def search_for_child_that_should_not_exist(self, child: Child) -> None:
self.search_for(str(child))
child_locator = self.page.get_by_role("link", name=str(child))
child_locator = self._get_patient_card_locator(child).get_by_role(
"link", name=str(child)
)
expect(child_locator).not_to_be_visible()

@step("Click Advanced filters")
Expand Down Expand Up @@ -157,21 +166,17 @@ def __init__(self, page: Page) -> None:

@step("Check {1} has PSD")
def check_child_has_psd(self, child: Child) -> None:
patient_card = self.page.locator(
f'div.nhsuk-card.app-card.app-card--compact:has(h4:has-text("{child!s}"))'
)
reload_until_element_is_visible(
self.page, patient_card.get_by_text("PSD added")
child_with_psd_locator = self._get_patient_card_locator(child).get_by_text(
"PSD added"
)
reload_until_element_is_visible(self.page, child_with_psd_locator)

@step("Check {1} does not have PSD")
def check_child_does_not_have_psd(self, child: Child) -> None:
patient_card = self.page.locator(
f'div.nhsuk-card.app-card.app-card--compact:has(h4:has-text("{child!s}"))'
)
reload_until_element_is_visible(
self.page, patient_card.get_by_text("PSD not added")
child_without_psd_locator = self._get_patient_card_locator(child).get_by_text(
"PSD not added"
)
reload_until_element_is_visible(self.page, child_without_psd_locator)

@step("Click Add new PSDs")
def click_add_new_psds(self) -> None:
Expand Down Expand Up @@ -652,10 +657,8 @@ def verify_child_shows_correct_flu_consent_method(
reload_until_element_is_visible(self.page, method_locator)

def get_flu_consent_status_locator_from_search(self, child: Child) -> Locator:
patient_card = self.page.locator(
f'div.nhsuk-card.app-card.app-card--compact:has(h4:has-text("{child!s}"))',
)
flu_consent_section = patient_card.locator("p:has-text('Flu')")
child_locator = self._get_patient_card_locator(child)
flu_consent_section = child_locator.locator("p:has-text('Flu')")
reload_until_element_is_visible(self.page, flu_consent_section)

return flu_consent_section
Expand Down