gitlab-org--gitlab-foss/spec/features/container_registry_spec.rb

76 lines
2.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-05-09 16:32:18 -04:00
require 'spec_helper'
describe 'Container Registry', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:container_repository) do
create(:container_repository, name: 'my/image')
end
2016-05-09 16:32:18 -04:00
before do
sign_in(user)
project.add_developer(user)
2016-05-16 19:07:49 -04:00
stub_container_registry_config(enabled: true)
stub_container_registry_tags(repository: :any, tags: [])
stub_feature_flags(vue_container_registry_explorer: false)
2016-05-09 16:32:18 -04:00
end
it 'has a page title set' do
visit_container_registry
expect(page).to have_title(_('Container Registry'))
end
context 'when there are no image repositories' do
2018-07-05 02:32:05 -04:00
it 'user visits container registry main page' do
visit_container_registry
2016-05-12 14:03:04 -04:00
expect(page).to have_content 'no container images'
2016-05-09 16:32:18 -04:00
end
2016-12-15 22:24:05 -05:00
end
context 'when there are image repositories' do
2016-12-15 22:24:05 -05:00
before do
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest], with_manifest: true)
project.container_repositories << container_repository
end
2018-07-05 02:32:05 -04:00
it 'user wants to see multi-level container repository' do
visit_container_registry
expect(page).to have_content('my/image')
2016-12-15 22:24:05 -05:00
end
it 'user removes entire container repository', :sidekiq_might_not_need_inline do
visit_container_registry
expect_any_instance_of(ContainerRepository).to receive(:delete_tags!).and_return(true)
2016-05-09 16:32:18 -04:00
2017-10-03 06:20:18 -04:00
click_on(class: 'js-remove-repo')
expect(find('.modal .modal-title')).to have_content 'Remove repository'
find('.modal .modal-footer .btn-danger').click
2016-05-09 16:32:18 -04:00
end
2018-07-05 02:32:05 -04:00
it 'user removes a specific tag from container repository' do
visit_container_registry
2016-05-09 16:32:18 -04:00
2017-10-09 16:17:24 -04:00
find('.js-toggle-repo').click
2017-10-03 06:20:18 -04:00
wait_for_requests
service = double('service')
expect(service).to receive(:execute).with(container_repository) { { status: :success } }
expect(Projects::ContainerRepository::DeleteTagsService).to receive(:new).with(container_repository.project, user, tags: ['latest']) { service }
2016-05-12 14:03:04 -04:00
click_on(class: 'js-delete-registry-row', visible: false)
expect(find('.modal .modal-title')).to have_content 'Remove tag'
find('.modal .modal-footer .btn-danger').click
2016-05-09 16:32:18 -04:00
end
end
def visit_container_registry
visit project_container_registry_index_path(project)
end
2016-05-12 14:03:04 -04:00
end