gitlab-org--gitlab-foss/spec/support/filtered_search_helpers.rb

70 lines
1.9 KiB
Ruby
Raw Normal View History

2017-02-15 22:13:53 +00:00
module FilteredSearchHelpers
def filtered_search
page.find('.filtered-search')
end
2017-01-30 22:53:18 +00:00
# Enables input to be set (similar to copy and paste)
2017-02-15 22:13:53 +00:00
def input_filtered_search(search_term, submit: true)
2017-01-30 22:53:18 +00:00
# Add an extra space to engage visual tokens
filtered_search.set("#{search_term} ")
2017-02-15 22:13:53 +00:00
if submit
filtered_search.send_keys(:enter)
end
end
2017-01-30 22:53:18 +00:00
# Enables input to be added character by character
2017-02-15 22:13:53 +00:00
def input_filtered_search_keys(search_term)
2017-01-30 22:53:18 +00:00
# Add an extra space to engage visual tokens
filtered_search.send_keys("#{search_term} ")
2017-02-15 22:13:53 +00:00
filtered_search.send_keys(:enter)
end
def expect_filtered_search_input(input)
expect(find('.filtered-search').value).to eq(input)
end
def clear_search_field
find('.filtered-search-input-container .clear-search').click
end
def reset_filters
clear_search_field
filtered_search.send_keys(:enter)
end
def init_label_search
filtered_search.set('label:')
# This ensures the dropdown is shown
expect(find('#js-dropdown-label')).not_to have_css('.filter-dropdown-loading')
end
2017-01-30 22:53:18 +00:00
def expect_filtered_search_input_empty
expect(find('.filtered-search').value).to eq('')
end
# Iterates through each visual token inside
# .tokens-container to make sure the correct names and values are rendered
def expect_tokens(tokens)
page.find '.filtered-search-input-container .tokens-container' do
page.all(:css, '.tokens-container li').each_with_index do |el, index|
token_name = tokens[index][:name]
token_value = tokens[index][:value]
expect(el.find('.name')).to have_content(token_name)
if token_value
expect(el.find('.value')).to have_content(token_value)
end
end
end
end
def default_placeholder
'Search or filter results...'
end
def get_filtered_search_placeholder
find('.filtered-search')['placeholder']
end
2017-02-15 22:13:53 +00:00
end