Skip to content

Conversation

h-m-m
Copy link
Collaborator

@h-m-m h-m-m commented Sep 12, 2025

What github issue is this PR for, if any?

This fixes some flaky tests.

  • Fixes one that was listed as TODO in a comment
  • Fixes a few tests that we noticed in local dev envs at the RfG 2025 events

This also speeds up test times for spec/system/casa_cases/edit_spec.rb

What changed, and why?

This addresses two main types of changes

  • When expecting a controller to do something via a headless browser actions, assert a UI change you expect to see before asserting the DB was updated or navigating the browser to a different page
    • On fast machines, it's possible to navigate away before the browser has finished sending its request
    • In many of these cases, the visit call was unneeded because the page to visit was already the page that the controller redirects to
  • When asserting in sequence a series of page content matchers (CSS based or otherwise) are valid and not expecting the page to change between assertions, put at least one positive .to assertions before any .not_to assertions whenever practicable.
    • If the negative page content matchers are first, Capybara would wait for the full length of its maximum wait time to be extra sure the content doesn't show up at the very last second
    • Getting this wrong can easily double the time Capybara waits to make sure the page is correct before passing the test.

Using expect(page).to have_current_path(expected_path) does count as putting a positive assertion first that helps with not doubling the wait time . The have_current_path matcher was intentionally written with this goal in mind.

How is this tested? (please write rspec and jest tests!) 💖💪

I tested it locally repeatedly and the edited tests pass reliably.

Feelings gif (optional)

a turtle attempting to walk up a playground slide

- Introduced PlacementTypesController with actions for new, create, edit, and update.
- Added routes for placement types.
- Implemented views for managing placement types.
- Created policies to manage access to placement types.
- Added tests for placement types functionality in both request and policy specs.

fixes #5778
@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Sep 12, 2025
@h-m-m h-m-m requested review from abachman and gvt September 12, 2025 21:44
@h-m-m h-m-m force-pushed the hmm/2025-flaky-test-resolution branch from e55f66c to ab42ccc Compare September 12, 2025 21:54
@github-actions github-actions bot added the erb label Sep 12, 2025
@compwron
Copy link
Collaborator

@claude fix merge conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erb ruby Pull requests that update Ruby code Tests! 🎉💖👏
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants