2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'Dropdown author', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
include FilteredSearchHelpers
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let!(:project) { create(:project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:user) { create(:user, name: 'administrator', username: 'root') }
|
|
|
|
let(:js_dropdown_author) { '#js-dropdown-author' }
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:filter_dropdown) { find("#{js_dropdown_author} .filter-dropdown") }
|
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)
|
2017-08-17 22:00:37 +05:30
|
|
|
create(:issue, project: project)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_issues_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'behavior' do
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'loads all the authors when opened' do
|
2020-04-08 14:13:33 +05:30
|
|
|
input_filtered_search('author:=', submit: false, extra_space: false)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect_filtered_search_dropdown_results(filter_dropdown, 2)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows current user at top of dropdown' do
|
2020-04-08 14:13:33 +05:30
|
|
|
input_filtered_search('author:=', submit: false, extra_space: false)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(filter_dropdown.first('.filter-dropdown-item')).to have_content(user.name)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'selecting from dropdown without Ajax call' do
|
|
|
|
before do
|
|
|
|
Gitlab::Testing::RequestBlockerMiddleware.block_requests!
|
2020-04-08 14:13:33 +05:30
|
|
|
input_filtered_search('author:=', submit: false, extra_space: false)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'selects current user' do
|
2020-03-13 15:44:24 +05:30
|
|
|
find("#{js_dropdown_author} .filter-dropdown-item", text: user.username).click
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
expect(page).to have_css(js_dropdown_author, visible: false)
|
2018-03-17 18:26:18 +05:30
|
|
|
expect_tokens([author_token(user.username)])
|
2017-09-10 17:25:29 +05:30
|
|
|
expect_filtered_search_input_empty
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|