Commit 28da5bc6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor dependency proxy ui specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c2720c70
...@@ -17,8 +17,10 @@ describe 'Group Dependency Proxy' do ...@@ -17,8 +17,10 @@ describe 'Group Dependency Proxy' do
end end
describe 'feature settings' do describe 'feature settings' do
context 'when not logged in' do context 'when not logged in and feature disabled' do
it 'does not show the feature settings' do it 'does not show the feature settings' do
group.create_dependency_proxy_setting(enabled: false)
visit path visit path
expect(page).not_to have_css('.js-dependency-proxy-toggle-area') expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
...@@ -26,89 +28,80 @@ describe 'Group Dependency Proxy' do ...@@ -26,89 +28,80 @@ describe 'Group Dependency Proxy' do
end end
end end
context 'when logged in as group owner' do context 'feature is available', :js do
context 'feature is available', :js do context 'when logged in as group owner' do
before do before do
sign_in(owner) sign_in(owner)
visit path visit path
end end
it 'toggles defaults to disabled' do it 'toggles defaults to enabled' do
page.within('.js-dependency-proxy-toggle-area') do page.within('.js-dependency-proxy-toggle-area') do
expect(find('.js-project-feature-toggle-input', visible: false).value).to eq('false') expect(find('.js-project-feature-toggle-input', visible: false).value).to eq('true')
end end
end end
context 'when disabled' do it 'shows the proxy URL' do
it 'does not show the proxy URL' do page.within('.edit_dependency_proxy_group_setting') do
expect(page).not_to have_css('.js-dependency-proxy-url') expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end end
end end
context 'when enabled by owner' do it 'hides the proxy URL when feature is disabled' do
before do page.within('.edit_dependency_proxy_group_setting') do
page.within('.edit_dependency_proxy_group_setting') do find('.js-project-feature-toggle').click
find('.js-project-feature-toggle').click click_button 'Save changes'
end
click_button('Save changes')
wait_for_requests
visit path
end
it 'shows the proxy URL' do
page.within('.edit_dependency_proxy_group_setting') do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end end
context 'then when logged in as group developer' do expect(page).not_to have_css('.js-dependency-proxy-url')
before do
sign_in(developer)
visit path
end
it 'does not show the feature toggle but shows the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end
end end
end end
context 'feature is not avaible' do context 'when logged in as group developer' do
before do before do
sign_in(owner) sign_in(developer)
visit path
end end
context 'group is private' do it 'does not show the feature toggle but shows the proxy URL' do
let(:group) { create(:group, :private) } expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end
end
context 'feature is not avaible' do
before do
sign_in(owner)
end
it 'informs user that feature is only available for public groups' do context 'group is private' do
visit path let(:group) { create(:group, :private) }
expect(page).to have_content('Dependency proxy feature is limited to public groups for now.') it 'informs user that feature is only available for public groups' do
end visit path
expect(page).to have_content('Dependency proxy feature is limited to public groups for now.')
end end
end
context 'feature is not supported by the license' do context 'feature is not supported by the license' do
it 'renders 404 page' do it 'renders 404 page' do
stub_licensed_features(dependency_proxy: false) stub_licensed_features(dependency_proxy: false)
visit path visit path
expect(page).to have_gitlab_http_status(404) expect(page).to have_gitlab_http_status(404)
end
end end
end
context 'feature is disabled globally' do context 'feature is disabled globally' do
it 'renders 404 page' do it 'renders 404 page' do
disable_feature disable_feature
visit path visit path
expect(page).to have_gitlab_http_status(404) expect(page).to have_gitlab_http_status(404)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment