-
Notifications
You must be signed in to change notification settings - Fork 345
Add turbo frame assertion test helpers #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
lib/turbo/test_assertions.rb
Outdated
def assert_turbo_frame(id:, loading: nil, src: nil, target: nil, count: 1, &block) | ||
selector = %(turbo-frame[id="#{id}"]) | ||
selector << %([loading="#{loading}"]) if loading | ||
selector << %([src="#{src}"]) if src | ||
selector << %([target="#{target}"]) if target | ||
assert_select selector, count: count, &block | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about omitting the count:
keyword option, and instead forwarding all remaining options:
def assert_turbo_frame(id:, loading: nil, src: nil, target: nil, count: 1, &block) | |
selector = %(turbo-frame[id="#{id}"]) | |
selector << %([loading="#{loading}"]) if loading | |
selector << %([src="#{src}"]) if src | |
selector << %([target="#{target}"]) if target | |
assert_select selector, count: count, &block | |
end | |
def assert_turbo_frame(id:, loading: nil, src: nil, target: nil, **options, &block) | |
selector = %(turbo-frame[id="#{id}"]) | |
selector << %([loading="#{loading}"]) if loading | |
selector << %([src="#{src}"]) if src | |
selector << %([target="#{target}"]) if target | |
assert_select selector, **options, &block | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since frames IDs should be unique, I thought it might make sense to set count to 1 instead of unset which matches 1 or more.
Co-authored-by: Sean Doyle <seanpdoyle@users.noreply.github.com>
Co-authored-by: Sean Doyle <seanpdoyle@users.noreply.github.com>
This adds integration test helpers for turbo frames. There are already helpers for turbo streams so this brings Frames into parity with them.