2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-16 09:02:30 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'User searches for issues', :js do
|
2017-09-16 09:02:30 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
let!(:issue1) { create(:issue, title: 'Foo', project: project) }
|
2020-09-10 06:08:37 +00:00
|
|
|
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
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-09-16 09:02:30 +00:00
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(search_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'top right search form'
|
|
|
|
|
|
|
|
it 'finds an issue' do
|
2020-09-10 06:08:37 +00:00
|
|
|
search_for_issue(issue1.title)
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
page.within('.results') do
|
2019-08-30 09:49:14 +00:00
|
|
|
expect(page).to have_link(issue1.title)
|
|
|
|
expect(page).not_to have_link(issue2.title)
|
2017-09-16 09:02:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-10 06:08:37 +00:00
|
|
|
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
|
|
|
|
|
2017-09-16 09:02:30 +00:00
|
|
|
context 'when on a project page' do
|
|
|
|
it 'finds an issue' do
|
2017-09-25 16:14:19 +00:00
|
|
|
find('.js-search-project-dropdown').click
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
page.within('.project-filter') do
|
2018-03-05 14:15:26 +00:00
|
|
|
click_link(project.full_name)
|
2017-09-16 09:02:30 +00:00
|
|
|
end
|
|
|
|
|
2020-09-10 06:08:37 +00:00
|
|
|
search_for_issue(issue1.title)
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
page.within('.results') do
|
2019-08-30 09:49:14 +00:00
|
|
|
expect(page).to have_link(issue1.title)
|
|
|
|
expect(page).not_to have_link(issue2.title)
|
2017-09-16 09:02:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
2020-09-11 12:08:50 +00:00
|
|
|
context 'when block_anonymous_global_searches is disabled' do
|
|
|
|
let(:project) { create(:project, :public) }
|
2017-09-16 09:02:30 +00:00
|
|
|
|
2020-09-11 12:08:50 +00:00
|
|
|
before do
|
|
|
|
stub_feature_flags(block_anonymous_global_searches: false)
|
|
|
|
visit(search_path)
|
|
|
|
end
|
2017-09-16 09:02:30 +00:00
|
|
|
|
2020-09-11 12:08:50 +00:00
|
|
|
include_examples 'top right search form'
|
2017-09-16 09:02:30 +00:00
|
|
|
|
2020-09-11 12:08:50 +00:00
|
|
|
it 'finds an issue' do
|
|
|
|
search_for_issue(issue1.title)
|
2017-09-16 09:02:30 +00:00
|
|
|
|
2020-09-11 12:08:50 +00:00
|
|
|
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')
|
2017-09-16 09:02:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|