summaryrefslogtreecommitdiff
path: root/spec/features/issues/filtered_search/recent_searches_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /spec/features/issues/filtered_search/recent_searches_spec.rb
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
downloadgitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/features/issues/filtered_search/recent_searches_spec.rb')
-rw-r--r--spec/features/issues/filtered_search/recent_searches_spec.rb97
1 files changed, 38 insertions, 59 deletions
diff --git a/spec/features/issues/filtered_search/recent_searches_spec.rb b/spec/features/issues/filtered_search/recent_searches_spec.rb
index 3929d3694ff..bb5964258be 100644
--- a/spec/features/issues/filtered_search/recent_searches_spec.rb
+++ b/spec/features/issues/filtered_search/recent_searches_spec.rb
@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec.describe 'Recent searches', :js do
include FilteredSearchHelpers
- include MobileHelpers
let_it_be(:project_1) { create(:project, :public) }
let_it_be(:project_2) { create(:project, :public) }
@@ -14,116 +13,96 @@ RSpec.describe 'Recent searches', :js do
let(:project_1_local_storage_key) { "#{project_1.full_path}-issue-recent-searches" }
before do
- Capybara.ignore_hidden_elements = false
+ stub_feature_flags(vue_issues_list: true)
# Visit any fast-loading page so we can clear local storage without a DOM exception
visit '/404'
remove_recent_searches
end
- after do
- Capybara.ignore_hidden_elements = true
- end
-
it 'searching adds to recent searches' do
visit project_issues_path(project_1)
- input_filtered_search('foo', submit: true)
- input_filtered_search('bar', submit: true)
-
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ submit_then_clear_search 'foo'
+ submit_then_clear_search 'bar'
+ click_button 'Toggle history'
- expect(items[0].text).to eq('bar')
- expect(items[1].text).to eq('foo')
+ expect_recent_searches_history_item 'bar'
+ expect_recent_searches_history_item 'foo'
end
it 'visiting URL with search params adds to recent searches' do
visit project_issues_path(project_1, label_name: 'foo', search: 'bar')
visit project_issues_path(project_1, label_name: 'qux', search: 'garply')
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ click_button 'Toggle history'
- expect(items[0].text).to eq('label: = ~qux garply')
- expect(items[1].text).to eq('label: = ~foo bar')
+ expect_recent_searches_history_item 'Label := qux garply'
+ expect_recent_searches_history_item 'Label := foo bar'
end
it 'saved recent searches are restored last on the list' do
- set_recent_searches(project_1_local_storage_key, '["saved1", "saved2"]')
+ set_recent_searches(project_1_local_storage_key, '[[{"type":"filtered-search-term","value":{"data":"saved1"}}],[{"type":"filtered-search-term","value":{"data":"saved2"}}]]')
visit project_issues_path(project_1, search: 'foo')
+ click_button 'Toggle history'
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 3)
-
- expect(items[0].text).to eq('foo')
- expect(items[1].text).to eq('saved1')
- expect(items[2].text).to eq('saved2')
+ expect_recent_searches_history_item 'foo'
+ expect_recent_searches_history_item 'saved1'
+ expect_recent_searches_history_item 'saved2'
end
it 'searches are scoped to projects' do
visit project_issues_path(project_1)
- input_filtered_search('foo', submit: true)
- input_filtered_search('bar', submit: true)
+ submit_then_clear_search 'foo'
+ submit_then_clear_search 'bar'
visit project_issues_path(project_2)
- input_filtered_search('more', submit: true)
- input_filtered_search('things', submit: true)
-
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ submit_then_clear_search 'more'
+ submit_then_clear_search 'things'
+ click_button 'Toggle history'
- expect(items[0].text).to eq('things')
- expect(items[1].text).to eq('more')
+ expect_recent_searches_history_item 'things'
+ expect_recent_searches_history_item 'more'
end
it 'clicking item fills search input' do
- set_recent_searches(project_1_local_storage_key, '["foo", "bar"]')
+ set_recent_searches(project_1_local_storage_key, '[[{"type":"filtered-search-term","value":{"data":"foo"}}],[{"type":"filtered-search-term","value":{"data":"bar"}}]]')
visit project_issues_path(project_1)
- find('.filtered-search-history-dropdown-toggle-button').click
- all('.filtered-search-history-dropdown-item', count: 2)[0].click
- wait_for_filtered_search('foo')
+ click_button 'Toggle history'
+ click_button 'foo'
- expect(find('.filtered-search').value.strip).to eq('foo')
+ expect_search_term 'foo'
end
it 'clear recent searches button, clears recent searches' do
- set_recent_searches(project_1_local_storage_key, '["foo"]')
+ set_recent_searches(project_1_local_storage_key, '[[{"type":"filtered-search-term","value":{"data":"foo"}}]]')
visit project_issues_path(project_1)
- find('.filtered-search-history-dropdown-toggle-button').click
- all('.filtered-search-history-dropdown-item', count: 1)
+ click_button 'Toggle history'
- find('.filtered-search-history-clear-button').click
- items_after = all('.filtered-search-history-dropdown-item', count: 0)
+ expect_recent_searches_history_item_count 1
- expect(items_after.count).to eq(0)
+ click_button 'Clear recent searches'
+ click_button 'Toggle history'
+
+ expect(page).to have_text "You don't have any recent searches"
+ expect_recent_searches_history_item_count 0
end
it 'shows flash error when failed to parse saved history' do
set_recent_searches(project_1_local_storage_key, 'fail')
visit project_issues_path(project_1)
- expect(find('[data-testid="alert-danger"]')).to have_text('An error occurred while parsing recent searches')
+ expect(page).to have_text 'An error occurred while parsing recent searches'
end
- context 'on tablet/mobile screen' do
- it 'shows only the history icon in the dropdown' do
- resize_screen_sm
- visit project_issues_path(project_1)
-
- expect(find('.filtered-search-history-dropdown-wrapper')).to have_selector('svg', visible: true)
- expect(find('.filtered-search-history-dropdown-wrapper')).to have_selector('span', text: 'Recent searches', visible: false)
- end
- end
-
- context 'on PC screen' do
- it 'shows only the Recent searches text in the dropdown' do
- restore_window_size
- visit project_issues_path(project_1)
-
- expect(find('.filtered-search-history-dropdown-wrapper')).to have_selector('svg', visible: false)
- expect(find('.filtered-search-history-dropdown-wrapper')).to have_selector('span', text: 'Recent searches', visible: true)
- end
+ def submit_then_clear_search(search)
+ click_filtered_search_bar
+ send_keys(search, :enter)
+ click_button 'Clear'
end
end