Skip to content

Commit 80fb337

Browse files
excid3seanpdoyle
andcommitted
Include hidden elements for turbo-cable-stream-source selector
Chrome considers these elements not visible (likely due to their 0px size) so the assertion never matches. This changes the default visible flag to include all elements. Co-authored-by: Sean Doyle <[email protected]>
1 parent cb47713 commit 80fb337

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/turbo/system_test_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def assert_no_turbo_cable_stream_source(...)
8080
end
8181

8282
Capybara.add_selector :turbo_cable_stream_source do
83+
visible :all
84+
8385
xpath do |locator|
8486
xpath = XPath.descendant.where(XPath.local_name == "turbo-cable-stream-source")
8587
xpath.where(SignedStreamNameConditions.new(locator).reduce(:|))

test/dummy/app/views/messages/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1>Message #<%= @message.id %></h1>
22

3-
<%= turbo_stream_from @message %>
3+
<%= turbo_stream_from @message, style: "display: none" %>
44

55
<div id="<%= dom_id @message %>">
66
<%= render @message %>

test/system/broadcasts_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class BroadcastsTest < ApplicationSystemTestCase
123123
private
124124

125125
def reconnect_cable_stream_source(from:, to:)
126-
cable_stream_source = find("turbo-cable-stream-source[signed-stream-name=#{signed_stream_name(from)}]")
126+
cable_stream_source = find(:turbo_cable_stream_source, signed_stream_name: from)
127127

128128
cable_stream_source.execute_script <<~JS, signed_stream_name(to)
129129
this.setAttribute("signed-stream-name", arguments[0])

0 commit comments

Comments
 (0)