2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-19 17:21:26 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Prioritize labels' do
|
2017-01-06 11:52:18 -05:00
|
|
|
include DragTo
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-09-19 23:09:57 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public, namespace: group) }
|
2016-09-19 23:09:57 -04:00
|
|
|
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-05-19 17:21:26 -04:00
|
|
|
|
2016-09-19 23:09:57 -04:00
|
|
|
context 'when user belongs to project team' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2016-09-19 23:09:57 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can prioritize a group label', :js do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-11-12 18:51:47 -05:00
|
|
|
expect(page).to have_content('Star labels to start sorting by priority')
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-09-29 00:03:28 -04:00
|
|
|
page.within('.other-labels') do
|
|
|
|
all('.js-toggle-priority')[1].click
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).not_to have_content('feature')
|
2016-06-03 03:14:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-11-12 18:51:47 -05:00
|
|
|
expect(page).not_to have_content('Star labels to start sorting by priority')
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content('feature')
|
2016-06-03 03:14:39 -04:00
|
|
|
end
|
2016-05-19 17:21:26 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can unprioritize a group label', :js do
|
2016-10-14 17:32:44 -04:00
|
|
|
create(:label_priority, project: project, label: feature, priority: 1)
|
2016-06-03 03:14:39 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-06-03 03:14:39 -04:00
|
|
|
|
2016-09-19 23:09:57 -04:00
|
|
|
page.within('.prioritized-labels') do
|
|
|
|
expect(page).to have_content('feature')
|
|
|
|
|
|
|
|
first('.js-toggle-priority').click
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
2016-09-29 00:03:28 -04:00
|
|
|
page.within('.other-labels') do
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content('feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can prioritize a project label', :js do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-06-03 03:14:39 -04:00
|
|
|
|
2016-11-12 18:51:47 -05:00
|
|
|
expect(page).to have_content('Star labels to start sorting by priority')
|
2016-09-19 23:09:57 -04:00
|
|
|
|
2016-09-29 00:03:28 -04:00
|
|
|
page.within('.other-labels') do
|
2016-09-19 23:09:57 -04:00
|
|
|
first('.js-toggle-priority').click
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-11-12 18:51:47 -05:00
|
|
|
expect(page).not_to have_content('Star labels to start sorting by priority')
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content('bug')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can unprioritize a project label', :js do
|
2016-10-14 17:32:44 -04:00
|
|
|
create(:label_priority, project: project, label: bug, priority: 1)
|
2016-09-19 23:09:57 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-06-03 03:14:39 -04:00
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content('bug')
|
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
first('.js-toggle-priority').click
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-06-03 03:14:39 -04:00
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
2016-09-29 00:03:28 -04:00
|
|
|
page.within('.other-labels') do
|
2016-06-03 03:14:39 -04:00
|
|
|
expect(page).to have_content('bug')
|
|
|
|
expect(page).to have_content('wontfix')
|
|
|
|
end
|
2016-05-19 17:21:26 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can sort prioritized labels and persist across reloads', :js do
|
2016-10-14 17:32:44 -04:00
|
|
|
create(:label_priority, project: project, label: bug, priority: 1)
|
|
|
|
create(:label_priority, project: project, label: feature, priority: 2)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
expect(page).to have_content 'bug'
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content 'feature'
|
2016-06-03 03:14:39 -04:00
|
|
|
expect(page).to have_content 'wontfix'
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
# Sort labels
|
2018-01-29 10:37:56 -05:00
|
|
|
drag_to(selector: '.label-list-item', from_index: 1, to_index: 2)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
page.within('.prioritized-labels') do
|
2018-05-29 06:07:48 -04:00
|
|
|
expect(first('.label-list-item')).to have_content('feature')
|
|
|
|
expect(page.all('.label-list-item').last).to have_content('bug')
|
2016-06-03 03:14:39 -04:00
|
|
|
end
|
2016-06-07 06:57:09 -04:00
|
|
|
|
2016-07-06 07:36:39 -04:00
|
|
|
refresh
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-06-07 06:57:09 -04:00
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2018-05-29 06:07:48 -04:00
|
|
|
expect(first('.label-list-item')).to have_content('feature')
|
|
|
|
expect(page.all('.label-list-item').last).to have_content('bug')
|
2016-06-07 06:57:09 -04:00
|
|
|
end
|
2016-05-19 17:21:26 -04:00
|
|
|
end
|
2017-07-17 07:41:50 -04:00
|
|
|
|
2018-12-07 08:47:26 -05:00
|
|
|
it 'user can see a primary button when there are only prioritized labels', :js do
|
|
|
|
visit project_labels_path(project)
|
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
all('.js-toggle-priority').each do |el|
|
|
|
|
el.click
|
|
|
|
end
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2019-01-22 12:42:10 -05:00
|
|
|
page.within('.top-area') do
|
2018-12-07 08:47:26 -05:00
|
|
|
expect(page).to have_link('New label')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-17 07:41:50 -04:00
|
|
|
it 'shows a help message about prioritized labels' do
|
|
|
|
visit project_labels_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_content 'Star a label'
|
|
|
|
end
|
2016-05-19 17:21:26 -04:00
|
|
|
end
|
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
context 'as a guest' do
|
2019-04-12 06:54:23 -04:00
|
|
|
before do
|
|
|
|
create(:label_priority, project: project, label: bug, priority: 1)
|
|
|
|
create(:label_priority, project: project, label: feature, priority: 2)
|
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
guest = create(:user)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in guest
|
2016-09-19 23:09:57 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2019-04-12 06:54:23 -04:00
|
|
|
end
|
2016-06-03 03:14:39 -04:00
|
|
|
|
2019-04-12 06:54:23 -04:00
|
|
|
it 'cannot prioritize labels' do
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content 'feature'
|
2017-07-17 07:41:50 -04:00
|
|
|
expect(page).not_to have_content 'Star a label'
|
2016-06-03 03:14:39 -04:00
|
|
|
end
|
2019-04-12 06:54:23 -04:00
|
|
|
|
|
|
|
it 'cannot sort prioritized labels', :js do
|
|
|
|
drag_to(selector: '.prioritized-labels .label-list-item', from_index: 1, to_index: 2)
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
|
|
|
expect(first('.label-list-item')).to have_content('bug')
|
|
|
|
expect(page.all('.label-list-item').last).to have_content('feature')
|
|
|
|
end
|
|
|
|
end
|
2016-06-03 03:14:39 -04:00
|
|
|
end
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-06-03 03:14:39 -04:00
|
|
|
context 'as a non signed in user' do
|
2019-04-12 06:54:23 -04:00
|
|
|
it 'cannot prioritize labels' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-05-19 17:21:26 -04:00
|
|
|
|
2016-09-19 23:09:57 -04:00
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content 'feature'
|
2017-07-17 07:41:50 -04:00
|
|
|
expect(page).not_to have_content 'Star a label'
|
2016-05-19 17:21:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|