From 8022f08aa454fabe455f1b5013aef86e79ae169e Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 6 May 2026 12:37:05 +0200 Subject: [PATCH] fix: flaky tests in CI Fix two flaky tests that were failing intermittently in CI: 1. spec/features/listing_coaches_spec.rb:2 - Changed to use a workshop with a date in the current year (beginning_of_year + 1.month) instead of the default future date to ensure the coach is counted for the current year query - Added 5 second wait to the expectation for page load timing 2. spec/features/admin/manage_workshop_attendances_spec.rb:25 - Added explicit wait for '.cancel_attendance' element to be present before attempting to click it - This ensures the element is rendered before interaction These changes make the tests more robust in parallel CI execution where timing and database state can vary between test runs. --- spec/features/admin/manage_workshop_attendances_spec.rb | 1 + spec/features/listing_coaches_spec.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/manage_workshop_attendances_spec.rb b/spec/features/admin/manage_workshop_attendances_spec.rb index 84ad89d6a..9e2192e14 100644 --- a/spec/features/admin/manage_workshop_attendances_spec.rb +++ b/spec/features/admin/manage_workshop_attendances_spec.rb @@ -24,6 +24,7 @@ scenario 'can remove a member from the attendee list' do visit admin_workshop_path(workshop) + expect(page).to have_css('.cancel_attendance', wait: 5) find('.cancel_attendance').click expect(page).to have_content('0 are attending as students') diff --git a/spec/features/listing_coaches_spec.rb b/spec/features/listing_coaches_spec.rb index 716c089d8..cf94e1382 100644 --- a/spec/features/listing_coaches_spec.rb +++ b/spec/features/listing_coaches_spec.rb @@ -1,8 +1,10 @@ RSpec.feature 'when visiting the coaches page', type: :feature do scenario 'I can see the most active coaches' do - coach = Fabricate(:attended_coach).member + # Use a past workshop date in the current year to ensure the coach is counted + workshop = Fabricate(:workshop, date_and_time: Time.zone.today.beginning_of_year + 1.month) + coach = Fabricate(:attended_coach, workshop: workshop).member visit coaches_path - expect(page).to have_content coach.name + expect(page).to have_content(coach.name, wait: 5) end scenario 'I can see the top coaches by year' do