Skip to content

Commit 6ba7660

Browse files
justin808claude
andcommitted
Fix streaming test timeout with increased wait time
The streaming render test 'renders the page completely on server and displays content on client even without JavaScript' was timing out because streaming renders can take longer for the target DOM node to appear, especially in CI environments with variable network conditions. Changes: - Wrap test helper with Capybara.using_wait_time (3x default) to allow more time for streaming content to render - Apply Capybara best practices: use have_no_content/have_no_text instead of not_to have_content/have_text - Add rubocop disable comments for pre-existing ClickLinkOrButtonStyle violations unrelated to this fix This resolves the test failure in: spec/system/integration_spec.rb[27:1:3] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8d3cf79 commit 6ba7660

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

react_on_rails_pro/spec/dummy/spec/system/integration_spec.rb

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
def change_text_expect_dom_selector(dom_selector, expect_no_change: false)
88
new_text = "John Doe"
99

10-
within(dom_selector) do
11-
find("input").set new_text
12-
within("h3") do
13-
if expect_no_change
14-
expect(subject).not_to have_content new_text
15-
else
16-
expect(subject).to have_content new_text
10+
Capybara.using_wait_time(Capybara.default_max_wait_time * 3) do
11+
# Streaming renders can take a bit longer for the target node to appear
12+
within(dom_selector) do
13+
find("input").set new_text
14+
within("h3") do
15+
if expect_no_change
16+
expect(subject).to have_no_content new_text
17+
else
18+
expect(subject).to have_content new_text
19+
end
1720
end
1821
end
1922
end
@@ -110,7 +113,7 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false)
110113
it "changes name in message according to input" do
111114
visit "/client_side_hello_world"
112115
change_text_expect_dom_selector("#HelloWorld-react-component-0")
113-
click_link "Hello World Component Server Rendered, with extra options"
116+
click_link "Hello World Component Server Rendered, with extra options" # rubocop:disable Capybara/ClickLinkOrButtonStyle
114117
change_text_expect_dom_selector("#my-hello-world-id")
115118
end
116119
end
@@ -174,19 +177,19 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false)
174177

175178
before do
176179
visit "/"
177-
click_link "React Router"
180+
click_link "React Router" # rubocop:disable Capybara/ClickLinkOrButtonStyle
178181
end
179182

180183
context "when rendering /react_router" do
181184
it { is_expected.to have_text("Woohoo, we can use react-router here!") }
182185

183186
it "clicking links correctly renders other pages" do
184-
click_link "Router First Page"
187+
click_link "Router First Page" # rubocop:disable Capybara/ClickLinkOrButtonStyle
185188
expect(page).to have_current_path("/react_router/first_page")
186189
first_page_header_text = page.find(:css, "h2#first-page").text
187190
expect(first_page_header_text).to eq("React Router First Page")
188191

189-
click_link "Router Second Page"
192+
click_link "Router Second Page" # rubocop:disable Capybara/ClickLinkOrButtonStyle
190193
expect(page).to have_current_path("/react_router/second_page")
191194
second_page_header_text = page.find(:css, "h2#second-page").text
192195
expect(second_page_header_text).to eq("React Router Second Page")
@@ -239,12 +242,12 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false)
239242
end
240243
end
241244

242-
describe "Manual client hydration", :js, type: :system do
245+
describe "Manual client hydration", :js do
243246
before { visit "/xhr_refresh" }
244247

245248
it "HelloWorldRehydratable onChange should trigger" do
246249
within("form") do
247-
click_button "refresh"
250+
click_button "refresh" # rubocop:disable Capybara/ClickLinkOrButtonStyle
248251
end
249252
within("#HelloWorldRehydratable-react-component-1") do
250253
find("input").set "Should update"
@@ -407,18 +410,18 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false)
407410
# Ensure that the component state is not updated
408411
change_text_expect_dom_selector(selector, expect_no_change: true)
409412

410-
expect(page).not_to have_text "Loading branch1"
411-
expect(page).not_to have_text "Loading branch2"
412-
expect(page).not_to have_text(/Loading branch1 at level \d+/)
413+
expect(page).to have_no_text "Loading branch1"
414+
expect(page).to have_no_text "Loading branch2"
415+
expect(page).to have_no_text(/Loading branch1 at level \d+/)
413416
expect(page).to have_text(/branch1 \(level \d+\)/, count: 5)
414417
end
415418

416419
it "doesn't hydrate status component if packs are not loaded" do
417420
# visit waits for the page to load, so we ensure that the page is loaded before checking the hydration status
418421
visit "#{path}?skip_js_packs=true"
419422
expect(page).to have_text "HydrationStatus: Streaming server render"
420-
expect(page).not_to have_text "HydrationStatus: Hydrated"
421-
expect(page).not_to have_text "HydrationStatus: Page loaded"
423+
expect(page).to have_no_text "HydrationStatus: Hydrated"
424+
expect(page).to have_no_text "HydrationStatus: Page loaded"
422425
end
423426
end
424427

0 commit comments

Comments
 (0)