debian-mirror-gitlab/spec/features/groups/settings/packages_and_registries_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
3.1 KiB
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-10-11 01:57:18 +05:30
RSpec.describe 'Group Package and registry settings' do
2021-03-08 18:12:59 +05:30
include WaitForRequests
let(:user) { create(:user) }
let(:group) { create(:group) }
2021-03-11 19:13:27 +05:30
let(:sub_group) { create(:group, parent: group) }
2021-03-08 18:12:59 +05:30
before do
group.add_owner(user)
2021-03-11 19:13:27 +05:30
sub_group.add_owner(user)
2021-03-08 18:12:59 +05:30
sign_in(user)
end
2022-08-13 15:12:31 +05:30
context 'when packages feature is disabled on the group' do
2021-03-08 18:12:59 +05:30
before do
2021-03-11 19:13:27 +05:30
stub_packages_setting(enabled: false)
2021-03-08 18:12:59 +05:30
end
it 'the menu item is not visible' do
visit group_path(group)
settings_menu = find_settings_menu
2022-10-11 01:57:18 +05:30
expect(settings_menu).not_to have_content 'Packages and registries'
2021-03-08 18:12:59 +05:30
end
2021-03-11 19:13:27 +05:30
it 'renders 404 when navigating to page' do
visit_settings_page
expect(page).to have_content('Not Found')
end
2021-03-08 18:12:59 +05:30
end
2021-03-11 19:13:27 +05:30
context 'when packages feature is enabled on the group' do
2021-03-08 18:12:59 +05:30
it 'the menu item is visible' do
visit group_path(group)
settings_menu = find_settings_menu
2022-10-11 01:57:18 +05:30
expect(settings_menu).to have_content 'Packages and registries'
2021-03-08 18:12:59 +05:30
end
it 'has a page title set' do
visit_settings_page
2022-10-11 01:57:18 +05:30
expect(page).to have_title _('Package and registry settings')
2021-03-08 18:12:59 +05:30
end
it 'sidebar menu is open' do
visit_settings_page
sidebar = find('.nav-sidebar')
2022-10-11 01:57:18 +05:30
expect(sidebar).to have_link _('Packages and registries')
2021-03-08 18:12:59 +05:30
end
2021-03-11 19:13:27 +05:30
2022-08-13 15:12:31 +05:30
it 'has a Duplicate packages section', :js do
2021-03-11 19:13:27 +05:30
visit_settings_page
2022-08-13 15:12:31 +05:30
expect(page).to have_content('Duplicate packages')
2022-10-11 01:57:18 +05:30
expect(page).to have_content('Allow duplicates')
expect(page).to have_content('Exceptions')
2021-03-11 19:13:27 +05:30
end
it 'automatically saves changes to the server', :js do
visit_settings_page
2022-10-11 01:57:18 +05:30
wait_for_requests
2021-03-11 19:13:27 +05:30
2021-06-08 01:23:25 +05:30
within '[data-testid="maven-settings"]' do
2022-10-11 01:57:18 +05:30
expect(page).to have_field _('Exceptions'), disabled: true
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
click_button class: 'gl-toggle'
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
expect(page).to have_field _('Exceptions'), disabled: false
2021-03-11 19:13:27 +05:30
2021-06-08 01:23:25 +05:30
visit_settings_page
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
expect(page).to have_field _('Exceptions'), disabled: false
2021-06-08 01:23:25 +05:30
end
2021-03-11 19:13:27 +05:30
end
it 'shows an error on wrong regex', :js do
visit_settings_page
2022-10-11 01:57:18 +05:30
wait_for_requests
2021-03-11 19:13:27 +05:30
2021-06-08 01:23:25 +05:30
within '[data-testid="maven-settings"]' do
2022-10-11 01:57:18 +05:30
click_button class: 'gl-toggle'
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
fill_in _('Exceptions'), with: ')'
2021-11-11 11:23:49 +05:30
# simulate blur event
2022-10-11 01:57:18 +05:30
send_keys(:tab)
2021-06-08 01:23:25 +05:30
end
2021-03-11 19:13:27 +05:30
expect(page).to have_content('is an invalid regexp')
end
context 'in a sub group' do
it 'works correctly', :js do
visit_sub_group_settings_page
2022-10-11 01:57:18 +05:30
wait_for_requests
2021-03-11 19:13:27 +05:30
2021-06-08 01:23:25 +05:30
within '[data-testid="maven-settings"]' do
2022-10-11 01:57:18 +05:30
expect(page).to have_content('Allow duplicates')
expect(page).to have_field _('Exceptions'), disabled: true
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
click_button class: 'gl-toggle'
2021-03-11 19:13:27 +05:30
2022-10-11 01:57:18 +05:30
expect(page).to have_field _('Exceptions'), disabled: false
2021-06-08 01:23:25 +05:30
end
2021-03-11 19:13:27 +05:30
end
end
2021-03-08 18:12:59 +05:30
end
def find_settings_menu
2021-10-27 15:23:28 +05:30
find('.shortcuts-settings ul')
2021-03-08 18:12:59 +05:30
end
def visit_settings_page
visit group_settings_packages_and_registries_path(group)
end
2021-03-11 19:13:27 +05:30
def visit_sub_group_settings_page
visit group_settings_packages_and_registries_path(sub_group)
end
2021-03-08 18:12:59 +05:30
end