Attempt to fix flaky specs where the toast might disappear before the page finishes loading #15410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's consider the following scenario:
We are saving a form by clicking the submit button. The page redirects, the toast message is shown, but the page still loads some requests in the background. Capybara will not consider the page submission with the "click_on" command done, unless the page is loaded. Hence it will not go to the next expectation unless the page is loaded. If the page takes too long to load, the toast message might already disappear by the time capybara runs the next expectation for the toast's presence. This will make the expectation fail.
Attempt to fix flaky spec on ./modules/budgets/spec/features/budgets/add_budget_spec.rb:59
Some specs got broken alongside while applying the fix. Those cases were prone to toast timing and fixed those too.