Skip to content

Race Condition Check: spec/system/case_court_reports/index_spec.rb#6757

Merged
compwron merged 2 commits intorubyforgood:mainfrom
costajohnt:fix/6700-court-report-race-condition
Mar 9, 2026
Merged

Race Condition Check: spec/system/case_court_reports/index_spec.rb#6757
compwron merged 2 commits intorubyforgood:mainfrom
costajohnt:fix/6700-court-report-race-condition

Conversation

@costajohnt
Copy link
Contributor

@costajohnt costajohnt commented Mar 9, 2026

Resolves #6700

Summary

  • spec/system/case_court_reports/index_spec.rb: Replaced 4 database-level assertions (attached?, reload, wait_for_report_attachment) with page-based Capybara checks in the "generates and attaches a report on success" test. The button re-enabling, download icon visibility, and spinner state serve as reliable page-level signals that the report was generated successfully.
  • spec/support/case_court_report_helpers.rb: Removed the wait_for_report_attachment helper method (only used in this one test). The two remaining helpers (open_court_report_modal, open_case_select2_dropdown) are unchanged.

All other tests in the file already used expect(page) exclusively — no changes needed.

Test plan

  • bundle exec rspec spec/system/case_court_reports/index_spec.rb passes with 0 failures
  • No reload, attached?, or wait_for_report_attachment calls remain in the spec

@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Mar 9, 2026
Remove ActiveRecord precondition/postcondition checks and the
wait_for_report_attachment polling helper from the court report
generation test. Use Capybara's built-in wait/retry to assert
button state, download icon, and spinner visibility instead.

This eliminates race conditions on CI where the DB check could
execute before the browser action completed.
The test no longer verifies ActiveStorage attachment directly,
so rename from "generates and attaches" to "generates a report
and opens the download link" to match what is actually asserted.
@costajohnt costajohnt force-pushed the fix/6700-court-report-race-condition branch from 1e43e16 to d4bd23c Compare March 9, 2026 15:02
Copy link
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@compwron compwron merged commit af8a221 into rubyforgood:main Mar 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race Condition Check: spec/system/case_court_reports/index_spec.rb

2 participants