@@ -168,3 +168,44 @@ def test_tallying( # noqa: PLR0915
168168 tally_totals [TallyCategory .DUE_NASAL_SPRAY ] -= 1
169169 tally_totals [TallyCategory .VACCINATED ] += 1
170170 sessions_overview_page .check_all_totals (tally_totals )
171+
172+
173+ @issue ("MAV-2689" )
174+ @pytest .mark .parametrize (
175+ "programme" , list (Programme ), ids = lambda p : f"Programme: { p .value } "
176+ )
177+ def test_tallying_totals_match_eligible_patients (
178+ setup_fixed_child ,
179+ sessions_overview_page ,
180+ sessions_children_page ,
181+ programme ,
182+ children ,
183+ schools ,
184+ ):
185+ """
186+ Test: Verify that tallying totals match the number of eligible patients.
187+ Steps:
188+ 1. Navigate to a session with eligible patients for the given programme.
189+ 2. Compare the sum of the tally boxes with the count of eligible patients.
190+ Verification:
191+ - Sum of tally totals should equal the number of eligible children shown
192+ on the children tab.
193+ """
194+ # Get tally totals for the programme
195+ tally_totals = sessions_overview_page .get_all_totals (programme )
196+ sum_of_tally_totals = sum (tally_totals .values ())
197+
198+ # Navigate to children tab to count eligible children
199+ sessions_overview_page .click_children_tab ()
200+
201+ # Count all children cards displayed (these are the eligible children)
202+ children_cards = sessions_children_page .page .locator (
203+ "div.nhsuk-card.app-card.app-card--compact:has(h4)"
204+ )
205+ eligible_children_count = children_cards .count ()
206+
207+ # Verify that the sum of tally totals equals the number of eligible children
208+ assert sum_of_tally_totals == eligible_children_count , (
209+ f"Sum of tally totals ({ sum_of_tally_totals } ) does not match "
210+ f"eligible children count ({ eligible_children_count } ) for { programme } "
211+ )
0 commit comments