2016-04-14 12:23:46 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
feature 'Issue filtering by Labels', feature: true, js: true do
|
2017-02-15 22:13:53 +00:00
|
|
|
include FilteredSearchHelpers
|
|
|
|
include MergeRequestHelpers
|
2016-04-21 08:30:48 +00:00
|
|
|
|
2016-04-14 12:23:46 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-09-23 13:16:11 +00:00
|
|
|
let!(:user) { create(:user) }
|
2016-04-14 12:23:46 +00:00
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
|
2016-11-11 20:51:32 +00:00
|
|
|
let!(:bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let!(:feature) { create(:label, project: project, title: 'feature') }
|
|
|
|
let!(:enhancement) { create(:label, project: project, title: 'enhancement') }
|
|
|
|
|
|
|
|
let!(:mr1) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "bugfix1") }
|
2016-11-14 16:25:32 +00:00
|
|
|
let!(:mr2) { create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "bugfix2") }
|
2016-11-11 20:51:32 +00:00
|
|
|
let!(:mr3) { create(:merge_request, title: "Feature1", source_project: project, target_project: project, source_branch: "feature1") }
|
2016-09-22 12:39:13 +00:00
|
|
|
|
2016-11-11 20:51:32 +00:00
|
|
|
before do
|
|
|
|
mr1.labels << bug
|
2016-04-14 12:23:46 +00:00
|
|
|
|
2016-11-11 20:51:32 +00:00
|
|
|
mr2.labels << bug
|
|
|
|
mr2.labels << enhancement
|
2016-04-14 12:23:46 +00:00
|
|
|
|
2016-11-11 20:51:32 +00:00
|
|
|
mr3.title = "Feature1"
|
|
|
|
mr3.labels << feature
|
2016-04-14 12:23:46 +00:00
|
|
|
|
|
|
|
project.team << [user, :master]
|
|
|
|
login_as(user)
|
|
|
|
|
2016-11-11 20:51:32 +00:00
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
context 'filter by label bug' do
|
2016-04-14 12:23:46 +00:00
|
|
|
before do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:~bug')
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
it 'apply the filter' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Bugfix1"
|
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
expect(page).not_to have_content "Feature1"
|
2016-05-17 11:07:11 +00:00
|
|
|
end
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
context 'filter by label feature' do
|
2016-04-14 12:23:46 +00:00
|
|
|
before do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:~feature')
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
it 'applies the filter' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Feature1"
|
|
|
|
expect(page).not_to have_content "Bugfix2"
|
|
|
|
expect(page).not_to have_content "Bugfix1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
context 'filter by label enhancement' do
|
2016-04-14 12:23:46 +00:00
|
|
|
before do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:~enhancement')
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
it 'applies the filter' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
expect(page).not_to have_content "Feature1"
|
|
|
|
expect(page).not_to have_content "Bugfix1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
context 'filter by label enhancement and bug in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
before do
|
2017-03-07 20:37:22 +00:00
|
|
|
input_filtered_search('label:~bug label:~enhancement')
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-23 13:16:11 +00:00
|
|
|
it 'applies the filters' do
|
2016-09-29 14:55:55 +00:00
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-09-23 13:16:11 +00:00
|
|
|
expect(page).to have_content "Bugfix2"
|
2016-04-21 07:12:03 +00:00
|
|
|
expect(page).not_to have_content "Feature1"
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
end
|
2016-06-02 09:40:42 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
context 'clear button' do
|
2016-06-02 09:40:42 +00:00
|
|
|
before do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:~bug')
|
2016-06-02 09:40:42 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'allows user to remove filtered labels' do
|
2017-02-15 22:13:53 +00:00
|
|
|
first('.clear-search').click
|
|
|
|
filtered_search.send_keys(:enter)
|
2016-06-02 09:40:42 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect(page).to have_issuable_counts(open: 3, closed: 0, all: 3)
|
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
expect(page).to have_content "Feature1"
|
|
|
|
expect(page).to have_content "Bugfix1"
|
2016-06-02 09:40:42 +00:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 09:44:17 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
context 'filter dropdown' do
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'filters by label name' do
|
2017-02-15 22:13:53 +00:00
|
|
|
init_label_search
|
|
|
|
filtered_search.send_keys('~bug')
|
2016-09-23 13:16:11 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
page.within '.filter-dropdown' do
|
|
|
|
expect(page).not_to have_content 'enhancement'
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
end
|
2016-09-23 13:16:11 +00:00
|
|
|
end
|
|
|
|
end
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|