|
7 | 7 | def change_text_expect_dom_selector(dom_selector, expect_no_change: false) |
8 | 8 | new_text = "John Doe" |
9 | 9 |
|
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 |
17 | 20 | end |
18 | 21 | end |
19 | 22 | end |
@@ -110,7 +113,7 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false) |
110 | 113 | it "changes name in message according to input" do |
111 | 114 | visit "/client_side_hello_world" |
112 | 115 | 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 |
114 | 117 | change_text_expect_dom_selector("#my-hello-world-id") |
115 | 118 | end |
116 | 119 | end |
@@ -174,19 +177,19 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false) |
174 | 177 |
|
175 | 178 | before do |
176 | 179 | visit "/" |
177 | | - click_link "React Router" |
| 180 | + click_link "React Router" # rubocop:disable Capybara/ClickLinkOrButtonStyle |
178 | 181 | end |
179 | 182 |
|
180 | 183 | context "when rendering /react_router" do |
181 | 184 | it { is_expected.to have_text("Woohoo, we can use react-router here!") } |
182 | 185 |
|
183 | 186 | it "clicking links correctly renders other pages" do |
184 | | - click_link "Router First Page" |
| 187 | + click_link "Router First Page" # rubocop:disable Capybara/ClickLinkOrButtonStyle |
185 | 188 | expect(page).to have_current_path("/react_router/first_page") |
186 | 189 | first_page_header_text = page.find(:css, "h2#first-page").text |
187 | 190 | expect(first_page_header_text).to eq("React Router First Page") |
188 | 191 |
|
189 | | - click_link "Router Second Page" |
| 192 | + click_link "Router Second Page" # rubocop:disable Capybara/ClickLinkOrButtonStyle |
190 | 193 | expect(page).to have_current_path("/react_router/second_page") |
191 | 194 | second_page_header_text = page.find(:css, "h2#second-page").text |
192 | 195 | 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) |
239 | 242 | end |
240 | 243 | end |
241 | 244 |
|
242 | | -describe "Manual client hydration", :js, type: :system do |
| 245 | +describe "Manual client hydration", :js do |
243 | 246 | before { visit "/xhr_refresh" } |
244 | 247 |
|
245 | 248 | it "HelloWorldRehydratable onChange should trigger" do |
246 | 249 | within("form") do |
247 | | - click_button "refresh" |
| 250 | + click_button "refresh" # rubocop:disable Capybara/ClickLinkOrButtonStyle |
248 | 251 | end |
249 | 252 | within("#HelloWorldRehydratable-react-component-1") do |
250 | 253 | find("input").set "Should update" |
@@ -407,18 +410,18 @@ def change_text_expect_dom_selector(dom_selector, expect_no_change: false) |
407 | 410 | # Ensure that the component state is not updated |
408 | 411 | change_text_expect_dom_selector(selector, expect_no_change: true) |
409 | 412 |
|
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+/) |
413 | 416 | expect(page).to have_text(/branch1 \(level \d+\)/, count: 5) |
414 | 417 | end |
415 | 418 |
|
416 | 419 | it "doesn't hydrate status component if packs are not loaded" do |
417 | 420 | # visit waits for the page to load, so we ensure that the page is loaded before checking the hydration status |
418 | 421 | visit "#{path}?skip_js_packs=true" |
419 | 422 | 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" |
422 | 425 | end |
423 | 426 | end |
424 | 427 |
|
|
0 commit comments