diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/features/search | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/features/search')
3 files changed, 97 insertions, 37 deletions
diff --git a/spec/features/search/user_searches_for_issues_spec.rb b/spec/features/search/user_searches_for_issues_spec.rb index e9943347522..900ed35adea 100644 --- a/spec/features/search/user_searches_for_issues_spec.rb +++ b/spec/features/search/user_searches_for_issues_spec.rb @@ -6,7 +6,13 @@ RSpec.describe 'User searches for issues', :js do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } let!(:issue1) { create(:issue, title: 'Foo', project: project) } - let!(:issue2) { create(:issue, title: 'Bar', project: project) } + let!(:issue2) { create(:issue, :closed, :confidential, title: 'Bar', project: project) } + + def search_for_issue(search) + fill_in('dashboard_search', with: search) + find('.btn-search').click + select_search_scope('Issues') + end context 'when signed in' do before do @@ -19,9 +25,7 @@ RSpec.describe 'User searches for issues', :js do include_examples 'top right search form' it 'finds an issue' do - fill_in('dashboard_search', with: issue1.title) - find('.btn-search').click - select_search_scope('Issues') + search_for_issue(issue1.title) page.within('.results') do expect(page).to have_link(issue1.title) @@ -29,6 +33,40 @@ RSpec.describe 'User searches for issues', :js do end end + it 'hides confidential icon for non-confidential issues' do + search_for_issue(issue1.title) + + page.within('.results') do + expect(page).not_to have_css('[data-testid="eye-slash-icon"]') + end + end + + it 'shows confidential icon for confidential issues' do + search_for_issue(issue2.title) + + page.within('.results') do + expect(page).to have_css('[data-testid="eye-slash-icon"]') + end + end + + it 'shows correct badge for open issues' do + search_for_issue(issue1.title) + + page.within('.results') do + expect(page).to have_css('.badge-success') + expect(page).not_to have_css('.badge-info') + end + end + + it 'shows correct badge for closed issues' do + search_for_issue(issue2.title) + + page.within('.results') do + expect(page).not_to have_css('.badge-success') + expect(page).to have_css('.badge-info') + end + end + context 'when on a project page' do it 'finds an issue' do find('.js-search-project-dropdown').click @@ -37,9 +75,7 @@ RSpec.describe 'User searches for issues', :js do click_link(project.full_name) end - fill_in('dashboard_search', with: issue1.title) - find('.btn-search').click - select_search_scope('Issues') + search_for_issue(issue1.title) page.within('.results') do expect(page).to have_link(issue1.title) @@ -50,22 +86,33 @@ RSpec.describe 'User searches for issues', :js do end context 'when signed out' do - let(:project) { create(:project, :public) } + context 'when block_anonymous_global_searches is disabled' do + let(:project) { create(:project, :public) } - before do - visit(search_path) - end + before do + stub_feature_flags(block_anonymous_global_searches: false) + visit(search_path) + end - include_examples 'top right search form' + include_examples 'top right search form' - it 'finds an issue' do - fill_in('dashboard_search', with: issue1.title) - find('.btn-search').click - select_search_scope('Issues') + it 'finds an issue' do + search_for_issue(issue1.title) - page.within('.results') do - expect(page).to have_link(issue1.title) - expect(page).not_to have_link(issue2.title) + page.within('.results') do + expect(page).to have_link(issue1.title) + expect(page).not_to have_link(issue2.title) + end + end + end + + context 'when block_anonymous_global_searches is enabled' do + before do + visit(search_path) + end + + it 'is redirected to login page' do + expect(page).to have_content('You must be logged in to search across all of GitLab') end end end diff --git a/spec/features/search/user_searches_for_projects_spec.rb b/spec/features/search/user_searches_for_projects_spec.rb index 7bb5a4da7d0..b64909dd42f 100644 --- a/spec/features/search/user_searches_for_projects_spec.rb +++ b/spec/features/search/user_searches_for_projects_spec.rb @@ -6,31 +6,44 @@ RSpec.describe 'User searches for projects' do let!(:project) { create(:project, :public, name: 'Shop') } context 'when signed out' do - include_examples 'top right search form' + context 'when block_anonymous_global_searches is disabled' do + before do + stub_feature_flags(block_anonymous_global_searches: false) + end - it 'finds a project' do - visit(search_path) + include_examples 'top right search form' - fill_in('dashboard_search', with: project.name[0..3]) - click_button('Search') + it 'finds a project' do + visit(search_path) - expect(page).to have_link(project.name) - end + fill_in('dashboard_search', with: project.name[0..3]) + click_button('Search') - it 'preserves the group being searched in' do - visit(search_path(group_id: project.namespace.id)) + expect(page).to have_link(project.name) + end - submit_search('foo') + it 'preserves the group being searched in' do + visit(search_path(group_id: project.namespace.id)) - expect(find('#group_id', visible: false).value).to eq(project.namespace.id.to_s) - end + submit_search('foo') + + expect(find('#group_id', visible: false).value).to eq(project.namespace.id.to_s) + end - it 'preserves the project being searched in' do - visit(search_path(project_id: project.id)) + it 'preserves the project being searched in' do + visit(search_path(project_id: project.id)) - submit_search('foo') + submit_search('foo') + + expect(find('#project_id', visible: false).value).to eq(project.id.to_s) + end + end - expect(find('#project_id', visible: false).value).to eq(project.id.to_s) + context 'when block_anonymous_global_searches is enabled' do + it 'is redirected to login page' do + visit(search_path) + expect(page).to have_content('You must be logged in to search across all of GitLab') + end end end end diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb index 37e83d1e888..cfda25b9ab4 100644 --- a/spec/features/search/user_uses_header_search_field_spec.rb +++ b/spec/features/search/user_uses_header_search_field_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'User uses header search field', :js do context 'when using the keyboard shortcut' do before do - find('#search.js-autocomplete-disabled') + find('#search') find('body').native.send_keys('s') end @@ -39,7 +39,7 @@ RSpec.describe 'User uses header search field', :js do context 'when clicking the search field' do before do - page.find('#search.js-autocomplete-disabled').click + page.find('#search').click end it 'shows category search dropdown' do |