From c28cdd5579ad0ef8a2d8a3001c83e568bad7b34b Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 18 Dec 2024 09:35:43 +0000 Subject: [PATCH] Fix flaky manage attendance feature test Instead of picking the last patient (which doesn't have a guaranteed order) we can pick the patient that will be left on the page, i.e. the patient that's missing attendance information. --- spec/features/manage_attendance_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/features/manage_attendance_spec.rb b/spec/features/manage_attendance_spec.rb index 1e63b52cb..d0ff36b85 100644 --- a/spec/features/manage_attendance_spec.rb +++ b/spec/features/manage_attendance_spec.rb @@ -94,7 +94,12 @@ def when_i_register_a_patient_as_absent end def when_i_go_to_a_patient - click_link @session.reload.patients.last.full_name + click_link PatientSession + .where + .missing(:session_attendances) + .find_by(session: @session) + .patient + .full_name end def then_the_patient_is_not_registered_yet