2012-05-27 06:22:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-12 04:56:37 -04:00
|
|
|
describe "Search", feature: true do
|
2017-01-30 17:53:18 -05:00
|
|
|
include FilteredSearchHelpers
|
2016-09-09 07:08:49 -04:00
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:empty_project, namespace: user.namespace) }
|
2017-05-04 08:11:15 -04:00
|
|
|
let!(:issue) { create(:issue, project: project, assignees: [user]) }
|
2016-06-24 12:45:55 -04:00
|
|
|
let!(:issue2) { create(:issue, project: project, author: user) }
|
2016-03-31 03:21:20 -04:00
|
|
|
|
2012-05-27 06:22:23 -04:00
|
|
|
before do
|
2017-06-05 14:51:54 -04:00
|
|
|
gitlab_sign_in(user)
|
2016-03-31 03:21:20 -04:00
|
|
|
project.team << [user, :reporter]
|
2012-05-27 06:22:23 -04:00
|
|
|
visit search_path
|
2016-03-31 03:21:20 -04:00
|
|
|
end
|
2016-04-13 17:43:07 -04:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'does not show top right search form' do
|
2016-04-13 17:43:07 -04:00
|
|
|
expect(page).not_to have_selector('.search')
|
|
|
|
end
|
2013-02-21 06:28:05 -05:00
|
|
|
|
2016-09-09 07:08:49 -04:00
|
|
|
context 'search filters', js: true do
|
|
|
|
let(:group) { create(:group) }
|
2017-05-08 07:42:42 -04:00
|
|
|
let!(:group_project) { create(:empty_project, group: group) }
|
2016-09-09 07:08:49 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows group name after filtering' do
|
2017-05-08 16:08:39 -04:00
|
|
|
find('.js-search-group-dropdown').trigger('click')
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-09 07:08:49 -04:00
|
|
|
|
|
|
|
page.within '.search-holder' do
|
|
|
|
click_link group.name
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.js-search-group-dropdown')).to have_content(group.name)
|
|
|
|
end
|
|
|
|
|
2017-05-08 07:42:42 -04:00
|
|
|
it 'filters by group projects after filtering by group' do
|
2017-05-12 16:14:55 -04:00
|
|
|
find('.js-search-group-dropdown').trigger('click')
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-08 07:42:42 -04:00
|
|
|
|
|
|
|
page.within '.search-holder' do
|
|
|
|
click_link group.name
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.js-search-group-dropdown')).to have_content(group.name)
|
|
|
|
|
|
|
|
page.within('.project-filter') do
|
2017-05-12 16:14:55 -04:00
|
|
|
find('.js-search-project-dropdown').trigger('click')
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-08 07:42:42 -04:00
|
|
|
|
|
|
|
expect(page).to have_link(group_project.name_with_namespace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-09 07:08:49 -04:00
|
|
|
it 'shows project name after filtering' do
|
|
|
|
page.within('.project-filter') do
|
2017-05-08 16:08:39 -04:00
|
|
|
find('.js-search-project-dropdown').trigger('click')
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-09 07:08:49 -04:00
|
|
|
|
|
|
|
click_link project.name_with_namespace
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.js-search-project-dropdown')).to have_content(project.name_with_namespace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
describe 'searching for Projects' do
|
|
|
|
it 'finds a project' do
|
|
|
|
page.within '.search-holder' do
|
|
|
|
fill_in "search", with: project.name[0..3]
|
|
|
|
click_button "Search"
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content project.name
|
2013-02-21 06:28:05 -05:00
|
|
|
end
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
context 'search for comments' do
|
2016-07-29 15:20:00 -04:00
|
|
|
context 'when comment belongs to a invalid commit' do
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-07-29 15:20:00 -04:00
|
|
|
let(:note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'Bug here') }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
note.update_attributes(commit_id: 12345678)
|
|
|
|
end
|
2016-07-29 15:20:00 -04:00
|
|
|
|
|
|
|
it 'finds comment' do
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within '.search' do
|
|
|
|
fill_in 'search', with: note.note
|
|
|
|
click_button 'Go'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_link 'Comments'
|
|
|
|
|
|
|
|
expect(page).to have_text("Commit deleted")
|
|
|
|
expect(page).to have_text("12345678")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
it 'finds a snippet' do
|
|
|
|
snippet = create(:project_snippet, :private, project: project, author: user, title: 'Some title')
|
|
|
|
note = create(:note,
|
|
|
|
noteable: snippet,
|
|
|
|
author: user,
|
|
|
|
note: 'Supercalifragilisticexpialidocious',
|
|
|
|
project: project)
|
|
|
|
# Must visit project dashboard since global search won't search
|
|
|
|
# everything (e.g. comments, snippets, etc.)
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within '.search' do
|
|
|
|
fill_in 'search', with: note.note
|
|
|
|
click_button 'Go'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_link 'Comments'
|
|
|
|
|
|
|
|
expect(page).to have_link(snippet.title)
|
|
|
|
end
|
2016-11-07 13:36:58 -05:00
|
|
|
|
|
|
|
it 'finds a commit' do
|
2017-03-28 17:13:16 -04:00
|
|
|
project = create(:project, :repository) { |p| p.add_reporter(user) }
|
2016-11-07 13:36:58 -05:00
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within '.search' do
|
|
|
|
fill_in 'search', with: 'add'
|
|
|
|
click_button 'Go'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_link "Commits"
|
|
|
|
|
|
|
|
expect(page).to have_selector('.commit-row-description')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'finds a code' do
|
2017-03-28 17:13:16 -04:00
|
|
|
project = create(:project, :repository) { |p| p.add_reporter(user) }
|
2016-11-07 13:36:58 -05:00
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within '.search' do
|
2017-04-03 13:31:52 -04:00
|
|
|
fill_in 'search', with: 'application.js'
|
2016-11-07 13:36:58 -05:00
|
|
|
click_button 'Go'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_link "Code"
|
|
|
|
|
|
|
|
expect(page).to have_selector('.file-content .code')
|
2017-04-03 13:31:52 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector("span.line[lang='javascript']")
|
2016-11-07 13:36:58 -05:00
|
|
|
end
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|
2016-06-07 10:54:29 -04:00
|
|
|
|
|
|
|
describe 'Right header search field', feature: true do
|
2016-08-19 04:45:58 -04:00
|
|
|
it 'allows enter key to search', js: true do
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
fill_in 'search', with: 'gitlab'
|
|
|
|
find('#search').native.send_keys(:enter)
|
|
|
|
|
|
|
|
page.within '.title' do
|
|
|
|
expect(page).to have_content 'Search'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-07 10:54:29 -04:00
|
|
|
describe 'Search in project page' do
|
|
|
|
before do
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'shows top right search form' do
|
2016-06-07 10:54:29 -04:00
|
|
|
expect(page).to have_selector('#search')
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'contains location badge in top right search form' do
|
2016-06-07 10:54:29 -04:00
|
|
|
expect(page).to have_selector('.has-location-badge')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'clicking the search field', js: true do
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'shows category search dropdown' do
|
2016-06-07 10:54:29 -04:00
|
|
|
page.find('#search').click
|
|
|
|
|
2016-06-09 18:05:09 -04:00
|
|
|
expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i)
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'click the links in the category search dropdown', js: true do
|
2017-04-05 08:43:03 -04:00
|
|
|
let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) }
|
|
|
|
|
2016-06-07 10:54:29 -04:00
|
|
|
before do
|
|
|
|
page.find('#search').click
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'takes user to her issues page when issues assigned is clicked' do
|
2016-06-07 10:54:29 -04:00
|
|
|
find('.dropdown-menu').click_link 'Issues assigned to me'
|
|
|
|
sleep 2
|
|
|
|
|
2016-11-11 12:56:47 -05:00
|
|
|
expect(page).to have_selector('.filtered-search')
|
2017-01-30 17:53:18 -05:00
|
|
|
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }])
|
|
|
|
expect_filtered_search_input_empty
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'takes user to her issues page when issues authored is clicked' do
|
2016-06-07 10:54:29 -04:00
|
|
|
find('.dropdown-menu').click_link "Issues I've created"
|
|
|
|
sleep 2
|
|
|
|
|
2016-11-11 12:56:47 -05:00
|
|
|
expect(page).to have_selector('.filtered-search')
|
2017-01-30 17:53:18 -05:00
|
|
|
expect_tokens([{ name: 'author', value: "@#{user.username}" }])
|
|
|
|
expect_filtered_search_input_empty
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'takes user to her MR page when MR assigned is clicked' do
|
2016-06-07 10:54:29 -04:00
|
|
|
find('.dropdown-menu').click_link 'Merge requests assigned to me'
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-requests-holder')
|
2017-01-30 17:53:18 -05:00
|
|
|
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }])
|
|
|
|
expect_filtered_search_input_empty
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'takes user to her MR page when MR authored is clicked' do
|
2016-06-07 10:54:29 -04:00
|
|
|
find('.dropdown-menu').click_link "Merge requests I've created"
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-requests-holder')
|
2017-01-30 17:53:18 -05:00
|
|
|
expect_tokens([{ name: 'author', value: "@#{user.username}" }])
|
|
|
|
expect_filtered_search_input_empty
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'entering text into the search field', js: true do
|
|
|
|
before do
|
|
|
|
page.within '.search-input-wrap' do
|
|
|
|
fill_in "search", with: project.name[0..3]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'does not display the category search dropdown' do
|
2016-06-09 18:05:09 -04:00
|
|
|
expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i)
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-12-08 09:54:45 -05:00
|
|
|
|
|
|
|
describe 'search for commits' do
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
2016-12-08 09:54:45 -05:00
|
|
|
before do
|
|
|
|
visit search_path(project_id: project.id)
|
|
|
|
end
|
|
|
|
|
2017-01-10 23:20:32 -05:00
|
|
|
it 'redirects to commit page when search by sha and only commit found' do
|
|
|
|
fill_in 'search', with: '6d394385cf567f80a8fd85055db1ab4c5295806f'
|
|
|
|
|
|
|
|
click_button 'Search'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(namespace_project_commit_path(project.namespace, project, '6d394385cf567f80a8fd85055db1ab4c5295806f'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to single commit regardless of query case' do
|
|
|
|
fill_in 'search', with: '6D394385cf'
|
|
|
|
|
|
|
|
click_button 'Search'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(namespace_project_commit_path(project.namespace, project, '6d394385cf567f80a8fd85055db1ab4c5295806f'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'holds on /search page when the only commit is found by message' do
|
|
|
|
create_commit('Message referencing another sha: "deadbeef" ', project, user, 'master')
|
|
|
|
|
|
|
|
fill_in 'search', with: 'deadbeef'
|
|
|
|
click_button 'Search'
|
|
|
|
|
|
|
|
expect(page).to have_current_path('/search', only_path: true)
|
|
|
|
end
|
|
|
|
|
2016-12-08 09:54:45 -05:00
|
|
|
it 'shows multiple matching commits' do
|
|
|
|
fill_in 'search', with: 'See merge request'
|
|
|
|
|
|
|
|
click_button 'Search'
|
|
|
|
click_link 'Commits'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.commit-row-description', count: 9)
|
|
|
|
end
|
|
|
|
end
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|