debian-mirror-gitlab/spec/features/global_search_spec.rb

51 lines
1.3 KiB
Ruby
Raw Normal View History

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