2019-07-25 05:27:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-07 18:36:58 +00:00
|
|
|
module SearchHelpers
|
2020-09-18 18:10:26 +00:00
|
|
|
def fill_in_search(text)
|
2022-03-28 09:07:06 +00:00
|
|
|
# Once the `new_header_search` feature flag has been removed
|
|
|
|
# We can remove the `.search-input-wrap` selector
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/339348
|
|
|
|
page.within('.header-search-new') do
|
2020-10-30 09:08:39 +00:00
|
|
|
find('#search').click
|
2022-03-28 09:07:06 +00:00
|
|
|
fill_in 'search', with: text
|
2020-09-18 18:10:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_all_requests
|
|
|
|
end
|
|
|
|
|
2020-10-22 03:08:25 +00:00
|
|
|
def submit_search(query)
|
2022-03-04 15:16:11 +00:00
|
|
|
# Once the `new_header_search` feature flag has been removed
|
|
|
|
# We can remove the `.search-form` selector
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/339348
|
|
|
|
page.within('.header-search, .search-form, .search-page-form') do
|
2019-08-30 09:49:14 +00:00
|
|
|
field = find_field('search')
|
2022-03-04 15:16:11 +00:00
|
|
|
field.click
|
2019-08-30 09:49:14 +00:00
|
|
|
field.fill_in(with: query)
|
|
|
|
|
|
|
|
if javascript_test?
|
|
|
|
field.send_keys(:enter)
|
|
|
|
else
|
|
|
|
click_button('Search')
|
|
|
|
end
|
2020-09-18 18:10:26 +00:00
|
|
|
|
|
|
|
wait_for_all_requests
|
2019-08-30 09:49:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def select_search_scope(scope)
|
|
|
|
page.within '.search-filter' do
|
|
|
|
click_link scope
|
|
|
|
end
|
2016-11-07 18:36:58 +00:00
|
|
|
end
|
2019-09-09 13:46:24 +00:00
|
|
|
|
2019-11-15 08:21:08 +00:00
|
|
|
def has_search_scope?(scope)
|
|
|
|
page.within '.search-filter' do
|
|
|
|
has_link?(scope)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-09 13:46:24 +00:00
|
|
|
def max_limited_count
|
|
|
|
Gitlab::SearchResults::COUNT_LIMIT_MESSAGE
|
|
|
|
end
|
2016-11-07 18:36:58 +00:00
|
|
|
end
|