diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/support/helpers/filtered_search_helpers.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/support/helpers/filtered_search_helpers.rb')
-rw-r--r-- | spec/support/helpers/filtered_search_helpers.rb | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/spec/support/helpers/filtered_search_helpers.rb b/spec/support/helpers/filtered_search_helpers.rb index b6cf78b9046..93122ca3d0c 100644 --- a/spec/support/helpers/filtered_search_helpers.rb +++ b/spec/support/helpers/filtered_search_helpers.rb @@ -187,4 +187,116 @@ module FilteredSearchHelpers toggle.click if toggle.visible? end end + + ## + # For use with gl-filtered-search + def select_tokens(*args, submit: false) + within '[data-testid="filtered-search-input"]' do + find_field('Search').click + + args.each do |token| + # Move mouse away to prevent invoking tooltips on usernames, which blocks the search input + find_button('Search').hover + + if token == '=' + click_on '= is' + else + click_on token + end + + wait_for_requests + end + end + + if submit + send_keys :enter + end + end + + def get_suggestion_count + all('.gl-filtered-search-suggestion').size + end + + def submit_search_term(value) + click_filtered_search_bar + send_keys(value, :enter) + end + + def click_filtered_search_bar + find('.gl-filtered-search-last-item').click + end + + def click_token_segment(value) + find('.gl-filtered-search-token-segment', text: value).click + end + + def expect_visible_suggestions_list + expect(page).to have_css('.gl-filtered-search-suggestion-list') + end + + def expect_hidden_suggestions_list + expect(page).not_to have_css('.gl-filtered-search-suggestion-list') + end + + def expect_suggestion(value) + expect(page).to have_css('.gl-filtered-search-suggestion', text: value) + end + + def expect_no_suggestion(value) + expect(page).not_to have_css('.gl-filtered-search-suggestion', text: value) + end + + def expect_suggestion_count(count) + expect(page).to have_css('.gl-filtered-search-suggestion', count: count) + end + + def expect_assignee_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Assignee = #{value}" + end + + def expect_author_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Author = #{value}" + end + + def expect_label_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Label = ~#{value}" + end + + def expect_negated_label_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Label != ~#{value}" + end + + def expect_milestone_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Milestone = %#{value}" + end + + def expect_negated_milestone_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Milestone != %#{value}" + end + + def expect_epic_token(value) + expect(page).to have_css '.gl-filtered-search-token', text: "Epic = #{value}" + end + + def expect_search_term(value) + value.split(' ').each do |term| + expect(page).to have_css '.gl-filtered-search-term', text: term + end + end + + def expect_empty_search_term + expect(page).to have_css '.gl-filtered-search-term', text: '' + end + + def expect_token_segment(value) + expect(page).to have_css '.gl-filtered-search-token-segment', text: value + end + + def expect_recent_searches_history_item(value) + expect(page).to have_css '.gl-search-box-by-click-history-item', text: value + end + + def expect_recent_searches_history_item_count(count) + expect(page).to have_css '.gl-search-box-by-click-history-item', count: count + end end |