2016-04-14 12:23:46 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
feature 'Issue filtering by Labels', feature: true do
|
2016-04-21 08:30:48 +00:00
|
|
|
include WaitForAjax
|
|
|
|
|
2016-04-14 12:23:46 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let!(:user) { create(:user)}
|
|
|
|
let!(:label) { create(:label, project: project) }
|
2016-09-21 17:02:09 +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(:issue1) { create(:issue, title: "Bugfix1", project: project) }
|
|
|
|
let(:issue2) { create(:issue, title: "Bugfix2", project: project) }
|
|
|
|
let(:issue3) { create(:issue, title: "Feature1", project: project) }
|
2016-04-14 12:23:46 +00:00
|
|
|
|
|
|
|
before do
|
2016-04-21 07:12:03 +00:00
|
|
|
issue1.labels << bug
|
2016-04-14 12:23:46 +00:00
|
|
|
|
2016-04-21 07:12:03 +00:00
|
|
|
issue2.labels << bug
|
|
|
|
issue2.labels << enhancement
|
2016-04-14 12:23:46 +00:00
|
|
|
|
2016-04-21 07:12:03 +00:00
|
|
|
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', js: true do
|
|
|
|
before do
|
|
|
|
page.find('.js-label-select').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
|
|
|
|
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows issue "Bugfix1" and "Bugfix2" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Bugfix1"
|
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show "Feature1" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).not_to have_content "Feature1"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows label "bug" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).to have_content "bug"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show label "feature" and "enhancement" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).not_to have_content "feature"
|
|
|
|
expect(find('.filtered-labels')).not_to have_content "enhancement"
|
|
|
|
end
|
2016-05-17 11:07:11 +00:00
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'removes label "bug"' do
|
2016-06-14 11:21:24 +00:00
|
|
|
find('.js-label-filter-remove').click
|
|
|
|
wait_for_ajax
|
|
|
|
expect(find('.filtered-labels', visible: false)).to have_no_content "bug"
|
2016-05-17 11:07:11 +00:00
|
|
|
end
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'filter by label feature', js: true do
|
|
|
|
before do
|
|
|
|
page.find('.js-label-select').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
|
|
|
|
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows issue "Feature1" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Feature1"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show "Bugfix1" and "Bugfix2" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).not_to have_content "Bugfix2"
|
|
|
|
expect(page).not_to have_content "Bugfix1"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows label "feature" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).to have_content "feature"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show label "bug" and "enhancement" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
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', js: true do
|
|
|
|
before do
|
|
|
|
page.find('.js-label-select').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
|
|
|
|
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows issue "Bugfix2" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show "Feature1" and "Bugfix1" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).not_to have_content "Feature1"
|
|
|
|
expect(page).not_to have_content "Bugfix1"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows label "enhancement" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).to have_content "enhancement"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show label "feature" and "bug" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
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 or feature', js: true do
|
|
|
|
before do
|
|
|
|
page.find('.js-label-select').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
|
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
|
|
|
|
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show "Bugfix1" or "Feature1" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).not_to have_content "Bugfix1"
|
2016-04-21 07:12:03 +00:00
|
|
|
expect(page).not_to have_content "Feature1"
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows label "enhancement" and "feature" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).to have_content "enhancement"
|
|
|
|
expect(find('.filtered-labels')).to have_content "feature"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show label "bug" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).not_to have_content "bug"
|
|
|
|
end
|
2016-05-17 11:07:11 +00:00
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'removes label "enhancement"' do
|
2016-06-14 11:21:24 +00:00
|
|
|
find('.js-label-filter-remove', match: :first).click
|
|
|
|
wait_for_ajax
|
2016-05-17 11:07:11 +00:00
|
|
|
expect(find('.filtered-labels')).to have_no_content "enhancement"
|
|
|
|
end
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-04-21 07:12:03 +00:00
|
|
|
context 'filter by label enhancement and bug in issues list', js: true do
|
2016-04-14 12:23:46 +00:00
|
|
|
before do
|
|
|
|
page.find('.js-label-select').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
|
|
|
|
execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
|
|
|
|
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
|
2016-04-21 08:30:48 +00:00
|
|
|
wait_for_ajax
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|
|
|
|
|
2016-09-21 17:02:09 +00:00
|
|
|
it 'shows a correct "Open" counter' do
|
|
|
|
page.within '.issues-state-filters' do
|
|
|
|
expect(page).not_to have_content "{#{issue2.id} => 1}"
|
|
|
|
expect(page).to have_content "Open 1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows issue "Bugfix2" in issues list' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).to have_content "Bugfix2"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show "Feature1"' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(page).not_to have_content "Feature1"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows label "bug" and "enhancement" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).to have_content "bug"
|
|
|
|
expect(find('.filtered-labels')).to have_content "enhancement"
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show label "feature" in filtered-labels' do
|
2016-04-14 12:23:46 +00:00
|
|
|
expect(find('.filtered-labels')).not_to have_content "feature"
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 09:40:42 +00:00
|
|
|
|
|
|
|
context 'remove filtered labels', js: true do
|
|
|
|
before do
|
|
|
|
page.within '.labels-filter' do
|
|
|
|
click_button 'Label'
|
2016-06-14 11:21:24 +00:00
|
|
|
wait_for_ajax
|
2016-06-02 09:40:42 +00:00
|
|
|
click_link 'bug'
|
|
|
|
find('.dropdown-menu-close').click
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.filtered-labels' do
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'allows user to remove filtered labels' do
|
2016-06-14 11:21:24 +00:00
|
|
|
first('.js-label-filter-remove').click
|
|
|
|
wait_for_ajax
|
2016-06-02 09:40:42 +00:00
|
|
|
|
2016-06-14 11:21:24 +00:00
|
|
|
expect(find('.filtered-labels', visible: false)).not_to have_content 'bug'
|
|
|
|
expect(find('.labels-filter')).not_to have_content 'bug'
|
2016-06-02 09:40:42 +00:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 09:44:17 +00:00
|
|
|
|
|
|
|
context 'dropdown filtering', js: true do
|
2016-07-25 18:16:19 +00:00
|
|
|
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
|
2016-07-21 04:08:50 +00:00
|
|
|
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
|
2016-04-14 12:23:46 +00:00
|
|
|
end
|