debian-mirror-gitlab/spec/features/admin/admin_labels_spec.rb

120 lines
3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
RSpec.describe 'admin issues labels' do
2022-03-02 08:16:31 +05:30
include Spec::Support::Helpers::ModalHelpers
2021-04-29 21:17:54 +05:30
let!(:bug_label) { Label.create!(title: 'bug', template: true) }
let!(:feature_label) { Label.create!(title: 'feature', template: true) }
2017-08-17 22:00:37 +05:30
before do
2021-02-22 17:27:13 +05:30
admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
2017-08-17 22:00:37 +05:30
end
describe 'list' do
before do
2021-12-11 22:18:48 +05:30
stub_feature_flags(bootstrap_confirmation_modals: false)
2017-08-17 22:00:37 +05:30
visit admin_labels_path
end
it 'renders labels list' do
page.within '.manage-labels-list' do
expect(page).to have_content('bug')
expect(page).to have_content('feature')
end
end
it 'deletes label' do
page.within "#label_#{bug_label.id}" do
click_link 'Delete'
end
page.within '.manage-labels-list' do
expect(page).not_to have_content('bug')
end
end
2018-03-17 18:26:18 +05:30
it 'deletes all labels', :js do
2017-08-17 22:00:37 +05:30
page.within '.labels' do
2021-06-08 01:23:25 +05:30
page.all('.js-remove-label').each do |remove|
2018-03-17 18:26:18 +05:30
accept_confirm { remove.click }
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
end
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2022-01-26 12:08:38 +05:30
expect(page).to have_content("Define your default set of project labels")
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content('bug')
expect(page).not_to have_content('feature_label')
end
end
describe 'create' do
before do
visit new_admin_label_path
end
it 'creates new label' do
fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#F95610'
2022-03-02 08:16:31 +05:30
click_button 'Create label'
2017-08-17 22:00:37 +05:30
page.within '.manage-labels-list' do
expect(page).to have_content('support')
end
end
it 'does not creates label with invalid color' do
fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#12'
2022-03-02 08:16:31 +05:30
click_button 'Create label'
2017-08-17 22:00:37 +05:30
page.within '.label-form' do
expect(page).to have_content('Color must be a valid color code')
end
end
it 'does not creates label if label already exists' do
fill_in 'Title', with: 'bug'
fill_in 'Background color', with: '#F95610'
2022-03-02 08:16:31 +05:30
click_button 'Create label'
2017-08-17 22:00:37 +05:30
page.within '.label-form' do
expect(page).to have_content 'Title has already been taken'
end
end
end
describe 'edit' do
it 'changes bug label' do
visit edit_admin_label_path(bug_label)
fill_in 'Title', with: 'fix'
fill_in 'Background color', with: '#F15610'
2022-03-02 08:16:31 +05:30
click_button 'Save changes'
2017-08-17 22:00:37 +05:30
page.within '.manage-labels-list' do
expect(page).to have_content('fix')
end
end
2022-03-02 08:16:31 +05:30
it 'allows user to delete label', :js do
visit edit_admin_label_path(bug_label)
click_button 'Delete'
within_modal do
expect(page).to have_content("#{bug_label.title} will be permanently deleted. This cannot be undone.")
click_link 'Delete label'
end
expect(page).to have_content('Label was removed')
end
2017-08-17 22:00:37 +05:30
end
end