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