diff --git a/mavis/test/models.py b/mavis/test/models.py index 8b7976d4b07..3a26b671f31 100644 --- a/mavis/test/models.py +++ b/mavis/test/models.py @@ -142,6 +142,8 @@ class TallyCategory(StrEnum): DUE_VACCINATION = "Due vaccination" DUE_INJECTION = "Due injection" DUE_NASAL_SPRAY = "Due nasal spray" + NEEDS_TRIAGE = "Needs triage" + UNABLE_TO_VACCINATE = "Unable to vaccinate" class Programme(StrEnum): @@ -261,6 +263,8 @@ def tally_categories(self) -> list[str]: TallyCategory.NEEDS_CONSENT, TallyCategory.HAS_A_REFUSAL, TallyCategory.VACCINATED, + TallyCategory.NEEDS_TRIAGE, + TallyCategory.UNABLE_TO_VACCINATE, ] if self is self.FLU: return [ @@ -268,7 +272,7 @@ def tally_categories(self) -> list[str]: TallyCategory.DUE_INJECTION, TallyCategory.DUE_NASAL_SPRAY, ] - return [*common_categories, TallyCategory.DUE_VACCINATION] + return [*common_categories] class Vaccine(StrEnum): diff --git a/tests/test_tallying.py b/tests/test_tallying.py index 7e09f7ff821..7cdf38748dd 100644 --- a/tests/test_tallying.py +++ b/tests/test_tallying.py @@ -168,3 +168,44 @@ def test_tallying( # noqa: PLR0915 tally_totals[TallyCategory.DUE_NASAL_SPRAY] -= 1 tally_totals[TallyCategory.VACCINATED] += 1 sessions_overview_page.check_all_totals(tally_totals) + + +@issue("MAV-2689") +@pytest.mark.parametrize( + "programme", list(Programme), ids=lambda p: f"Programme: {p.value}" +) +def test_tallying_totals_match_eligible_patients( + setup_fixed_child, + sessions_overview_page, + sessions_children_page, + programme, + children, + schools, +): + """ + Test: Verify that tallying totals match the number of eligible patients. + Steps: + 1. Navigate to a session with eligible patients for the given programme. + 2. Compare the sum of the tally boxes with the count of eligible patients. + Verification: + - Sum of tally totals should equal the number of eligible children shown + on the children tab. + """ + # Get tally totals for the programme + tally_totals = sessions_overview_page.get_all_totals(programme) + sum_of_tally_totals = sum(tally_totals.values()) + + # Navigate to children tab to count eligible children + sessions_overview_page.click_children_tab() + + # Count all children cards displayed (these are the eligible children) + children_cards = sessions_children_page.page.locator( + "div.nhsuk-card.app-card.app-card--compact:has(h4)" + ) + eligible_children_count = children_cards.count() + + # Verify that the sum of tally totals equals the number of eligible children + assert sum_of_tally_totals == eligible_children_count, ( + f"Sum of tally totals ({sum_of_tally_totals}) does not match " + f"eligible children count ({eligible_children_count}) for {programme}" + )