gitlab-org--gitlab-foss/spec/features/issues/filter_by_labels_spec.rb

157 lines
4.8 KiB
Ruby
Raw Normal View History

2016-04-14 12:23:46 +00:00
require 'rails_helper'
feature 'Issue filtering by Labels', feature: true, js: true do
include WaitForAjax
2016-04-14 12:23:46 +00:00
let(:project) { create(:project, :public) }
let!(:user) { create(:user) }
2016-04-14 12:23:46 +00:00
let!(:label) { create(:label, project: project) }
before do
bug = create(:label, project: project, title: 'bug')
feature = create(:label, project: project, title: 'feature')
enhancement = create(:label, project: project, title: 'enhancement')
issue1 = create(:issue, title: "Bugfix1", project: project)
issue1.labels << bug
2016-04-14 12:23:46 +00:00
issue2 = create(:issue, title: "Bugfix2", project: project)
issue2.labels << bug
issue2.labels << enhancement
2016-04-14 12:23:46 +00:00
issue3 = create(:issue, title: "Feature1", project: project)
issue3.labels << feature
2016-04-14 12:23:46 +00:00
project.team << [user, :master]
login_as(user)
visit namespace_project_issues_path(project.namespace, project)
end
context 'filter by label bug' do
2016-04-14 12:23:46 +00:00
before do
select_labels('bug')
2016-04-14 12:23:46 +00:00
end
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"
expect(find('.filtered-labels')).to have_content "bug"
expect(find('.filtered-labels')).not_to have_content "feature"
expect(find('.filtered-labels')).not_to have_content "enhancement"
find('.js-label-filter-remove').click
wait_for_ajax
expect(find('.filtered-labels', visible: false)).to have_no_content "bug"
end
2016-04-14 12:23:46 +00:00
end
context 'filter by label feature' do
2016-04-14 12:23:46 +00:00
before do
select_labels('feature')
2016-04-14 12:23:46 +00:00
end
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"
expect(find('.filtered-labels')).to have_content "feature"
expect(find('.filtered-labels')).not_to have_content "bug"
expect(find('.filtered-labels')).not_to have_content "enhancement"
end
end
context 'filter by label enhancement' do
2016-04-14 12:23:46 +00:00
before do
select_labels('enhancement')
2016-04-14 12:23:46 +00:00
end
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"
expect(find('.filtered-labels')).to have_content "enhancement"
expect(find('.filtered-labels')).not_to have_content "bug"
expect(find('.filtered-labels')).not_to have_content "feature"
end
end
context 'filter by label enhancement and bug in issues list' do
2016-04-14 12:23:46 +00:00
before do
select_labels('bug', 'enhancement')
2016-04-14 12:23:46 +00:00
end
it 'applies the filters' do
page.within '.issues-state-filters' do
expect(page).to have_content('Open 1')
expect(page).to have_content('Closed 0')
expect(page).to have_content('All 1')
end
expect(page).to have_content "Bugfix2"
expect(page).not_to have_content "Feature1"
expect(find('.filtered-labels')).to have_content "bug"
2016-04-14 12:23:46 +00:00
expect(find('.filtered-labels')).to have_content "enhancement"
expect(find('.filtered-labels')).not_to have_content "feature"
find('.js-label-filter-remove', match: :first).click
wait_for_ajax
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"
expect(find('.filtered-labels')).not_to have_content "bug"
2016-04-14 12:23:46 +00:00
expect(find('.filtered-labels')).to have_content "enhancement"
expect(find('.filtered-labels')).not_to have_content "feature"
end
end
context 'remove filtered labels' do
before do
page.within '.labels-filter' do
click_button 'Label'
wait_for_ajax
click_link 'bug'
find('.dropdown-menu-close').click
end
page.within '.filtered-labels' do
expect(page).to have_content 'bug'
end
end
it 'allows user to remove filtered labels' do
first('.js-label-filter-remove').click
wait_for_ajax
expect(find('.filtered-labels', visible: false)).not_to have_content 'bug'
expect(find('.labels-filter')).not_to have_content 'bug'
end
end
2016-06-09 09:44:17 +00:00
context 'dropdown filtering' do
it 'filters by label name' do
2016-06-09 09:44:17 +00:00
page.within '.labels-filter' do
click_button 'Label'
wait_for_ajax
find('.dropdown-input input').set 'bug'
2016-06-09 09:44:17 +00:00
page.within '.dropdown-content' do
expect(page).not_to have_content 'enhancement'
expect(page).to have_content 'bug'
end
end
end
end
def select_labels(*labels)
page.find('.js-label-select').click
wait_for_ajax
labels.each do |label|
execute_script("$('.dropdown-menu-labels li:contains(\"#{label}\") a').click()")
end
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
wait_for_ajax
end
2016-04-14 12:23:46 +00:00
end