Skip to content

Fix: Flaky tests in CI#2610

Merged
olleolleolle merged 1 commit intocodebar:masterfrom
mroderick:fix/flaky-tests
May 7, 2026
Merged

Fix: Flaky tests in CI#2610
olleolleolle merged 1 commit intocodebar:masterfrom
mroderick:fix/flaky-tests

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

@mroderick mroderick commented May 6, 2026

This PR fixes two flaky tests that were failing intermittently in CI parallel test execution.

Fixed Tests

1. spec/features/listing_coaches_spec.rb:2 - "I can see the most active coaches"

Problem: The test was using the default workshop fabricator which creates a workshop 2 days in the future. In parallel CI execution with database timing issues, this could cause the coach to not appear in the query results for the current year.

Fix:

  • Explicitly create a workshop with a date in the current year (Time.zone.today.beginning_of_year + 1.month) to ensure it's counted in the current year query
  • Added 5-second wait to the expectation to handle page load timing

2. spec/features/admin/manage_workshop_attendances_spec.rb:25 - "can remove a member from the attendee list"

Problem: The test was immediately trying to find and click the .cancel_attendance element after visiting the page. In CI with parallel execution, the element might not be rendered yet when Capybara tries to interact with it.

Fix:

  • Added explicit wait for .cancel_attendance element to be present before attempting to click it

Changes

  • spec/features/listing_coaches_spec.rb: Use current year date, add wait
  • spec/features/admin/manage_workshop_attendances_spec.rb: Add wait for element

Verification

Both tests pass consistently locally and should be more reliable in CI parallel execution.

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.
@mroderick mroderick marked this pull request as ready for review May 6, 2026 10:44
@mroderick mroderick requested review from olleolleolle May 6, 2026 18:25
@olleolleolle olleolleolle merged commit de1fec4 into codebar:master May 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants