Commit a42ce8d3 authored by Terri Chu's avatar Terri Chu Committed by Dylan Griffith

Keep Search Scope Tab Order Consistent

parent 98643f5b
......@@ -13,23 +13,25 @@
= search_filter_link 'issues', _("Issues")
- if project_search_tabs?(:merge_requests)
= search_filter_link 'merge_requests', _("Merge requests")
- if project_search_tabs?(:milestones)
= search_filter_link 'milestones', _("Milestones")
- if project_search_tabs?(:notes)
= search_filter_link 'notes', _("Comments")
- if project_search_tabs?(:wiki)
= search_filter_link 'wiki_blobs', _("Wiki")
- if project_search_tabs?(:commits)
= search_filter_link 'commits', _("Commits")
- if project_search_tabs?(:notes)
= search_filter_link 'notes', _("Comments")
- if project_search_tabs?(:milestones)
= search_filter_link 'milestones', _("Milestones")
= users
- elsif @show_snippets
= search_filter_link 'snippet_titles', _("Titles and Descriptions"), search: { snippets: true, group_id: nil, project_id: nil }
- else
= search_filter_link 'projects', _("Projects"), data: { qa_selector: 'projects_tab' }
= render_if_exists 'search/category_code'
= render_if_exists 'search/epics_filter_link'
= search_filter_link 'issues', _("Issues")
= search_filter_link 'merge_requests', _("Merge requests")
= search_filter_link 'milestones', _("Milestones")
= render_if_exists 'search/epics_filter_link'
= render_if_exists 'search/category_wiki'
= render_if_exists 'search/category_elasticsearch'
= search_filter_link 'milestones', _("Milestones")
= users
---
title: Keep consistent Global Search tab order
merge_request: 60319
author:
type: changed
- if search_service.show_elasticsearch_tabs?
= search_filter_link 'blobs', _("Code"), data: { qa_selector: 'code_tab' }
- if search_service.show_elasticsearch_tabs?
= search_filter_link 'notes', _("Comments")
= search_filter_link 'blobs', _("Code"), data: { qa_selector: 'code_tab' }
= search_filter_link 'commits', _("Commits")
= search_filter_link 'wiki_blobs', _("Wiki")
= search_filter_link 'notes', _("Comments")
- if search_service.show_elasticsearch_tabs?
= search_filter_link 'wiki_blobs', _("Wiki")
......@@ -113,10 +113,46 @@ RSpec.describe SearchController, :elastic do
end
end
shared_examples 'search tabs displayed in consistent order' do
render_views
let(:scope) { 'issues' }
subject { get :show, params: request_params, format: :html }
it 'keeps search tab order' do
subject
# this order should be consistent across global, group, and project scoped searches
# though all tabs may not be available depending on the search scope and features enabled (epics, advanced search)
global_expected_order = %w[projects blobs epics issues merge_requests wiki_blobs commits notes milestones users]
tabs = response.body.scan(/search\?.*scope=(\w*)&amp/).flatten
expect(tabs).to eq(global_expected_order & tabs)
end
end
context 'global search' do
let(:request_params) { { scope: scope, search: 'term' } }
it_behaves_like 'renders the elasticsearch tabs if elasticsearch is enabled'
context 'scope tab order' do
context 'when elasticsearch is disabled' do
before do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
it_behaves_like 'search tabs displayed in consistent order'
end
context 'when elasticsearch is enabled' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
it_behaves_like 'search tabs displayed in consistent order'
end
end
end
context 'group search' do
......@@ -125,6 +161,81 @@ RSpec.describe SearchController, :elastic do
let(:request_params) { { group_id: group.id, scope: scope, search: 'term' } }
it_behaves_like 'renders the elasticsearch tabs if elasticsearch is enabled'
context 'scope tab order' do
context 'when elasticsearch is disabled' do
before do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
context 'when epics are disabled' do
before do
stub_licensed_features(epics: false)
end
it_behaves_like 'search tabs displayed in consistent order'
end
context 'when epics are enabled' do
before do
stub_licensed_features(epics: true)
end
it_behaves_like 'search tabs displayed in consistent order'
end
end
context 'when elasticsearch is enabled' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
context 'when epics are disabled' do
before do
stub_licensed_features(epics: false)
end
it_behaves_like 'search tabs displayed in consistent order'
end
context 'when epics are enabled' do
before do
stub_licensed_features(epics: true)
end
it_behaves_like 'search tabs displayed in consistent order'
end
end
end
end
context 'project search' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let(:request_params) { { project_id: project.id, group_id: project.group, scope: scope, search: 'term' } }
before do
project.add_developer(user)
end
context 'scope tab order' do
context 'when elasticsearch is disabled' do
before do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
it_behaves_like 'search tabs displayed in consistent order'
end
context 'when elasticsearch is enabled' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
it_behaves_like 'search tabs displayed in consistent order'
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment