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:
Diffstat (limited to 'spec/features/search')
-rw-r--r--spec/features/search/user_searches_for_code_spec.rb57
-rw-r--r--spec/features/search/user_searches_for_comments_spec.rb24
-rw-r--r--spec/features/search/user_searches_for_commits_spec.rb14
-rw-r--r--spec/features/search/user_searches_for_issues_spec.rb24
-rw-r--r--spec/features/search/user_searches_for_merge_requests_spec.rb16
-rw-r--r--spec/features/search/user_searches_for_milestones_spec.rb16
-rw-r--r--spec/features/search/user_searches_for_projects_spec.rb6
-rw-r--r--spec/features/search/user_searches_for_users_spec.rb92
-rw-r--r--spec/features/search/user_searches_for_wiki_pages_spec.rb7
-rw-r--r--spec/features/search/user_uses_header_search_field_spec.rb6
10 files changed, 108 insertions, 154 deletions
diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb
index 4ca79ccaea8..9451ee6eb15 100644
--- a/spec/features/search/user_searches_for_code_spec.rb
+++ b/spec/features/search/user_searches_for_code_spec.rb
@@ -6,21 +6,6 @@ describe 'User searches for code' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
- def submit_search(search, with_send_keys: false)
- page.within('.search') do
- field = find_field('search')
- field.fill_in(with: search)
-
- if with_send_keys
- field.send_keys(:enter)
- else
- click_button("Go")
- end
- end
-
- click_link('Code')
- end
-
context 'when signed in' do
before do
project.add_maintainer(user)
@@ -31,7 +16,9 @@ describe 'User searches for code' do
visit(project_path(project))
submit_search('application.js')
+ select_search_scope('Code')
+ 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']")
end
@@ -52,9 +39,7 @@ describe 'User searches for code' do
fill_in('dashboard_search', with: 'rspec')
find('.btn-search').click
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
- end
+ expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
end
it 'search mutiple words with refs switching' do
@@ -64,16 +49,12 @@ describe 'User searches for code' do
fill_in('dashboard_search', with: search)
find('.btn-search').click
- page.within('.results') do
- expect(find('.search-results')).to have_content(expected_result)
- end
+ expect(page).to have_selector('.results', text: expected_result)
find('.js-project-refs-dropdown').click
find('.dropdown-page-one .dropdown-content').click_link('v1.0.0')
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_content(expected_result)
- end
+ expect(page).to have_selector('.results', text: expected_result)
expect(find_field('dashboard_search').value).to eq(search)
end
@@ -84,7 +65,9 @@ describe 'User searches for code' do
before do
visit(project_tree_path(project, ref_name))
- submit_search('gitlab-grack', with_send_keys: true)
+
+ submit_search('gitlab-grack')
+ select_search_scope('Code')
end
it 'shows ref switcher in code result summary' do
@@ -104,22 +87,27 @@ describe 'User searches for code' do
end
it 'search result changes when refs switched' do
- expect(find('.search-results')).not_to have_content('path = gitlab-grack')
+ expect(find('.results')).not_to have_content('path = gitlab-grack')
+
find('.js-project-refs-dropdown').click
find('.dropdown-page-one .dropdown-content').click_link('master')
- expect(find('.search-results')).to have_content('path = gitlab-grack')
+
+ expect(page).to have_selector('.results', text: 'path = gitlab-grack')
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))
- submit_search('test', with_send_keys: true)
+
+ submit_search('test')
+ select_search_scope('Code')
+
expect(page).to have_selector('.js-project-refs-dropdown')
- page.within('.search-filter') do
- click_link('Issues')
- end
- expect(find(:css, '.search-results')).to have_link(issue.title)
+
+ select_search_scope('Issues')
+
+ expect(find(:css, '.results')).to have_link(issue.title)
expect(page).not_to have_selector('.js-project-refs-dropdown')
end
end
@@ -133,10 +121,9 @@ describe 'User searches for code' do
it 'finds code' do
submit_search('rspec')
+ select_search_scope('Code')
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
- end
+ expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
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 2ce3fa4735f..0a203a5bf2d 100644
--- a/spec/features/search/user_searches_for_comments_spec.rb
+++ b/spec/features/search/user_searches_for_comments_spec.rb
@@ -18,15 +18,13 @@ describe 'User searches for comments' do
let(:comment) { create(:note_on_commit, author: user, project: project, commit_id: 12345678, note: 'Bug here') }
it 'finds a commit' do
- page.within('.search') do
- fill_in('search', with: comment.note)
- click_button('Go')
- end
-
- click_link('Comments')
+ submit_search(comment.note)
+ select_search_scope('Comments')
- expect(page).to have_text('Commit deleted')
- expect(page).to have_text('12345678')
+ page.within('.results') do
+ expect(page).to have_content('Commit deleted')
+ expect(page).to have_content('12345678')
+ end
end
end
end
@@ -36,14 +34,10 @@ describe 'User searches for comments' do
let(:comment) { create(:note, noteable: snippet, author: user, note: 'Supercalifragilisticexpialidocious', project: project) }
it 'finds a snippet' do
- page.within('.search') do
- fill_in('search', with: comment.note)
- click_button('Go')
- end
-
- click_link('Comments')
+ submit_search(comment.note)
+ select_search_scope('Comments')
- expect(page).to have_link(snippet.title)
+ expect(page).to have_selector('.results', text: snippet.title)
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 81c299752ea..958f12d3b84 100644
--- a/spec/features/search/user_searches_for_commits_spec.rb
+++ b/spec/features/search/user_searches_for_commits_spec.rb
@@ -16,15 +16,13 @@ describe 'User searches for commits' do
context 'when searching by SHA' do
it 'finds a commit and redirects to its page' do
- fill_in('search', with: sha)
- click_button('Search')
+ submit_search(sha)
expect(page).to have_current_path(project_commit_path(project, sha))
end
it 'finds a commit in uppercase and redirects to its page' do
- fill_in('search', with: sha.upcase)
- click_button('Search')
+ submit_search(sha.upcase)
expect(page).to have_current_path(project_commit_path(project, sha))
end
@@ -34,16 +32,14 @@ describe 'User searches for commits' do
it 'finds a commit and holds on /search page' do
create_commit('Message referencing another sha: "deadbeef"', project, user, 'master')
- fill_in('search', with: 'deadbeef')
- click_button('Search')
+ submit_search('deadbeef')
expect(page).to have_current_path('/search', ignore_query: true)
end
it 'finds multiple commits' do
- fill_in('search', with: 'See merge request')
- click_button('Search')
- click_link('Commits')
+ submit_search('See merge request')
+ select_search_scope('Commits')
expect(page).to have_selector('.commit-row-description', count: 9)
end
diff --git a/spec/features/search/user_searches_for_issues_spec.rb b/spec/features/search/user_searches_for_issues_spec.rb
index f0fcf6df70c..ae718cec7af 100644
--- a/spec/features/search/user_searches_for_issues_spec.rb
+++ b/spec/features/search/user_searches_for_issues_spec.rb
@@ -21,13 +21,11 @@ describe 'User searches for issues', :js do
it 'finds an issue' do
fill_in('dashboard_search', with: issue1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Issues')
- end
+ select_search_scope('Issues')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ expect(page).to have_link(issue1.title)
+ expect(page).not_to have_link(issue2.title)
end
end
@@ -41,13 +39,11 @@ describe 'User searches for issues', :js do
fill_in('dashboard_search', with: issue1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Issues')
- end
+ select_search_scope('Issues')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ expect(page).to have_link(issue1.title)
+ expect(page).not_to have_link(issue2.title)
end
end
end
@@ -65,13 +61,11 @@ describe 'User searches for issues', :js do
it 'finds an issue' do
fill_in('dashboard_search', with: issue1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Issues')
- end
+ select_search_scope('Issues')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ expect(page).to have_link(issue1.title)
+ expect(page).not_to have_link(issue2.title)
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 d005b87cdfe..0139ac26816 100644
--- a/spec/features/search/user_searches_for_merge_requests_spec.rb
+++ b/spec/features/search/user_searches_for_merge_requests_spec.rb
@@ -20,13 +20,11 @@ describe 'User searches for merge requests', :js do
it 'finds a merge request' do
fill_in('dashboard_search', with: merge_request1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Merge requests')
- end
+ select_search_scope('Merge requests')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
+ expect(page).to have_link(merge_request1.title)
+ expect(page).not_to have_link(merge_request2.title)
end
end
@@ -40,13 +38,11 @@ describe 'User searches for merge requests', :js do
fill_in('dashboard_search', with: merge_request1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Merge requests')
- end
+ select_search_scope('Merge requests')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
+ expect(page).to have_link(merge_request1.title)
+ expect(page).not_to have_link(merge_request2.title)
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 00964ab4f1d..0714cfcc309 100644
--- a/spec/features/search/user_searches_for_milestones_spec.rb
+++ b/spec/features/search/user_searches_for_milestones_spec.rb
@@ -20,13 +20,11 @@ describe 'User searches for milestones', :js do
it 'finds a milestone' do
fill_in('dashboard_search', with: milestone1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Milestones')
- end
+ select_search_scope('Milestones')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(milestone1.title).and have_no_link(milestone2.title)
+ expect(page).to have_link(milestone1.title)
+ expect(page).not_to have_link(milestone2.title)
end
end
@@ -40,13 +38,11 @@ describe 'User searches for milestones', :js do
fill_in('dashboard_search', with: milestone1.title)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Milestones')
- end
+ select_search_scope('Milestones')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(milestone1.title).and have_no_link(milestone2.title)
+ expect(page).to have_link(milestone1.title)
+ expect(page).not_to have_link(milestone2.title)
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 082c1ae8e4a..b194ac32ff6 100644
--- a/spec/features/search/user_searches_for_projects_spec.rb
+++ b/spec/features/search/user_searches_for_projects_spec.rb
@@ -20,8 +20,7 @@ describe 'User searches for projects' do
it 'preserves the group being searched in' do
visit(search_path(group_id: project.namespace.id))
- fill_in('search', with: 'foo')
- click_button('Search')
+ submit_search('foo')
expect(find('#group_id', visible: false).value).to eq(project.namespace.id.to_s)
end
@@ -29,8 +28,7 @@ describe 'User searches for projects' do
it 'preserves the project being searched in' do
visit(search_path(project_id: project.id))
- fill_in('search', with: 'foo')
- click_button('Search')
+ submit_search('foo')
expect(find('#project_id', visible: false).value).to eq(project.id.to_s)
end
diff --git a/spec/features/search/user_searches_for_users_spec.rb b/spec/features/search/user_searches_for_users_spec.rb
index e10c1afc0b8..6f2c5d48018 100644
--- a/spec/features/search/user_searches_for_users_spec.rb
+++ b/spec/features/search/user_searches_for_users_spec.rb
@@ -3,83 +3,81 @@
require 'spec_helper'
describe 'User searches for users' do
- context 'when on the dashboard' do
- it 'finds the user', :js do
- create(:user, username: 'gob_bluth', name: 'Gob Bluth')
+ 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') }
- sign_in(create(:user))
+ before do
+ sign_in(user1)
+ end
+ context 'when on the dashboard' do
+ it 'finds the user', :js do
visit dashboard_projects_path
- fill_in 'search', with: 'gob'
- find('#search').send_keys(:enter)
+ submit_search('gob')
+ select_search_scope('Users')
- expect(page).to have_content('Users 1')
-
- click_on('Users 1')
-
- 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')
+ end
end
end
context 'when on the project page' do
- it 'finds the user belonging to the project' do
- project = create(:project)
+ let(:project) { create(:project) }
- user1 = create(:user, username: 'gob_bluth', name: 'Gob Bluth')
+ before do
create(:project_member, :developer, user: user1, project: project)
-
- user2 = create(:user, username: 'michael_bluth', name: 'Michael Bluth')
create(:project_member, :developer, user: user2, project: project)
+ user3
+ end
- create(:user, username: 'gob_2018', name: 'George Oscar Bluth')
-
- sign_in(user1)
-
- visit projects_path(project)
+ it 'finds the user belonging to the project' do
+ visit project_path(project)
- fill_in 'search', with: 'gob'
- click_button 'Go'
+ submit_search('gob')
+ select_search_scope('Users')
- 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
context 'when on the group page' do
- it 'finds the user belonging to the group' do
- group = create(:group)
+ let(:group) { create(:group) }
- user1 = create(:user, username: 'gob_bluth', name: 'Gob Bluth')
+ before do
create(:group_member, :developer, user: user1, group: group)
-
- user2 = create(:user, username: 'michael_bluth', name: 'Michael Bluth')
create(:group_member, :developer, user: user2, group: group)
+ user3
+ end
- create(:user, username: 'gob_2018', name: 'George Oscar Bluth')
-
- sign_in(user1)
-
+ it 'finds the user belonging to the group' do
visit group_path(group)
- fill_in 'search', with: 'gob'
- click_button 'Go'
+ submit_search('gob')
+ select_search_scope('Users')
- 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 0a5abfbf46a..1ae37447bdc 100644
--- a/spec/features/search/user_searches_for_wiki_pages_spec.rb
+++ b/spec/features/search/user_searches_for_wiki_pages_spec.rb
@@ -26,13 +26,10 @@ describe 'User searches for wiki pages', :js do
fill_in('dashboard_search', with: search_term)
find('.btn-search').click
-
- page.within('.search-filter') do
- click_link('Wiki')
- end
+ select_search_scope('Wiki')
page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
+ expect(page).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
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 5006631cc14..7e7c09e4a13 100644
--- a/spec/features/search/user_uses_header_search_field_spec.rb
+++ b/spec/features/search/user_uses_header_search_field_spec.rb
@@ -19,8 +19,7 @@ describe 'User uses header search field', :js do
end
it 'starts searching by pressing the enter key' do
- fill_in('search', with: 'gitlab')
- find('#search').native.send_keys(:enter)
+ submit_search('gitlab')
page.within('.page-title') do
expect(page).to have_content('Search')
@@ -101,8 +100,7 @@ describe 'User uses header search field', :js do
before do
create(:issue, project: project, title: 'project issue')
- fill_in('search', with: 'project')
- find('#search').send_keys(:enter)
+ submit_search('project')
end
it 'displays result counts for all categories' do