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
4 changes: 2 additions & 2 deletions mavis/test/fixtures/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def wrapper(vaccine: Vaccine, batch_name: str = "ABC123"):
vaccines_page.navigate()
vaccines_page.click_add_batch(vaccine)
add_batch_page.fill_name(batch_name)
add_batch_page.fill_expiry_date(get_offset_date(1))
add_batch_page.date.fill_expiry_date(get_offset_date(1))
add_batch_page.confirm()
return batch_name

Expand Down Expand Up @@ -193,7 +193,7 @@ def wrapper(
dashboard_page.click_mavis()
dashboard_page.click_programmes()
programmes_list_page.click_programme_for_current_year(programme)
programme_overview_page.click_children_tab()
programme_overview_page.tabs.click_children_tab()
programme_children_page.search_for_child(child)
programme_children_page.click_child(child)
child_record_page.click_vaccination_details(programme)
Expand Down
4 changes: 2 additions & 2 deletions mavis/test/fixtures/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def programmes_list_page(page: Page) -> ProgrammesListPage:


@pytest.fixture
def programme_overview_page(page: Page, test_data: TestData) -> ProgrammeOverviewPage:
return ProgrammeOverviewPage(page, test_data)
def programme_overview_page(page: Page) -> ProgrammeOverviewPage:
return ProgrammeOverviewPage(page)


@pytest.fixture
Expand Down
12 changes: 7 additions & 5 deletions mavis/test/pages/children.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def check_children_aged_out_of_programmes(self) -> None:
self.children_aged_out_of_programmes_checkbox.check()


class ChildRecordTabsMixin:
class ChildRecordTabs:
def __init__(self, page: Page) -> None:
self.page = page
self.child_record_tab = page.get_by_role("link", name="Child record")
Expand All @@ -129,9 +129,10 @@ def click_activity_log(self) -> None:
self.activity_log_tab.get_by_role("strong").wait_for()


class ChildRecordPage(ChildRecordTabsMixin):
class ChildRecordPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ChildRecordTabs(page)

vaccinations_card = page.locator("section").filter(
has=page.get_by_role("heading", name="Vaccinations"),
Expand Down Expand Up @@ -270,9 +271,10 @@ def archive_child_record(self) -> None:
expect(self.page.get_by_text("Archive reason")).to_be_visible()


class ChildActivityLogPage(ChildRecordTabsMixin):
class ChildActivityLogPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ChildRecordTabs(page)
self.manually_matched_card = self.page.get_by_text(
"Consent response manually matched with child record",
)
Expand Down
21 changes: 11 additions & 10 deletions mavis/test/pages/programmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from playwright.sync_api import Page

from mavis.test.annotations import step
from mavis.test.data import TestData
from mavis.test.models import Child, DeliverySite, Programme, ReportFormat
from mavis.test.utils import get_current_datetime_compact

Expand All @@ -24,7 +23,7 @@ def click_programme_for_current_year(self, programme: Programme) -> None:
self.current_year_programmes_card.get_by_role("link", name=programme).click()


class ProgrammeTabsMixin:
class ProgrammeTabs:
def __init__(self, page: Page) -> None:
self.page = page
self.children_tab = page.get_by_label("Secondary menu").get_by_role(
Expand All @@ -45,11 +44,10 @@ def click_sessions_tab(self) -> None:
self.sessions_tab.get_by_role("strong").wait_for()


class ProgrammeOverviewPage(ProgrammeTabsMixin):
def __init__(self, page: Page, test_data: TestData) -> None:
super().__init__(page)
class ProgrammeOverviewPage:
def __init__(self, page: Page) -> None:
self.page = page
self.test_data = test_data
self.tabs = ProgrammeTabs(page)

self.review_link = page.get_by_role("link", name="Review")
self.edit_vaccination_record_button = page.get_by_role(
Expand Down Expand Up @@ -171,14 +169,17 @@ def _download_and_verify_report_headers(self, expected_headers: str) -> None:
raise AssertionError(error_message)


class ProgrammeSessionsPage(ProgrammeTabsMixin):
class ProgrammeSessionsPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ProgrammeTabs(page)


class ProgrammeChildrenPage(ProgrammeTabsMixin):
class ProgrammeChildrenPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ProgrammeTabs(page)

self.import_child_records_link = page.get_by_text("Import child records")
self.search_textbox = page.get_by_role("textbox", name="Search")
self.search_button = page.get_by_role("button", name="Search")
Expand Down
14 changes: 9 additions & 5 deletions mavis/test/pages/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)


class ReportsTabsMixin:
class ReportsTabs:
def __init__(self, page: Page) -> None:
self.page = page
self.vaccinations_tab = page.get_by_label("Secondary menu").get_by_role(
Expand All @@ -35,9 +35,11 @@ def click_download_data_tab(self) -> None:
self.download_data_tab.get_by_role("strong").wait_for()


class ReportsVaccinationsPage(ReportsTabsMixin):
class ReportsVaccinationsPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ReportsTabs(page)

self.cohort_heading = self.page.get_by_role(
"heading", name="Cohort", exact=True
)
Expand Down Expand Up @@ -109,9 +111,11 @@ def get_expected_cohort_and_percentage_strings(
return str(total), str(unvaccinated_pct), str(vaccinated_pct)


class ReportsDownloadPage(ReportsTabsMixin):
class ReportsDownloadPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = ReportsTabs(page)

self.aggregate_data_radio = self.page.get_by_role(
"radio", name="Aggregate vaccination data"
)
Expand Down
73 changes: 41 additions & 32 deletions mavis/test/pages/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)


class SearchBarMixin:
class SearchComponent:
def __init__(
self,
page: Page,
Expand All @@ -48,7 +48,7 @@ def __init__(
name="Archived records",
)

def _get_patient_card_locator(self, child: Child) -> Locator:
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}"))'
)
Expand All @@ -70,15 +70,15 @@ def verify_search(self) -> None:

def search_and_click_child(self, child: Child) -> None:
self.search_for(str(child))
child_locator = self._get_patient_card_locator(child).get_by_role(
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._get_patient_card_locator(child).get_by_role(
child_locator = self.get_patient_card_locator(child).get_by_role(
"link", name=str(child)
)
expect(child_locator).not_to_be_visible()
Expand Down Expand Up @@ -112,7 +112,7 @@ def check_note_appears_in_search(self, child: Child, note: str) -> None:
expect(next_element.get_by_role("blockquote")).to_have_text(note)


class SessionsTabsMixin:
class SessionsTabs:
def __init__(
self,
page: Page,
Expand Down Expand Up @@ -146,14 +146,12 @@ def click_record_vaccinations_tab(self) -> None:
def click_children_tab(self) -> None:
self._select_tab("Children")

@step("Click on Triage tab")
def click_triage_tab(self) -> None:
self._select_tab("Triage")


class SessionsPsdPage(SearchBarMixin, SessionsTabsMixin):
class SessionsPsdPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.search = SearchComponent(page)
self.tabs = SessionsTabs(page)

self.add_new_psds_link = self.page.get_by_role(
"link",
Expand All @@ -166,16 +164,16 @@ def __init__(self, page: Page) -> None:

@step("Check {1} has PSD")
def check_child_has_psd(self, child: Child) -> None:
child_with_psd_locator = self._get_patient_card_locator(child).get_by_text(
"PSD added"
)
child_with_psd_locator = self.search.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:
child_without_psd_locator = self._get_patient_card_locator(child).get_by_text(
"PSD not added"
)
child_without_psd_locator = self.search.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")
Expand All @@ -194,9 +192,10 @@ def verify_psd_banner_has_patients(self, number_of_patients: int) -> None:
reload_until_element_is_visible(self.page, psd_banner)


class SessionsSearchPage(SearchBarMixin):
class SessionsSearchPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.search = SearchComponent(page)

@step("Click on {2} session at {1}")
def click_session_for_programme_group(
Expand All @@ -209,8 +208,8 @@ def click_session_for_programme_group(
else:
self.page.get_by_role("checkbox", name=str(programme)).uncheck()

self.search_textbox.fill(str(location))
self.search_button.click()
self.search.search_textbox.fill(str(location))
self.search.search_button.click()

self.page.get_by_role("link", name=str(location)).first.click()

Expand All @@ -221,9 +220,11 @@ def click_session_for_programme_group(
)


class SessionsOverviewPage(SessionsTabsMixin):
class SessionsOverviewPage:
def __init__(self, page: Page) -> None:
self.page = page
self.tabs = SessionsTabs(page)

self.schedule_sessions_link = self.page.get_by_role(
"link",
name="Schedule sessions",
Expand Down Expand Up @@ -265,7 +266,7 @@ def get_all_totals(self, programme: Programme) -> dict[str, int]:
}

def check_all_totals(self, totals: dict[str, int]) -> None:
self.click_overview_tab()
self.tabs.click_overview_tab()
for category, expected_total in totals.items():
actual_total = self.get_total_for_category(category)
assert actual_total == expected_total, (
Expand Down Expand Up @@ -597,9 +598,12 @@ def answer_whether_psd_should_be_enabled(self, answer: str) -> None:
).get_by_label(answer).check()


class SessionsChildrenPage(SearchBarMixin, SessionsTabsMixin):
class SessionsChildrenPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = SessionsTabs(page)
self.search = SearchComponent(page)

self.needs_consent_radio = self.page.get_by_role(
"radio",
name="Needs consent",
Expand Down Expand Up @@ -657,7 +661,7 @@ 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:
child_locator = self._get_patient_card_locator(child)
child_locator = self.search.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)

Expand All @@ -668,14 +672,17 @@ def expect_has_a_refusal_to_be_selected(self) -> None:
expect(self.has_a_refusal_radio).to_be_checked()


class SessionsRegisterPage(SearchBarMixin, SessionsTabsMixin):
class SessionsRegisterPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = SessionsTabs(page)
self.search = SearchComponent(page)

self.attending_button = self.page.get_by_role("button", name="Attending").first

def register_child_as_attending(self, child: Child) -> None:
self.click_register_tab()
self.search_for(str(child))
self.tabs.click_register_tab()
self.search.search_for(str(child))
reload_until_element_is_visible(
self.page, self.page.get_by_role("link", name=str(child)).first
)
Expand All @@ -686,9 +693,11 @@ def click_on_attending(self) -> None:
self.attending_button.click()


class SessionsRecordVaccinationsPage(SearchBarMixin, SessionsTabsMixin):
class SessionsRecordVaccinationsPage:
def __init__(self, page: Page) -> None:
super().__init__(page)
self.page = page
self.tabs = SessionsTabs(page)
self.search = SearchComponent(page)


class SessionsPatientPage:
Expand Down
12 changes: 5 additions & 7 deletions mavis/test/pages/vaccines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mavis.test.models import Vaccine


class BatchExpiryDateMixin:
class BatchExpiryDate:
def __init__(self, page: Page) -> None:
self.expiry_day_textbox = page.get_by_role("textbox", name="Day")
self.expiry_month_textbox = page.get_by_role("textbox", name="Month")
Expand All @@ -19,11 +19,10 @@ def fill_expiry_date(self, value: date) -> None:
self.expiry_year_textbox.fill(str(value.year))


class AddBatchPage(BatchExpiryDateMixin):
class AddBatchPage:
def __init__(self, page: Page) -> None:
super().__init__(page)

self.page = page
self.date = BatchExpiryDate(page)

self.name_textbox = page.get_by_role("textbox", name="Batch")
self.confirm_button = page.get_by_role("button", name="Add batch")
Expand All @@ -43,11 +42,10 @@ def confirm(self) -> None:
self.confirm_button.click()


class EditBatchPage(BatchExpiryDateMixin):
class EditBatchPage:
def __init__(self, page: Page) -> None:
super().__init__(page)

self.page = page
self.date = BatchExpiryDate(page)

self.confirm_button = page.get_by_role("button", name="Save changes")
self.success_alert = page.get_by_role("alert", name="Success").filter(
Expand Down
Loading