diff options
author | Markus Koller <mkoller@gitlab.com> | 2019-08-30 12:49:14 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-08-30 12:49:14 +0300 |
commit | 1bccd36f04f1e1c4efe9155ea9037910c42a3749 (patch) | |
tree | 5fa93f57ef35c07ee4cd9c15480404d15f0c47b3 /spec/support/helpers | |
parent | b76bc2762a245c61089fae486e61c9fd83d45f95 (diff) |
Improve search result labels
- Use "results" instead of "blobs", "wiki blobs", "snippet blobs"
- Use "comments" instead of "notes"
- Use correct pluralization
- Don't add "1 - 10 of" if there's only one page
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/capybara_helpers.rb | 4 | ||||
-rw-r--r-- | spec/support/helpers/search_helpers.rb | 19 | ||||
-rw-r--r-- | spec/support/helpers/wait_for_requests.rb | 4 |
3 files changed, 21 insertions, 6 deletions
diff --git a/spec/support/helpers/capybara_helpers.rb b/spec/support/helpers/capybara_helpers.rb index 5abbc1e2951..a7baa7042c9 100644 --- a/spec/support/helpers/capybara_helpers.rb +++ b/spec/support/helpers/capybara_helpers.rb @@ -42,4 +42,8 @@ module CapybaraHelpers def clear_browser_session page.driver.browser.manage.delete_cookie('_gitlab_session') end + + def javascript_test? + Capybara.current_driver == Capybara.javascript_driver + end end diff --git a/spec/support/helpers/search_helpers.rb b/spec/support/helpers/search_helpers.rb index 815337f8615..2cf3f4b83c4 100644 --- a/spec/support/helpers/search_helpers.rb +++ b/spec/support/helpers/search_helpers.rb @@ -1,7 +1,22 @@ # frozen_string_literal: true module SearchHelpers - def select_filter(name) - find(:xpath, "//ul[contains(@class, 'search-filter')]//a[contains(.,'#{name}')]").click + def submit_search(query, scope: nil) + page.within('.search-form, .search-page-form') do + field = find_field('search') + field.fill_in(with: query) + + if javascript_test? + field.send_keys(:enter) + else + click_button('Search') + end + end + end + + def select_search_scope(scope) + page.within '.search-filter' do + click_link scope + end end end diff --git a/spec/support/helpers/wait_for_requests.rb b/spec/support/helpers/wait_for_requests.rb index 3bb2f7c5b51..30dff1063b5 100644 --- a/spec/support/helpers/wait_for_requests.rb +++ b/spec/support/helpers/wait_for_requests.rb @@ -61,8 +61,4 @@ module WaitForRequests Capybara.page.evaluate_script('jQuery.active').zero? end - - def javascript_test? - Capybara.current_driver == Capybara.javascript_driver - end end |