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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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 11 times, most recently from 79ec955 to add742f Compare February 17, 2024 22:18
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
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.

None yet

1 participant