debian-mirror-gitlab/spec/features/projects/infrastructure_registry_spec.rb

77 lines
2.4 KiB
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Infrastructure Registry' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
before do
sign_in(user)
project.add_maintainer(user)
end
2021-10-27 15:23:28 +05:30
context 'when packages registry is not enabled' do
2021-09-04 01:27:46 +05:30
before do
2021-10-27 15:23:28 +05:30
stub_config(packages: { enabled: false })
2021-09-04 01:27:46 +05:30
end
it 'gives 404' do
visit_project_infrastructure_registry
expect(status_code).to eq(404)
end
end
2021-10-27 15:23:28 +05:30
context 'when packages registry is enabled', :js do
2021-09-04 01:27:46 +05:30
before do
visit_project_infrastructure_registry
end
2021-09-30 23:02:18 +05:30
context 'when there are modules' do
2021-09-04 01:27:46 +05:30
let_it_be(:terraform_module) { create(:terraform_module_package, project: project, created_at: 1.day.ago, version: '1.0.0') }
let_it_be(:terraform_module2) { create(:terraform_module_package, project: project, created_at: 2.days.ago, version: '2.0.0') }
let_it_be(:packages) { [terraform_module, terraform_module2] }
it_behaves_like 'packages list'
2021-09-30 23:02:18 +05:30
context 'details link' do
it 'navigates to the correct url' do
page.within(packages_table_selector) do
click_link terraform_module.name
end
expect(page).to have_current_path(project_infrastructure_registry_path(terraform_module.project, terraform_module))
2021-12-11 22:18:48 +05:30
expect(page).to have_css('.packages-app h2[data-testid="title"]', text: terraform_module.name)
2021-09-30 23:02:18 +05:30
2021-11-18 22:05:49 +05:30
expect(page).to have_content('Provision instructions')
expect(page).to have_content('Registry setup')
2021-09-30 23:02:18 +05:30
end
end
2021-09-04 01:27:46 +05:30
context 'deleting a package' do
let_it_be(:project) { create(:project) }
let_it_be(:terraform_module) { create(:terraform_module_package, project: project) }
it 'allows you to delete a module', :aggregate_failures do
# this is still using the package copy in the UI too
click_button('Remove package')
click_button('Delete package')
expect(page).to have_content 'Package deleted successfully'
expect(page).not_to have_content(terraform_module.name)
end
end
end
it 'displays the empty message' do
expect(page).to have_content('You have no Terraform modules in your project')
end
end
def visit_project_infrastructure_registry
visit project_infrastructure_registry_index_path(project)
end
end