Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

excid3
Copy link
Contributor

@excid3 excid3 commented May 29, 2025

This adds integration test helpers for turbo frames. There are already helpers for turbo streams so this brings Frames into parity with them.

Comment on lines 118 to 124
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
Copy link
Contributor

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:

Suggested change
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

Copy link
Contributor Author

@excid3 excid3 Jun 2, 2025

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.

excid3 and others added 3 commits June 2, 2025 14:12
Co-authored-by: Sean Doyle <seanpdoyle@users.noreply.github.com>
Co-authored-by: Sean Doyle <seanpdoyle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants