2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-09 16:32:18 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-07-12 05:27:23 -04:00
|
|
|
describe 'Container Registry', :js do
|
2017-04-03 04:38:37 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-04-03 04:38:37 -04:00
|
|
|
|
|
|
|
let(:container_repository) do
|
|
|
|
create(:container_repository, name: 'my/image')
|
|
|
|
end
|
2016-05-09 16:32:18 -04:00
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-04-03 04:38:37 -04:00
|
|
|
project.add_developer(user)
|
2016-05-16 19:07:49 -04:00
|
|
|
stub_container_registry_config(enabled: true)
|
2017-04-03 09:52:24 -04:00
|
|
|
stub_container_registry_tags(repository: :any, tags: [])
|
2020-02-10 10:08:54 -05:00
|
|
|
stub_feature_flags(vue_container_registry_explorer: false)
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
|
|
|
|
2019-10-07 17:07:54 -04:00
|
|
|
it 'has a page title set' do
|
|
|
|
visit_container_registry
|
|
|
|
expect(page).to have_title(_('Container Registry'))
|
|
|
|
end
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
context 'when there are no image repositories' do
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user visits container registry main page' do
|
2017-04-03 04:38:37 -04:00
|
|
|
visit_container_registry
|
2016-05-12 14:03:04 -04:00
|
|
|
|
2019-07-02 09:12:45 -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
|
|
|
|
|
2017-04-03 04:38:37 -04:00
|
|
|
context 'when there are image repositories' do
|
2016-12-15 22:24:05 -05:00
|
|
|
before do
|
2019-01-10 09:22:58 -05:00
|
|
|
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest], with_manifest: true)
|
2017-04-03 04:38:37 -04:00
|
|
|
project.container_repositories << container_repository
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user wants to see multi-level container repository' do
|
2017-04-03 04:38:37 -04:00
|
|
|
visit_container_registry
|
|
|
|
|
|
|
|
expect(page).to have_content('my/image')
|
2016-12-15 22:24:05 -05:00
|
|
|
end
|
|
|
|
|
2019-10-23 05:06:03 -04:00
|
|
|
it 'user removes entire container repository', :sidekiq_might_not_need_inline do
|
2017-04-03 04:38:37 -04:00
|
|
|
visit_container_registry
|
|
|
|
|
2019-07-12 05:27:23 -04:00
|
|
|
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')
|
2019-06-21 14:29:11 -04:00
|
|
|
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
|
2017-04-03 04:38:37 -04:00
|
|
|
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
|
|
|
|
|
2019-09-19 07:50:12 -04:00
|
|
|
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
|
|
|
|
2019-07-12 05:27:23 -04:00
|
|
|
click_on(class: 'js-delete-registry-row', visible: false)
|
2019-10-04 20:05:59 -04:00
|
|
|
expect(find('.modal .modal-title')).to have_content 'Remove tag'
|
2019-06-21 14:29:11 -04:00
|
|
|
find('.modal .modal-footer .btn-danger').click
|
2016-05-09 16:32:18 -04:00
|
|
|
end
|
|
|
|
end
|
2017-04-03 04:38:37 -04:00
|
|
|
|
|
|
|
def visit_container_registry
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_container_registry_index_path(project)
|
2017-04-03 04:38:37 -04:00
|
|
|
end
|
2016-05-12 14:03:04 -04:00
|
|
|
end
|