Skip to content
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

Introduce Turbo::SystemTestHelper #577

Merged

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Feb 11, 2024

Introduce the Turbo::SystemTestHelper module to be included into
ActionDispatch::SystemTestCase when it's available.

The module is named to mimic ActionText::SystemTestHelper.

The module defines a #connect_turbo_cable_stream_sources helper
method extracted from this project's System Test suite. It aims to
synchronize the test harness with Turbo's Action Cable-powered broadcast
support. The method will find all <turbo-cable-stream-source> elements
that are present but not yet [connected] (returning the results
immediately with Capybara's :wait), then wait for them to connect
(using whatever Capybara's configured wait value).

In addition to the connect_turbo_cable_stream_sources, also introduce
a :turbo_cable_stream_source Capybara selector, along with
assert_turbo_cable_stream_source and
assert_no_turbo_cable_stream_source helper methods.

@seanpdoyle seanpdoyle force-pushed the wait-for-cable-stream-sources branch 7 times, most recently from f9c07f7 to b6774ee Compare February 13, 2024 18:45
@seanpdoyle
Copy link
Contributor Author

@jorgemanrubia @afcapel have you encountered this in your test suites?

lib/turbo/engine.rb Outdated Show resolved Hide resolved
@seanpdoyle seanpdoyle force-pushed the wait-for-cable-stream-sources branch 12 times, most recently from add742f to d7c74a1 Compare February 17, 2024 22:19
@seanpdoyle seanpdoyle force-pushed the wait-for-cable-stream-sources branch from d7c74a1 to 6cf1d3a Compare July 13, 2024 09:56
Introduce the `Turbo::SystemTestHelper` module to be included into
[ActionDispatch::SystemTestCase][] when it's available.

The module is named to mimic [ActionText::SystemTestHelper][].

The module defines a `#connect_turbo_cable_stream_sources` helper
method extracted from this project's System Test suite. It aims to
synchronize the test harness with Turbo's Action Cable-powered broadcast
support. The method will find all `<turbo-cable-stream-source>` elements
that are present but not yet `[connected]` (returning the results
immediately with Capybara's `:wait`), then wait for them to connect
(using whatever Capybara's configured wait value).

In addition to the `connect_turbo_cable_stream_sources`, also introduce
a `:turbo_cable_stream_source` Capybara selector, along with
`assert_turbo_cable_stream_source` and
`assert_no_turbo_cable_stream_source` helper methods.

[ActionDispatch::SystemTestCase]: https://edgeapi.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
[ActionText::SystemTestHelper]: https://edgeapi.rubyonrails.org/classes/ActionText/SystemTestHelper.html
@seanpdoyle
Copy link
Contributor Author

@brunoprietog are you able to review this?

@gjtorikian
Copy link

Bless you and your bumps across PRs @seanpdoyle — I see you and thank you.

Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great one @seanpdoyle

@jorgemanrubia jorgemanrubia merged commit 9f5c846 into hotwired:main Sep 17, 2024
15 checks passed
@seanpdoyle seanpdoyle deleted the wait-for-cable-stream-sources branch September 17, 2024 12:01
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.

3 participants