2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-07 13:36:58 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Global search' do
|
2020-12-01 01:09:37 -05:00
|
|
|
include AfterNextHelpers
|
|
|
|
|
2016-11-07 13:36:58 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2016-11-07 13:36:58 -05:00
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2019-07-29 05:58:58 -04:00
|
|
|
|
|
|
|
visit dashboard_projects_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'increases usage ping searches counter' do
|
2020-05-25 02:08:38 -04:00
|
|
|
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:navbar_searches)
|
|
|
|
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:all_searches)
|
2019-07-29 05:58:58 -04:00
|
|
|
|
2019-08-30 05:49:14 -04:00
|
|
|
submit_search('foobar')
|
2016-11-07 13:36:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'I search through the issues and I see pagination' do
|
|
|
|
before do
|
2020-12-01 01:09:37 -05:00
|
|
|
allow_next(SearchService).to receive(:per_page).and_return(1)
|
2016-11-07 13:36:58 -05:00
|
|
|
create_list(:issue, 2, project: project, title: 'initial')
|
|
|
|
end
|
|
|
|
|
2021-02-12 04:08:48 -05:00
|
|
|
it "has a pagination" do
|
2019-08-30 05:49:14 -04:00
|
|
|
submit_search('initial')
|
|
|
|
select_search_scope('Issues')
|
2016-11-07 13:36:58 -05:00
|
|
|
|
2018-01-23 06:03:15 -05:00
|
|
|
expect(page).to have_selector('.gl-pagination .next')
|
2016-11-07 13:36:58 -05:00
|
|
|
end
|
|
|
|
end
|
2019-05-24 15:20:05 -04:00
|
|
|
|
2020-10-30 05:08:39 -04:00
|
|
|
it 'closes the dropdown on blur', :js do
|
|
|
|
find('#search').click
|
2019-05-24 15:20:05 -04:00
|
|
|
fill_in 'search', with: "a"
|
|
|
|
|
2020-10-30 05:08:39 -04:00
|
|
|
expect(page).to have_selector("div[data-testid='dashboard-search-options'].show")
|
2019-05-24 15:20:05 -04:00
|
|
|
|
|
|
|
find('#search').send_keys(:backspace)
|
|
|
|
find('body').click
|
|
|
|
|
2020-10-30 05:08:39 -04:00
|
|
|
expect(page).to have_no_selector("div[data-testid='dashboard-search-options'].show")
|
2019-05-24 15:20:05 -04:00
|
|
|
end
|
2016-11-07 13:36:58 -05:00
|
|
|
end
|