Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-16 21:11:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-16 21:11:26 +0300
commit8fa0c53e26c947ac647b8067fde3e9673b77b1a6 (patch)
treeda32e7224125973e9e87d3856fb7e672ff41c8b1 /spec/features/search
parent0552020767452da44de2bf5424096f2cb2ea6bf5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/search')
-rw-r--r--spec/features/search/user_searches_for_code_spec.rb323
-rw-r--r--spec/features/search/user_searches_for_comments_spec.rb61
-rw-r--r--spec/features/search/user_searches_for_commits_spec.rb74
-rw-r--r--spec/features/search/user_searches_for_issues_spec.rb177
-rw-r--r--spec/features/search/user_searches_for_merge_requests_spec.rb84
-rw-r--r--spec/features/search/user_searches_for_milestones_spec.rb67
-rw-r--r--spec/features/search/user_searches_for_projects_spec.rb5
-rw-r--r--spec/features/search/user_searches_for_users_spec.rb118
-rw-r--r--spec/features/search/user_searches_for_wiki_pages_spec.rb70
-rw-r--r--spec/features/search/user_uses_header_search_field_spec.rb6
10 files changed, 516 insertions, 469 deletions
diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb
index 50e6eb66466..ee74ac84a73 100644
--- a/spec/features/search/user_searches_for_code_spec.rb
+++ b/spec/features/search/user_searches_for_code_spec.rb
@@ -2,228 +2,237 @@
require 'spec_helper'
-RSpec.describe 'User searches for code' do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository, namespace: user.namespace) }
-
- context 'when signed in' do
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- project.add_maintainer(user)
- sign_in(user)
- end
-
- it 'finds a file' do
- visit(project_path(project))
+RSpec.describe 'User searches for code', :js, :disable_rate_limiter do
+ using RSpec::Parameterized::TableSyntax
- submit_search('application.js')
- select_search_scope('Code')
+ let_it_be(:user) { create(:user) }
+ let_it_be_with_reload(:project) { create(:project, :repository, namespace: user.namespace) }
- expect(page).to have_selector('.results', text: 'application.js')
- expect(page).to have_selector('.file-content .code')
- expect(page).to have_selector("span.line[lang='javascript']")
- expect(page).to have_link('application.js', href: %r{master/files/js/application.js})
- expect(page).to have_button('Copy file path')
- end
-
- context 'when on a project page', :js do
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ context 'when signed in' do
before do
- visit(search_path)
- find('[data-testid="project-filter"]').click
-
- wait_for_requests
-
- page.within('[data-testid="project-filter"]') do
- click_on(project.name)
- end
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ project.add_maintainer(user)
+ sign_in(user)
end
- include_examples 'top right search form'
- include_examples 'search timeouts', 'blobs'
+ it 'finds a file' do
+ visit(project_path(project))
- it 'finds code and links to blob' do
- fill_in('dashboard_search', with: 'rspec')
- find('.gl-search-box-by-click-search-button').click
+ submit_search('application.js')
+ select_search_scope('Code')
- expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
-
- find("#blob-L3").click
- expect(current_url).to match(%r{blob/master/.gitignore#L3})
+ expect(page).to have_selector('.results', text: 'application.js')
+ expect(page).to have_selector('.file-content .code')
+ expect(page).to have_selector("span.line[lang='javascript']")
+ expect(page).to have_link('application.js', href: %r{master/files/js/application.js})
+ expect(page).to have_button('Copy file path')
end
- it 'finds code and links to blame' do
- fill_in('dashboard_search', with: 'rspec')
- find('.gl-search-box-by-click-search-button').click
+ context 'when on a project page' do
+ before do
+ visit(search_path)
+ find('[data-testid="project-filter"]').click
- expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
+ wait_for_requests
- find("#blame-L3").click
- expect(current_url).to match(%r{blame/master/.gitignore#L3})
- end
+ page.within('[data-testid="project-filter"]') do
+ click_on(project.name)
+ end
+ end
- it 'search mutiple words with refs switching' do
- expected_result = 'Use `snake_case` for naming files'
- search = 'for naming files'
+ include_examples 'top right search form'
+ include_examples 'search timeouts', 'blobs' do
+ let(:additional_params) { { project_id: project.id } }
+ end
- fill_in('dashboard_search', with: search)
- find('.gl-search-box-by-click-search-button').click
+ it 'finds code and links to blob' do
+ expected_result = 'Update capybara, rspec-rails, poltergeist to recent versions'
- expect(page).to have_selector('.results', text: expected_result)
+ fill_in('dashboard_search', with: 'rspec')
+ find('.gl-search-box-by-click-search-button').click
- find('.ref-selector').click
- wait_for_requests
+ expect(page).to have_selector('.results', text: expected_result)
- page.within('.ref-selector') do
- find('li', text: 'v1.0.0').click
+ find("#blob-L3").click
+ expect(current_url).to match(%r{blob/master/.gitignore#L3})
end
- expect(page).to have_selector('.results', text: expected_result)
+ it 'finds code and links to blame' do
+ expected_result = 'Update capybara, rspec-rails, poltergeist to recent versions'
- expect(find_field('dashboard_search').value).to eq(search)
- expect(find("#blob-L1502")[:href]).to match(%r{blob/v1.0.0/files/markdown/ruby-style-guide.md#L1502})
- expect(find("#blame-L1502")[:href]).to match(%r{blame/v1.0.0/files/markdown/ruby-style-guide.md#L1502})
- end
- end
+ fill_in('dashboard_search', with: 'rspec')
+ find('.gl-search-box-by-click-search-button').click
- context 'when :new_header_search is true' do
- context 'search code within refs', :js do
- let(:ref_name) { 'v1.0.0' }
+ expect(page).to have_selector('.results', text: expected_result)
- before do
- # This feature is diabled by default in spec_helper.rb.
- # We missed a feature breaking bug, so to prevent this regression, testing both scenarios for this spec.
- # This can be removed as part of closing https://gitlab.com/gitlab-org/gitlab/-/issues/339348.
- stub_feature_flags(new_header_search: true)
- visit(project_tree_path(project, ref_name))
-
- submit_search('gitlab-grack')
- select_search_scope('Code')
+ find("#blame-L3").click
+ expect(current_url).to match(%r{blame/master/.gitignore#L3})
end
- it 'shows ref switcher in code result summary' do
- expect(find('.ref-selector')).to have_text(ref_name)
- end
+ it 'search multiple words with refs switching' do
+ expected_result = 'Use `snake_case` for naming files'
+ search = 'for naming files'
- it 'persists branch name across search' do
+ fill_in('dashboard_search', with: search)
find('.gl-search-box-by-click-search-button').click
- expect(find('.ref-selector')).to have_text(ref_name)
- end
- # this example is use to test the desgine that the refs is not
- # only repersent the branch as well as the tags.
- it 'ref swither list all the branchs and tags' do
+ expect(page).to have_selector('.results', text: expected_result)
+
find('.ref-selector').click
wait_for_requests
page.within('.ref-selector') do
- expect(page).to have_selector('li', text: 'add-ipython-files')
- expect(page).to have_selector('li', text: 'v1.0.0')
+ find('li', text: 'v1.0.0').click
end
+
+ expect(page).to have_selector('.results', text: expected_result)
+
+ expect(find_field('dashboard_search').value).to eq(search)
+ expect(find("#blob-L1502")[:href]).to match(%r{blob/v1.0.0/files/markdown/ruby-style-guide.md#L1502})
+ expect(find("#blame-L1502")[:href]).to match(%r{blame/v1.0.0/files/markdown/ruby-style-guide.md#L1502})
end
+ end
- it 'search result changes when refs switched' do
- ref = 'master'
- expect(find('.results')).not_to have_content('path = gitlab-grack')
+ context 'when :new_header_search is true' do
+ context 'search code within refs' do
+ let(:ref_name) { 'v1.0.0' }
- find('.ref-selector').click
- wait_for_requests
+ before do
+ # This feature is disabled by default in spec_helper.rb.
+ # We missed a feature breaking bug, so to prevent this regression, testing both scenarios for this spec.
+ # This can be removed as part of closing https://gitlab.com/gitlab-org/gitlab/-/issues/339348.
+ stub_feature_flags(new_header_search: true)
+ visit(project_tree_path(project, ref_name))
- page.within('.ref-selector') do
- fill_in _('Search by Git revision'), with: ref
+ submit_search('gitlab-grack')
+ select_search_scope('Code')
+ end
+
+ it 'shows ref switcher in code result summary' do
+ expect(find('.ref-selector')).to have_text(ref_name)
+ end
+
+ it 'persists branch name across search' do
+ find('.gl-search-box-by-click-search-button').click
+ expect(find('.ref-selector')).to have_text(ref_name)
+ end
+
+ # this example is use to test the design that the refs is not
+ # only represent the branch as well as the tags.
+ it 'ref switcher list all the branches and tags' do
+ find('.ref-selector').click
wait_for_requests
- find('li', text: ref).click
+ page.within('.ref-selector') do
+ expect(page).to have_selector('li', text: 'add-ipython-files')
+ expect(page).to have_selector('li', text: 'v1.0.0')
+ end
end
- expect(page).to have_selector('.results', text: 'path = gitlab-grack')
- end
- end
- end
+ it 'search result changes when refs switched' do
+ ref = 'master'
+ expect(find('.results')).not_to have_content('path = gitlab-grack')
- context 'when :new_header_search is false' do
- context 'search code within refs', :js do
- let(:ref_name) { 'v1.0.0' }
+ find('.ref-selector').click
+ wait_for_requests
- before do
- # This feature is diabled by default in spec_helper.rb.
- # We missed a feature breaking bug, so to prevent this regression, testing both scenarios for this spec.
- # This can be removed as part of closing https://gitlab.com/gitlab-org/gitlab/-/issues/339348.
- stub_feature_flags(new_header_search: false)
- visit(project_tree_path(project, ref_name))
-
- submit_search('gitlab-grack')
- select_search_scope('Code')
- end
+ page.within('.ref-selector') do
+ fill_in _('Search by Git revision'), with: ref
+ wait_for_requests
- it 'shows ref switcher in code result summary' do
- expect(find('.ref-selector')).to have_text(ref_name)
- end
+ find('li', text: ref).click
+ end
- it 'persists branch name across search' do
- find('.gl-search-box-by-click-search-button').click
- expect(find('.ref-selector')).to have_text(ref_name)
+ expect(page).to have_selector('.results', text: 'path = gitlab-grack')
+ end
end
+ end
- # this example is use to test the desgine that the refs is not
- # only repersent the branch as well as the tags.
- it 'ref swither list all the branchs and tags' do
- find('.ref-selector').click
- wait_for_requests
+ context 'when :new_header_search is false' do
+ context 'search code within refs' do
+ let(:ref_name) { 'v1.0.0' }
- page.within('.ref-selector') do
- expect(page).to have_selector('li', text: 'add-ipython-files')
- expect(page).to have_selector('li', text: 'v1.0.0')
+ before do
+ # This feature is disabled by default in spec_helper.rb.
+ # We missed a feature breaking bug, so to prevent this regression, testing both scenarios for this spec.
+ # This can be removed as part of closing https://gitlab.com/gitlab-org/gitlab/-/issues/339348.
+ stub_feature_flags(new_header_search: false)
+ visit(project_tree_path(project, ref_name))
+
+ submit_search('gitlab-grack')
+ select_search_scope('Code')
end
- end
- it 'search result changes when refs switched' do
- ref = 'master'
- expect(find('.results')).not_to have_content('path = gitlab-grack')
+ it 'shows ref switcher in code result summary' do
+ expect(find('.ref-selector')).to have_text(ref_name)
+ end
- find('.ref-selector').click
- wait_for_requests
+ it 'persists branch name across search' do
+ find('.gl-search-box-by-click-search-button').click
+ expect(find('.ref-selector')).to have_text(ref_name)
+ end
- page.within('.ref-selector') do
- fill_in _('Search by Git revision'), with: ref
+ # this example is use to test the design that the refs is not
+ # only represent the branch as well as the tags.
+ it 'ref switcher list all the branches and tags' do
+ find('.ref-selector').click
wait_for_requests
- find('li', text: ref).click
+ page.within('.ref-selector') do
+ expect(page).to have_selector('li', text: 'add-ipython-files')
+ expect(page).to have_selector('li', text: 'v1.0.0')
+ end
end
- expect(page).to have_selector('.results', text: 'path = gitlab-grack')
+ it 'search result changes when refs switched' do
+ ref = 'master'
+ expect(find('.results')).not_to have_content('path = gitlab-grack')
+
+ find('.ref-selector').click
+ wait_for_requests
+
+ page.within('.ref-selector') do
+ fill_in _('Search by Git revision'), with: ref
+ wait_for_requests
+
+ find('li', text: ref).click
+ end
+
+ expect(page).to have_selector('.results', text: 'path = gitlab-grack')
+ end
end
end
- end
- it 'no ref switcher shown in issue result summary', :js do
- issue = create(:issue, title: 'test', project: project)
- visit(project_tree_path(project))
+ it 'no ref switcher shown in issue result summary' do
+ issue = create(:issue, title: 'test', project: project)
+ visit(project_tree_path(project))
- submit_search('test')
- select_search_scope('Code')
+ submit_search('test')
+ select_search_scope('Code')
- expect(page).to have_selector('.ref-selector')
+ expect(page).to have_selector('.ref-selector')
- select_search_scope('Issues')
+ select_search_scope('Issues')
- expect(find(:css, '.results')).to have_link(issue.title)
- expect(page).not_to have_selector('.ref-selector')
+ expect(find(:css, '.results')).to have_link(issue.title)
+ expect(page).not_to have_selector('.ref-selector')
+ end
end
- end
- context 'when signed out' do
- let(:project) { create(:project, :public, :repository) }
-
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- visit(project_path(project))
- end
+ context 'when signed out' do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ end
- it 'finds code' do
- submit_search('rspec')
- select_search_scope('Code')
+ context 'when block_anonymous_global_searches is enabled' do
+ it 'is redirected to login page' do
+ visit(search_path)
- expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
+ expect(page).to have_content('You must be logged in to search across all of GitLab')
+ end
+ end
end
end
end
diff --git a/spec/features/search/user_searches_for_comments_spec.rb b/spec/features/search/user_searches_for_comments_spec.rb
index a6793bc3aa7..3c39e9f41d4 100644
--- a/spec/features/search/user_searches_for_comments_spec.rb
+++ b/spec/features/search/user_searches_for_comments_spec.rb
@@ -2,45 +2,52 @@
require 'spec_helper'
-RSpec.describe 'User searches for comments' do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+RSpec.describe 'User searches for comments', :js, :disable_rate_limiter do
+ using RSpec::Parameterized::TableSyntax
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- project.add_reporter(user)
- sign_in(user)
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
- visit(project_path(project))
- end
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ project.add_reporter(user)
+ sign_in(user)
- include_examples 'search timeouts', 'notes'
+ visit(project_path(project))
+ end
- context 'when a comment is in commits' do
- context 'when comment belongs to an invalid commit' do
- let(:comment) { create(:note_on_commit, author: user, project: project, commit_id: 12345678, note: 'Bug here') }
+ include_examples 'search timeouts', 'notes' do
+ let(:additional_params) { { project_id: project.id } }
+ end
- it 'finds a commit' do
- submit_search(comment.note)
- select_search_scope('Comments')
+ context 'when a comment is in commits' do
+ context 'when comment belongs to an invalid commit' do
+ let(:comment) { create(:note_on_commit, author: user, project: project, commit_id: 12345678, note: 'Bug here') }
- page.within('.results') do
- expect(page).to have_content('Commit deleted')
- expect(page).to have_content('12345678')
+ it 'finds a commit' do
+ submit_search(comment.note)
+ select_search_scope('Comments')
+
+ page.within('.results') do
+ expect(page).to have_content('Commit deleted')
+ expect(page).to have_content('12345678')
+ end
end
end
end
- end
- context 'when a comment is in a snippet' do
- let(:snippet) { create(:project_snippet, :private, project: project, author: user, title: 'Some title') }
- let(:comment) { create(:note, noteable: snippet, author: user, note: 'Supercalifragilisticexpialidocious', project: project) }
+ context 'when a comment is in a snippet' do
+ let(:snippet) { create(:project_snippet, :private, project: project, author: user, title: 'Some title') }
+ let(:comment) { create(:note, noteable: snippet, author: user, note: 'Supercalifragilisticexpialidocious', project: project) }
- it 'finds a snippet' do
- submit_search(comment.note)
- select_search_scope('Comments')
+ it 'finds a snippet' do
+ submit_search(comment.note)
+ select_search_scope('Comments')
- expect(page).to have_selector('.results', text: snippet.title)
+ expect(page).to have_selector('.results', text: snippet.title)
+ end
end
end
end
diff --git a/spec/features/search/user_searches_for_commits_spec.rb b/spec/features/search/user_searches_for_commits_spec.rb
index 4ec2a9e6cff..e5d86c27942 100644
--- a/spec/features/search/user_searches_for_commits_spec.rb
+++ b/spec/features/search/user_searches_for_commits_spec.rb
@@ -2,54 +2,62 @@
require 'spec_helper'
-RSpec.describe 'User searches for commits', :js do
+RSpec.describe 'User searches for commits', :js, :clean_gitlab_redis_rate_limiting do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+
let(:project) { create(:project, :repository) }
let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
- let(:user) { create(:user) }
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- project.add_reporter(user)
- sign_in(user)
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ project.add_reporter(user)
+ sign_in(user)
- visit(search_path(project_id: project.id))
- end
+ visit(search_path(project_id: project.id))
+ end
- include_examples 'search timeouts', 'commits'
+ include_examples 'search timeouts', 'commits' do
+ let(:additional_params) { { project_id: project.id } }
+ end
- context 'when searching by SHA' do
- it 'finds a commit and redirects to its page' do
- submit_search(sha)
+ context 'when searching by SHA' do
+ it 'finds a commit and redirects to its page' do
+ submit_search(sha)
- expect(page).to have_current_path(project_commit_path(project, sha))
- end
+ expect(page).to have_current_path(project_commit_path(project, sha))
+ end
- it 'finds a commit in uppercase and redirects to its page' do
- submit_search(sha.upcase)
+ it 'finds a commit in uppercase and redirects to its page' do
+ submit_search(sha.upcase)
- expect(page).to have_current_path(project_commit_path(project, sha))
+ expect(page).to have_current_path(project_commit_path(project, sha))
+ end
end
- end
- context 'when searching by message' do
- it 'finds a commit and holds on /search page' do
- project.repository.commit_files(
- user,
- message: 'Message referencing another sha: "deadbeef"',
- branch_name: 'master',
- actions: [{ action: :create, file_path: 'a/new.file', contents: 'new file' }]
- )
+ context 'when searching by message' do
+ it 'finds a commit and holds on /search page' do
+ project.repository.commit_files(
+ user,
+ message: 'Message referencing another sha: "deadbeef"',
+ branch_name: 'master',
+ actions: [{ action: :create, file_path: 'a/new.file', contents: 'new file' }]
+ )
- submit_search('deadbeef')
+ submit_search('deadbeef')
- expect(page).to have_current_path('/search', ignore_query: true)
- end
+ expect(page).to have_current_path('/search', ignore_query: true)
+ end
- it 'finds multiple commits' do
- submit_search('See merge request')
- select_search_scope('Commits')
+ it 'finds multiple commits' do
+ submit_search('See merge request')
+ select_search_scope('Commits')
- expect(page).to have_selector('.commit-row-description', visible: false, count: 9)
+ expect(page).to have_selector('.commit-row-description', visible: false, count: 9)
+ end
end
end
end
diff --git a/spec/features/search/user_searches_for_issues_spec.rb b/spec/features/search/user_searches_for_issues_spec.rb
index 51d2f355848..22d48bd38f2 100644
--- a/spec/features/search/user_searches_for_issues_spec.rb
+++ b/spec/features/search/user_searches_for_issues_spec.rb
@@ -2,9 +2,12 @@
require 'spec_helper'
-RSpec.describe 'User searches for issues', :js do
- let(:user) { create(:user) }
- let(:project) { create(:project, namespace: user.namespace) }
+RSpec.describe 'User searches for issues', :js, :clean_gitlab_redis_rate_limiting do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, namespace: user.namespace) }
+
let!(:issue1) { create(:issue, title: 'issue Foo', project: project, created_at: 1.hour.ago) }
let!(:issue2) { create(:issue, :closed, :confidential, title: 'issue Bar', project: project) }
@@ -14,127 +17,133 @@ RSpec.describe 'User searches for issues', :js do
select_search_scope('Issues')
end
- context 'when signed in' do
- before do
- project.add_maintainer(user)
- sign_in(user)
- stub_feature_flags(search_page_vertical_nav: false)
-
- visit(search_path)
- end
+ where(search_page_vertical_nav_enabled: [true, false])
- include_examples 'top right search form'
- include_examples 'search timeouts', 'issues'
+ with_them do
+ context 'when signed in' do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
- it 'finds an issue' do
- search_for_issue(issue1.title)
+ project.add_maintainer(user)
+ sign_in(user)
- page.within('.results') do
- expect(page).to have_link(issue1.title)
- expect(page).not_to have_link(issue2.title)
+ visit(search_path)
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
+ include_examples 'top right search form'
+ include_examples 'search timeouts', 'issues'
- it 'shows confidential icon for confidential issues' do
- search_for_issue(issue2.title)
+ it 'finds an issue' do
+ search_for_issue(issue1.title)
- page.within('.results') do
- expect(page).to have_css('[data-testid="eye-slash-icon"]')
+ page.within('.results') do
+ expect(page).to have_link(issue1.title)
+ expect(page).not_to have_link(issue2.title)
+ end
end
- end
- it 'shows correct badge for open issues' do
- search_for_issue(issue1.title)
+ it 'hides confidential icon for non-confidential 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')
+ page.within('.results') do
+ expect(page).not_to have_css('[data-testid="eye-slash-icon"]')
+ end
end
- end
- it 'shows correct badge for closed issues' do
- search_for_issue(issue2.title)
+ it 'shows confidential icon for confidential 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')
+ page.within('.results') do
+ expect(page).to have_css('[data-testid="eye-slash-icon"]')
+ end
end
- end
- it 'sorts by created date' do
- search_for_issue('issue')
+ it 'shows correct badge for open issues' do
+ search_for_issue(issue1.title)
- page.within('.results') do
- expect(page.all('.search-result-row').first).to have_link(issue2.title)
- expect(page.all('.search-result-row').last).to have_link(issue1.title)
+ page.within('.results') do
+ expect(page).to have_css('.badge-success')
+ expect(page).not_to have_css('.badge-info')
+ end
end
- find('[data-testid="sort-highest-icon"]').click
+ it 'shows correct badge for closed issues' do
+ search_for_issue(issue2.title)
- page.within('.results') do
- expect(page.all('.search-result-row').first).to have_link(issue1.title)
- expect(page.all('.search-result-row').last).to have_link(issue2.title)
+ page.within('.results') do
+ expect(page).not_to have_css('.badge-success')
+ expect(page).to have_css('.badge-info')
+ end
end
- end
-
- context 'when on a project page' do
- it 'finds an issue' do
- find('[data-testid="project-filter"]').click
- wait_for_requests
+ it 'sorts by created date' do
+ search_for_issue('issue')
- page.within('[data-testid="project-filter"]') do
- click_on(project.name)
+ page.within('.results') do
+ expect(page.all('.search-result-row').first).to have_link(issue2.title)
+ expect(page.all('.search-result-row').last).to have_link(issue1.title)
end
- search_for_issue(issue1.title)
+ find('[data-testid="sort-highest-icon"]').click
page.within('.results') do
- expect(page).to have_link(issue1.title)
- expect(page).not_to have_link(issue2.title)
+ expect(page.all('.search-result-row').first).to have_link(issue1.title)
+ expect(page.all('.search-result-row').last).to have_link(issue2.title)
end
end
- end
- end
- context 'when signed out' do
- context 'when block_anonymous_global_searches is disabled' do
- let(:project) { create(:project, :public) }
+ context 'when on a project page' do
+ it 'finds an issue' do
+ find('[data-testid="project-filter"]').click
- before do
- stub_feature_flags(block_anonymous_global_searches: false)
- stub_feature_flags(search_page_vertical_nav: false)
- visit(search_path)
- end
+ wait_for_requests
- include_examples 'top right search form'
+ page.within('[data-testid="project-filter"]') do
+ click_on(project.name)
+ end
- it 'finds an issue' do
- search_for_issue(issue1.title)
+ 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
end
- context 'when block_anonymous_global_searches is enabled' do
+ context 'when signed out' do
before do
- stub_feature_flags(search_page_vertical_nav: false)
- visit(search_path)
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
end
- it 'is redirected to login page' do
- expect(page).to have_content('You must be logged in to search across all of GitLab')
+ context 'when block_anonymous_global_searches is disabled' do
+ let_it_be(:project) { create(:project, :public) }
+
+ before do
+ stub_feature_flags(block_anonymous_global_searches: false)
+
+ visit(search_path)
+ end
+
+ include_examples 'top right search form'
+
+ 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)
+ end
+ end
+ end
+
+ 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_searches_for_merge_requests_spec.rb b/spec/features/search/user_searches_for_merge_requests_spec.rb
index a4fbe3a6e59..9bbf2cf16d8 100644
--- a/spec/features/search/user_searches_for_merge_requests_spec.rb
+++ b/spec/features/search/user_searches_for_merge_requests_spec.rb
@@ -2,7 +2,9 @@
require 'spec_helper'
-RSpec.describe 'User searches for merge requests', :js do
+RSpec.describe 'User searches for merge requests', :js, :clean_gitlab_redis_rate_limiting do
+ using RSpec::Parameterized::TableSyntax
+
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let!(:merge_request1) { create(:merge_request, title: 'Merge Request Foo', source_project: project, target_project: project, created_at: 1.hour.ago) }
@@ -14,62 +16,64 @@ RSpec.describe 'User searches for merge requests', :js do
select_search_scope('Merge requests')
end
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- project.add_maintainer(user)
- sign_in(user)
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ sign_in(user)
- visit(search_path)
- end
+ visit(search_path)
+ end
- include_examples 'top right search form'
- include_examples 'search timeouts', 'merge_requests'
+ include_examples 'top right search form'
+ include_examples 'search timeouts', 'merge_requests'
- it 'finds a merge request' do
- search_for_mr(merge_request1.title)
+ it 'finds a merge request' do
+ search_for_mr(merge_request1.title)
- page.within('.results') do
- expect(page).to have_link(merge_request1.title)
- expect(page).not_to have_link(merge_request2.title)
+ page.within('.results') do
+ expect(page).to have_link(merge_request1.title)
+ expect(page).not_to have_link(merge_request2.title)
- # Each result should have MR refs like `gitlab-org/gitlab!1`
- page.all('.search-result-row').each do |e|
- expect(e.text).to match(/!\d+/)
+ # Each result should have MR refs like `gitlab-org/gitlab!1`
+ page.all('.search-result-row').each do |e|
+ expect(e.text).to match(/!\d+/)
+ end
end
end
- end
- it 'sorts by created date' do
- search_for_mr('Merge Request')
+ it 'sorts by created date' do
+ search_for_mr('Merge Request')
- page.within('.results') do
- expect(page.all('.search-result-row').first).to have_link(merge_request2.title)
- expect(page.all('.search-result-row').last).to have_link(merge_request1.title)
- end
+ page.within('.results') do
+ expect(page.all('.search-result-row').first).to have_link(merge_request2.title)
+ expect(page.all('.search-result-row').last).to have_link(merge_request1.title)
+ end
- find('[data-testid="sort-highest-icon"]').click
+ find('[data-testid="sort-highest-icon"]').click
- page.within('.results') do
- expect(page.all('.search-result-row').first).to have_link(merge_request1.title)
- expect(page.all('.search-result-row').last).to have_link(merge_request2.title)
+ page.within('.results') do
+ expect(page.all('.search-result-row').first).to have_link(merge_request1.title)
+ expect(page.all('.search-result-row').last).to have_link(merge_request2.title)
+ end
end
- end
- context 'when on a project page' do
- it 'finds a merge request' do
- find('[data-testid="project-filter"]').click
+ context 'when on a project page' do
+ it 'finds a merge request' do
+ find('[data-testid="project-filter"]').click
- wait_for_requests
+ wait_for_requests
- page.within('[data-testid="project-filter"]') do
- click_on(project.name)
- end
+ page.within('[data-testid="project-filter"]') do
+ click_on(project.name)
+ end
- search_for_mr(merge_request1.title)
+ search_for_mr(merge_request1.title)
- page.within('.results') do
- expect(page).to have_link(merge_request1.title)
- expect(page).not_to have_link(merge_request2.title)
+ page.within('.results') do
+ expect(page).to have_link(merge_request1.title)
+ expect(page).not_to have_link(merge_request2.title)
+ end
end
end
end
diff --git a/spec/features/search/user_searches_for_milestones_spec.rb b/spec/features/search/user_searches_for_milestones_spec.rb
index 6773059830c..702d4e60022 100644
--- a/spec/features/search/user_searches_for_milestones_spec.rb
+++ b/spec/features/search/user_searches_for_milestones_spec.rb
@@ -2,44 +2,30 @@
require 'spec_helper'
-RSpec.describe 'User searches for milestones', :js do
- let(:user) { create(:user) }
- let(:project) { create(:project, namespace: user.namespace) }
- let!(:milestone1) { create(:milestone, title: 'Foo', project: project) }
- let!(:milestone2) { create(:milestone, title: 'Bar', project: project) }
+RSpec.describe 'User searches for milestones', :js, :clean_gitlab_redis_rate_limiting do
+ using RSpec::Parameterized::TableSyntax
- before do
- project.add_maintainer(user)
- sign_in(user)
- stub_feature_flags(search_page_vertical_nav: false)
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, namespace: user.namespace) }
- visit(search_path)
- end
+ let!(:milestone1) { create(:milestone, title: 'Foo', project: project) }
+ let!(:milestone2) { create(:milestone, title: 'Bar', project: project) }
- include_examples 'top right search form'
- include_examples 'search timeouts', 'milestones'
+ where(search_page_vertical_nav_enabled: [true, false])
- it 'finds a milestone' do
- fill_in('dashboard_search', with: milestone1.title)
- find('.gl-search-box-by-click-search-button').click
- select_search_scope('Milestones')
+ with_them do
+ before do
+ project.add_maintainer(user)
+ sign_in(user)
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
- page.within('.results') do
- expect(page).to have_link(milestone1.title)
- expect(page).not_to have_link(milestone2.title)
+ visit(search_path)
end
- end
-
- context 'when on a project page' do
- it 'finds a milestone' do
- find('[data-testid="project-filter"]').click
-
- wait_for_requests
- page.within('[data-testid="project-filter"]') do
- click_on(project.name)
- end
+ include_examples 'top right search form'
+ include_examples 'search timeouts', 'milestones'
+ it 'finds a milestone' do
fill_in('dashboard_search', with: milestone1.title)
find('.gl-search-box-by-click-search-button').click
select_search_scope('Milestones')
@@ -49,5 +35,26 @@ RSpec.describe 'User searches for milestones', :js do
expect(page).not_to have_link(milestone2.title)
end
end
+
+ context 'when on a project page' do
+ it 'finds a milestone' do
+ find('[data-testid="project-filter"]').click
+
+ wait_for_requests
+
+ page.within('[data-testid="project-filter"]') do
+ click_on(project.name)
+ end
+
+ fill_in('dashboard_search', with: milestone1.title)
+ find('.gl-search-box-by-click-search-button').click
+ select_search_scope('Milestones')
+
+ page.within('.results') do
+ expect(page).to have_link(milestone1.title)
+ expect(page).not_to have_link(milestone2.title)
+ end
+ end
+ 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 5902859d1f5..15c6224b61b 100644
--- a/spec/features/search/user_searches_for_projects_spec.rb
+++ b/spec/features/search/user_searches_for_projects_spec.rb
@@ -2,15 +2,12 @@
require 'spec_helper'
-RSpec.describe 'User searches for projects', :js do
+RSpec.describe 'User searches for projects', :js, :disable_rate_limiter do
let!(:project) { create(:project, :public, name: 'Shop') }
context 'when signed out' do
context 'when block_anonymous_global_searches is disabled' do
before do
- stub_feature_flags(search_page_vertical_nav: false)
- allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit).and_return(1000)
- allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit_unauthenticated).and_return(1000)
stub_feature_flags(block_anonymous_global_searches: false)
end
diff --git a/spec/features/search/user_searches_for_users_spec.rb b/spec/features/search/user_searches_for_users_spec.rb
index e21a66fed92..1d649b42c8c 100644
--- a/spec/features/search/user_searches_for_users_spec.rb
+++ b/spec/features/search/user_searches_for_users_spec.rb
@@ -2,84 +2,90 @@
require 'spec_helper'
-RSpec.describe 'User searches for users' do
- let(:user1) { create(:user, username: 'gob_bluth', name: 'Gob Bluth') }
- let(:user2) { create(:user, username: 'michael_bluth', name: 'Michael Bluth') }
- let(:user3) { create(:user, username: 'gob_2018', name: 'George Oscar Bluth') }
-
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- sign_in(user1)
- end
-
- include_examples 'search timeouts', 'users'
+RSpec.describe 'User searches for users', :js, :clean_gitlab_redis_rate_limiting do
+ let_it_be(:user1) { create(:user, username: 'gob_bluth', name: 'Gob Bluth') }
+ let_it_be(:user2) { create(:user, username: 'michael_bluth', name: 'Michael Bluth') }
+ let_it_be(:user3) { create(:user, username: 'gob_2018', name: 'George Oscar Bluth') }
- context 'when on the dashboard' do
- it 'finds the user', :js do
- visit dashboard_projects_path
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
- submit_search('gob')
- select_search_scope('Users')
+ sign_in(user1)
+ end
- page.within('.results') do
- expect(page).to have_content('Gob Bluth')
- expect(page).to have_content('@gob_bluth')
+ include_examples 'search timeouts', 'users' do
+ before do
+ visit(search_path)
end
end
- end
- context 'when on the project page' do
- let(:project) { create(:project) }
+ context 'when on the dashboard' do
+ it 'finds the user' do
+ visit dashboard_projects_path
- before do
- create(:project_member, :developer, user: user1, project: project)
- create(:project_member, :developer, user: user2, project: project)
- user3
+ submit_search('gob')
+ select_search_scope('Users')
+
+ page.within('.results') do
+ expect(page).to have_content('Gob Bluth')
+ expect(page).to have_content('@gob_bluth')
+ end
+ end
end
- it 'finds the user belonging to the project' do
- visit project_path(project)
+ context 'when on the project page' do
+ let_it_be_with_reload(:project) { create(:project) }
- submit_search('gob')
- select_search_scope('Users')
+ before do
+ project.add_developer(user1)
+ project.add_developer(user2)
+ end
+
+ it 'finds the user belonging to the project' do
+ visit project_path(project)
- page.within('.results') do
- expect(page).to have_content('Gob Bluth')
- expect(page).to have_content('@gob_bluth')
+ submit_search('gob')
+ select_search_scope('Users')
- expect(page).not_to have_content('Michael Bluth')
- expect(page).not_to have_content('@michael_bluth')
+ page.within('.results') do
+ expect(page).to have_content('Gob Bluth')
+ expect(page).to have_content('@gob_bluth')
- expect(page).not_to have_content('George Oscar Bluth')
- expect(page).not_to have_content('@gob_2018')
+ expect(page).not_to have_content('Michael Bluth')
+ expect(page).not_to have_content('@michael_bluth')
+
+ expect(page).not_to have_content('George Oscar Bluth')
+ expect(page).not_to have_content('@gob_2018')
+ end
end
end
- end
- context 'when on the group page' do
- let(:group) { create(:group) }
+ context 'when on the group page' do
+ let(:group) { create(:group) }
- before do
- create(:group_member, :developer, user: user1, group: group)
- create(:group_member, :developer, user: user2, group: group)
- user3
- end
+ before do
+ group.add_developer(user1)
+ group.add_developer(user2)
+ end
- it 'finds the user belonging to the group' do
- visit group_path(group)
+ it 'finds the user belonging to the group' do
+ visit group_path(group)
- submit_search('gob')
- select_search_scope('Users')
+ submit_search('gob')
+ select_search_scope('Users')
- page.within('.results') do
- expect(page).to have_content('Gob Bluth')
- expect(page).to have_content('@gob_bluth')
+ page.within('.results') do
+ expect(page).to have_content('Gob Bluth')
+ expect(page).to have_content('@gob_bluth')
- expect(page).not_to have_content('Michael Bluth')
- expect(page).not_to have_content('@michael_bluth')
+ expect(page).not_to have_content('Michael Bluth')
+ expect(page).not_to have_content('@michael_bluth')
- expect(page).not_to have_content('George Oscar Bluth')
- expect(page).not_to have_content('@gob_2018')
+ expect(page).not_to have_content('George Oscar Bluth')
+ expect(page).not_to have_content('@gob_2018')
+ end
end
end
end
diff --git a/spec/features/search/user_searches_for_wiki_pages_spec.rb b/spec/features/search/user_searches_for_wiki_pages_spec.rb
index 2e390309022..0f20ad0aa07 100644
--- a/spec/features/search/user_searches_for_wiki_pages_spec.rb
+++ b/spec/features/search/user_searches_for_wiki_pages_spec.rb
@@ -2,55 +2,59 @@
require 'spec_helper'
-RSpec.describe 'User searches for wiki pages', :js do
- let(:user) { create(:user) }
+RSpec.describe 'User searches for wiki pages', :js, :clean_gitlab_redis_rate_limiting do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+
let(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
let!(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'directory/title', content: 'Some Wiki content') }
- before do
- stub_feature_flags(search_page_vertical_nav: false)
- project.add_maintainer(user)
- sign_in(user)
-
- visit(search_path)
- end
+ where(search_page_vertical_nav_enabled: [true, false])
+ with_them do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ project.add_maintainer(user)
+ sign_in(user)
- include_examples 'top right search form'
- include_examples 'search timeouts', 'wiki_blobs'
+ visit(search_path)
+ end
- shared_examples 'search wiki blobs' do
- before do
- stub_feature_flags(search_page_vertical_nav: false)
+ include_examples 'top right search form'
+ include_examples 'search timeouts', 'wiki_blobs' do
+ let(:additional_params) { { project_id: project.id } }
end
- it 'finds a page' do
- find('[data-testid="project-filter"]').click
+ shared_examples 'search wiki blobs' do
+ it 'finds a page' do
+ find('[data-testid="project-filter"]').click
- wait_for_requests
+ wait_for_requests
- page.within('[data-testid="project-filter"]') do
- click_on(project.name)
- end
+ page.within('[data-testid="project-filter"]') do
+ click_on(project.name)
+ end
- fill_in('dashboard_search', with: search_term)
- find('.gl-search-box-by-click-search-button').click
- select_search_scope('Wiki')
+ fill_in('dashboard_search', with: search_term)
+ find('.gl-search-box-by-click-search-button').click
+ select_search_scope('Wiki')
- page.within('.results') do
- expect(page).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
+ page.within('.results') do
+ expect(page).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
+ end
end
end
- end
- context 'when searching by content' do
- it_behaves_like 'search wiki blobs' do
- let(:search_term) { 'content' }
+ context 'when searching by content' do
+ it_behaves_like 'search wiki blobs' do
+ let(:search_term) { 'content' }
+ end
end
- end
- context 'when searching by title' do
- it_behaves_like 'search wiki blobs' do
- let(:search_term) { 'title' }
+ context 'when searching by title' do
+ it_behaves_like 'search wiki blobs' do
+ let(:search_term) { 'title' }
+ 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 827e3984896..04f22cd2a31 100644
--- a/spec/features/search/user_uses_header_search_field_spec.rb
+++ b/spec/features/search/user_uses_header_search_field_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'User uses header search field', :js do
+RSpec.describe 'User uses header search field', :js, :disable_rate_limiter do
include FilteredSearchHelpers
let_it_be(:project) { create(:project, :repository) }
@@ -17,10 +17,6 @@ RSpec.describe 'User uses header search field', :js do
end
before do
- stub_feature_flags(search_page_vertical_nav: false)
- allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).and_return(0)
- allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit).and_return(1000)
- allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit_unauthenticated).and_return(1000)
sign_in(user)
end