1 require 'integration_helper'
3 class FilterableInfiniteScrollTest < ActionDispatch::IntegrationTest
5 headless = Headless.new
7 Capybara.current_driver = :selenium
10 # Chrome remembers what you had in the text field when you hit
11 # "back". Here, we simulate the same effect by sending an otherwise
12 # unused ?search=foo param to pre-populate the search field.
13 test 'no double-load if text input has a value at page load time' do
14 visit page_with_token('admin', '/pipeline_instances')
15 assert_text 'pipeline_2'
16 visit page_with_token('admin', '/pipeline_instances?search=pipeline_1')
17 # Horrible hack to ensure the search results can't load correctly
18 # on the second attempt.
19 assert_selector '#recent-pipeline-instances'
20 assert page.evaluate_script('$("#recent-pipeline-instances[data-infinite-content-href0]").attr("data-infinite-content-href0","/give-me-an-error").length == 1')
21 # Wait for the first page of results to appear.
22 assert_text 'pipeline_1'
23 # Make sure the results are filtered.
24 assert_no_text 'pipeline_2'
25 # Make sure pipeline_2 didn't disappear merely because the results
26 # were replaced with an error message.
27 assert_text 'pipeline_1'