2021-03-08 18:12:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Group Packages & Registries settings' do
|
|
|
|
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
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'when packges 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
|
|
|
|
|
|
|
|
expect(settings_menu).not_to have_content 'Packages & Registries'
|
|
|
|
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
|
|
|
|
expect(settings_menu).to have_content 'Packages & Registries'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a page title set' do
|
|
|
|
visit_settings_page
|
|
|
|
|
|
|
|
expect(page).to have_title _('Packages & Registries')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sidebar menu is open' do
|
|
|
|
visit_settings_page
|
|
|
|
|
|
|
|
sidebar = find('.nav-sidebar')
|
|
|
|
expect(sidebar).to have_link _('Packages & Registries')
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
it 'has a Package Registry section', :js do
|
|
|
|
visit_settings_page
|
|
|
|
|
|
|
|
expect(page).to have_content('Package Registry')
|
|
|
|
expect(page).to have_button('Collapse')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'automatically saves changes to the server', :js do
|
|
|
|
visit_settings_page
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
within '[data-testid="maven-settings"]' do
|
|
|
|
expect(page).to have_content('Allow duplicates')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
find('.gl-toggle').click
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_content('Do not allow duplicates')
|
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
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_content('Do not allow duplicates')
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error on wrong regex', :js do
|
|
|
|
visit_settings_page
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
within '[data-testid="maven-settings"]' do
|
|
|
|
expect(page).to have_content('Allow duplicates')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
find('.gl-toggle').click
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_content('Do not allow duplicates')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
fill_in 'Exceptions', with: ')'
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
# simulate blur event
|
|
|
|
find('body').click
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
within '[data-testid="maven-settings"]' do
|
|
|
|
expect(page).to have_content('Allow duplicates')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
find('.gl-toggle').click
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_content('Do not allow duplicates')
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def find_settings_menu
|
|
|
|
find('ul[data-testid="group-settings-menu"]')
|
|
|
|
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
|