[6.x] Add clickAndWaitForReload
#953
Merged
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.
This PR adds a
clickAndWaitForReloadmethod as syntactic sugar. I have this macro'd in my projects and use it all the time. I figured it was worth trying a PR.If you use
duskattributes on elements,clickAndWaitForReloadcan be used to navigate almost the entire app. Instead of code like this:You write this instead:
This way of writing tests has worked great for me in Blade + Livewire projects.
The same kind of syntactic sugar could be added for
pressAndWaitForReloadandclickLinkAndWaitForReload. I don't use those methods personally so I didn't include them in this PR.There wasn't a logical place to put this new method, so I ended up putting it next to
waitForReload. The new method uses methods from both theInteractsWithMouseandWaitsForElementstraits. Maybe a new trait calledProvidesGreatUXwould be a good place for methods like this.This PR doesn't include tests because I couldn't figure out how to craft a suitable mock.