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

91 lines
2.5 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
end
2021-11-11 11:23:49 +05:30
describe 'when new_header_search feature is disabled' do
before do
# TODO: Remove this along with feature flag #339348
stub_feature_flags(new_header_search: false)
visit dashboard_projects_path
end
2019-10-12 21:52:04 +05:30
2021-11-11 11:23:49 +05:30
it 'increases usage ping searches counter' do
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:navbar_searches)
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:all_searches)
2017-08-17 22:00:37 +05:30
2021-11-11 11:23:49 +05:30
submit_search('foobar')
2017-08-17 22:00:37 +05:30
end
2021-11-11 11:23:49 +05:30
describe 'I search through the issues and I see pagination' do
before do
allow_next(SearchService).to receive(:per_page).and_return(1)
create_list(:issue, 2, project: project, title: 'initial')
end
it "has a pagination" do
submit_search('initial')
select_search_scope('Issues')
2017-08-17 22:00:37 +05:30
2021-11-11 11:23:49 +05:30
expect(page).to have_selector('.gl-pagination .next')
end
2017-08-17 22:00:37 +05:30
end
2019-09-04 21:01:54 +05:30
2021-11-11 11:23:49 +05:30
it 'closes the dropdown on blur', :js do
find('#search').click
fill_in 'search', with: "a"
expect(page).to have_selector("div[data-testid='dashboard-search-options'].show")
2019-09-04 21:01:54 +05:30
2021-11-11 11:23:49 +05:30
find('#search').send_keys(:backspace)
find('body').click
2019-09-04 21:01:54 +05:30
2021-11-11 11:23:49 +05:30
expect(page).to have_no_selector("div[data-testid='dashboard-search-options'].show")
end
it 'renders legacy search bar' do
expect(page).to have_selector('.search-form')
expect(page).to have_no_selector('#js-header-search')
end
2022-01-26 12:08:38 +05:30
it 'focuses search input when shortcut "s" is pressed', :js do
expect(page).not_to have_selector('#search:focus')
find('body').native.send_key('s')
expect(page).to have_selector('#search:focus')
end
2021-11-11 11:23:49 +05:30
end
2019-09-04 21:01:54 +05:30
2021-11-11 11:23:49 +05:30
describe 'when new_header_search feature is enabled' do
before do
# TODO: Remove this along with feature flag #339348
stub_feature_flags(new_header_search: true)
visit dashboard_projects_path
end
it 'renders updated search bar' do
expect(page).to have_no_selector('.search-form')
expect(page).to have_selector('#js-header-search')
end
2022-01-26 12:08:38 +05:30
it 'focuses search input when shortcut "s" is pressed', :js do
expect(page).not_to have_selector('#search:focus')
find('body').native.send_key('s')
expect(page).to have_selector('#search:focus')
end
2019-09-04 21:01:54 +05:30
end
2017-08-17 22:00:37 +05:30
end