2016-11-11 21:10:13 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-08-10 17:44:17 +00:00
|
|
|
feature 'Merge requests filter clear button', :js do
|
2017-02-15 22:13:53 +00:00
|
|
|
include FilteredSearchHelpers
|
|
|
|
include MergeRequestHelpers
|
2016-11-11 21:10:13 +00:00
|
|
|
include IssueHelpers
|
|
|
|
|
2017-07-26 21:52:10 +00:00
|
|
|
let!(:project) { create(:project, :public, :repository) }
|
2017-02-15 22:13:53 +00:00
|
|
|
let!(:user) { create(:user) }
|
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
|
|
|
let!(:bug) { create(:label, project: project, name: 'bug')}
|
2017-08-10 17:44:17 +00:00
|
|
|
let!(:mr1) { create(:merge_request, title: "Feature", source_project: project, target_project: project, source_branch: "improve/awesome", milestone: milestone, author: user, assignee: user) }
|
|
|
|
let!(:mr2) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "fix") }
|
2016-11-11 21:10:13 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
let(:merge_request_css) { '.merge-request' }
|
2017-03-30 02:04:05 +00:00
|
|
|
let(:clear_search_css) { '.filtered-search-box .clear-search' }
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
mr2.labels << bug
|
|
|
|
project.team << [user, :developer]
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a milestone filter has been applied' do
|
|
|
|
it 'resets the milestone filter' do
|
|
|
|
visit_merge_requests(project, milestone_title: milestone.title)
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 1)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a label filter has been applied' do
|
|
|
|
it 'resets the label filter' do
|
|
|
|
visit_merge_requests(project, label_name: bug.name)
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 1)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-20 23:27:12 +00:00
|
|
|
context 'when multiple label filters have been applied' do
|
|
|
|
let!(:label) { create(:label, project: project, name: 'Frontend') }
|
|
|
|
let(:filter_dropdown) { find("#js-dropdown-label .filter-dropdown") }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit_merge_requests(project)
|
|
|
|
init_label_search
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters bug label' do
|
|
|
|
filtered_search.set('~bug')
|
|
|
|
|
|
|
|
filter_dropdown.find('.filter-dropdown-item', text: bug.title).click
|
|
|
|
init_label_search
|
|
|
|
|
|
|
|
expect(filter_dropdown.find('.filter-dropdown-item', text: bug.title)).to be_visible
|
|
|
|
expect(filter_dropdown.find('.filter-dropdown-item', text: label.title)).to be_visible
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
context 'when a text search has been conducted' do
|
|
|
|
it 'resets the text search filter' do
|
|
|
|
visit_merge_requests(project, search: 'Bug')
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 1)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when author filter has been applied' do
|
|
|
|
it 'resets the author filter' do
|
2017-02-15 22:13:53 +00:00
|
|
|
visit_merge_requests(project, author_username: user.username)
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 1)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when assignee filter has been applied' do
|
|
|
|
it 'resets the assignee filter' do
|
2017-02-15 22:13:53 +00:00
|
|
|
visit_merge_requests(project, assignee_username: user.username)
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 1)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when all filters have been applied' do
|
2017-01-30 22:53:18 +00:00
|
|
|
it 'clears all filters' do
|
2017-02-15 22:13:53 +00:00
|
|
|
visit_merge_requests(project, assignee_username: user.username, author_username: user.username, milestone_title: milestone.title, label_name: bug.name, search: 'Bug')
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 0)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq('')
|
2016-11-11 21:10:13 +00:00
|
|
|
|
|
|
|
reset_filters
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when no filters have been applied' do
|
2017-01-30 22:53:18 +00:00
|
|
|
it 'the clear button should not be visible' do
|
2016-11-11 21:10:13 +00:00
|
|
|
visit_merge_requests(project)
|
2017-01-30 22:53:18 +00:00
|
|
|
|
2016-11-11 21:10:13 +00:00
|
|
|
expect(page).to have_css(merge_request_css, count: 2)
|
2017-01-30 22:53:18 +00:00
|
|
|
expect(get_filtered_search_placeholder).to eq(default_placeholder)
|
2017-02-15 22:13:53 +00:00
|
|
|
expect(page).not_to have_css(clear_search_css)
|
2016-11-11 21:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|