Relax expectations for flash messages in tests #16889
Draft
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.
Ticket
None
Follow up to #16789 (this comment) and #16863.
What are you trying to accomplish?
Make the test code more intentional when we want to be precise with flash messages, and less verbose when we just want to dismiss them, the flash helpers do not have implicit values for
:type
and:message
anymore, and do not require them to be present either.What approach did you choose and why?
Previously
expect_flash
default value fortype
was:success
, meaning that code likeexpect_flash(message: "An error occurred")
implicitly expected a:success
flash, which is not obvious by reading the code.This commit changes the default value for
type
to:any
for all flash helpers, so that there is no implicit expectations on the flash type anymore.expect_flash(message: "An error occurred")
would then check the flash message text and only the flash message text, which is a fair expectation.Additionally, it also relaxes the expectation on the message text so that
expect_and_dismiss_flash
and other helpers can be called without:type
or:message
parameters, and it will be done regardless of the flash type and message text.Finally it also adds documentation to all flash helpers.
Merge checklist