debian-mirror-gitlab/spec/features/projects/labels/update_prioritization_spec.rb

153 lines
4.4 KiB
Ruby
Raw Normal View History

require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Prioritize labels' do
2017-08-17 22:00:37 +05:30
include DragTo
2016-11-03 12:29:30 +05:30
let(:user) { create(:user) }
let(:group) { create(:group) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, :public, namespace: group) }
2016-11-03 12:29:30 +05:30
let!(:bug) { create(:label, project: project, title: 'bug') }
let!(:wontfix) { create(:label, project: project, title: 'wontfix') }
let!(:feature) { create(:group_label, group: group, title: 'feature') }
2016-11-03 12:29:30 +05:30
context 'when user belongs to project team' do
before do
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2017-09-10 17:25:29 +05:30
sign_in user
2016-11-03 12:29:30 +05:30
end
2018-11-08 19:23:39 +05:30
it 'user can prioritize a group label', :js do
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
2016-11-03 12:29:30 +05:30
2017-08-17 22:00:37 +05:30
expect(page).to have_content('Star labels to start sorting by priority')
2016-11-03 12:29:30 +05:30
page.within('.other-labels') do
all('.js-toggle-priority')[1].click
2017-09-10 17:25:29 +05:30
wait_for_requests
2016-11-03 12:29:30 +05:30
expect(page).not_to have_content('feature')
end
page.within('.prioritized-labels') do
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content('Star labels to start sorting by priority')
2016-11-03 12:29:30 +05:30
expect(page).to have_content('feature')
end
end
2018-11-08 19:23:39 +05:30
it 'user can unprioritize a group label', :js do
2016-11-03 12:29:30 +05:30
create(:label_priority, project: project, label: feature, priority: 1)
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
2016-11-03 12:29:30 +05:30
page.within('.prioritized-labels') do
expect(page).to have_content('feature')
first('.js-toggle-priority').click
2017-09-10 17:25:29 +05:30
wait_for_requests
2016-11-03 12:29:30 +05:30
expect(page).not_to have_content('bug')
end
page.within('.other-labels') do
expect(page).to have_content('feature')
end
end
2018-11-08 19:23:39 +05:30
it 'user can prioritize a project label', :js do
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
2017-08-17 22:00:37 +05:30
expect(page).to have_content('Star labels to start sorting by priority')
page.within('.other-labels') do
first('.js-toggle-priority').click
2017-09-10 17:25:29 +05:30
wait_for_requests
expect(page).not_to have_content('bug')
end
page.within('.prioritized-labels') do
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content('Star labels to start sorting by priority')
expect(page).to have_content('bug')
end
end
2018-11-08 19:23:39 +05:30
it 'user can unprioritize a project label', :js do
2016-11-03 12:29:30 +05:30
create(:label_priority, project: project, label: bug, priority: 1)
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
page.within('.prioritized-labels') do
2016-11-03 12:29:30 +05:30
expect(page).to have_content('bug')
first('.js-toggle-priority').click
2017-09-10 17:25:29 +05:30
wait_for_requests
expect(page).not_to have_content('bug')
end
page.within('.other-labels') do
expect(page).to have_content('bug')
expect(page).to have_content('wontfix')
end
end
2018-11-08 19:23:39 +05:30
it 'user can sort prioritized labels and persist across reloads', :js do
2016-11-03 12:29:30 +05:30
create(:label_priority, project: project, label: bug, priority: 1)
create(:label_priority, project: project, label: feature, priority: 2)
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
expect(page).to have_content 'bug'
2016-11-03 12:29:30 +05:30
expect(page).to have_content 'feature'
expect(page).to have_content 'wontfix'
# Sort labels
2018-03-17 18:26:18 +05:30
drag_to(selector: '.label-list-item', from_index: 1, to_index: 2)
page.within('.prioritized-labels') do
2018-11-08 19:23:39 +05:30
expect(first('.label-list-item')).to have_content('feature')
expect(page.all('.label-list-item').last).to have_content('bug')
end
2016-08-24 12:49:21 +05:30
refresh
2017-09-10 17:25:29 +05:30
wait_for_requests
page.within('.prioritized-labels') do
2018-11-08 19:23:39 +05:30
expect(first('.label-list-item')).to have_content('feature')
expect(page.all('.label-list-item').last).to have_content('bug')
end
end
2017-09-10 17:25:29 +05:30
it 'shows a help message about prioritized labels' do
visit project_labels_path(project)
expect(page).to have_content 'Star a label'
end
end
context 'as a guest' do
2016-09-13 17:45:13 +05:30
it 'does not prioritize labels' do
guest = create(:user)
2017-09-10 17:25:29 +05:30
sign_in guest
2016-11-03 12:29:30 +05:30
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
2016-11-03 12:29:30 +05:30
expect(page).to have_content 'bug'
expect(page).to have_content 'wontfix'
expect(page).to have_content 'feature'
expect(page).not_to have_css('.prioritized-labels')
2017-09-10 17:25:29 +05:30
expect(page).not_to have_content 'Star a label'
end
end
context 'as a non signed in user' do
2016-09-13 17:45:13 +05:30
it 'does not prioritize labels' do
2017-09-10 17:25:29 +05:30
visit project_labels_path(project)
2016-11-03 12:29:30 +05:30
expect(page).to have_content 'bug'
expect(page).to have_content 'wontfix'
expect(page).to have_content 'feature'
expect(page).not_to have_css('.prioritized-labels')
2017-09-10 17:25:29 +05:30
expect(page).not_to have_content 'Star a label'
end
end
end