Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/explore')
-rw-r--r--spec/features/explore/catalog/catalog_details_spec.rb48
-rw-r--r--spec/features/explore/catalog/catalog_releases_spec.rb111
-rw-r--r--spec/features/explore/catalog/catalog_settings_spec.rb93
-rw-r--r--spec/features/explore/catalog/catalog_spec.rb182
4 files changed, 341 insertions, 93 deletions
diff --git a/spec/features/explore/catalog/catalog_details_spec.rb b/spec/features/explore/catalog/catalog_details_spec.rb
new file mode 100644
index 00000000000..8def565ac01
--- /dev/null
+++ b/spec/features/explore/catalog/catalog_details_spec.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'CI/CD Catalog details page', :js, feature_category: :pipeline_composition do
+ let_it_be(:namespace) { create(:group) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :public, :repository, namespace: namespace) }
+
+ shared_examples_for 'has correct viewing permissions' do
+ context 'when the resource is published' do
+ let(:published_catalog_resource) { create(:ci_catalog_resource, :published, project: project) }
+
+ before do
+ visit explore_catalog_path(published_catalog_resource)
+ end
+
+ it 'navigates to the details page' do
+ expect(page).to have_content('Go to the project')
+ end
+ end
+
+ context 'when the resource is not published' do
+ let(:draft_catalog_resource) { create(:ci_catalog_resource, project: project, state: :draft) }
+
+ before do
+ visit explore_catalog_path(draft_catalog_resource)
+ end
+
+ it 'returns a 404' do
+ expect(page).to have_title('Not Found')
+ expect(page).to have_content('Page Not Found')
+ end
+ end
+ end
+
+ context 'when authenticated' do
+ before do
+ sign_in(user)
+ end
+
+ it_behaves_like 'has correct viewing permissions'
+ end
+
+ context 'when unauthenticated' do
+ it_behaves_like 'has correct viewing permissions'
+ end
+end
diff --git a/spec/features/explore/catalog/catalog_releases_spec.rb b/spec/features/explore/catalog/catalog_releases_spec.rb
new file mode 100644
index 00000000000..27b7aa17551
--- /dev/null
+++ b/spec/features/explore/catalog/catalog_releases_spec.rb
@@ -0,0 +1,111 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'CI/CD Catalog releases', :js, feature_category: :pipeline_composition do
+ let_it_be(:tag_name) { 'catalog_release_tag' }
+ let_it_be(:user) { create(:user) }
+ let_it_be_with_reload(:namespace) { create(:group) }
+ let_it_be_with_reload(:project) do
+ create(
+ :project,
+ :catalog_resource_with_components,
+ description: 'Brand new thing',
+ namespace: namespace
+ )
+ end
+
+ let_it_be(:draft_catalog_resource) do
+ create(:ci_catalog_resource, project: project)
+ end
+
+ before_all do
+ namespace.add_owner(user)
+ end
+
+ before do
+ sign_in(user)
+ end
+
+ context 'when a resource is in draft' do
+ it 'does not render it in the Catalog', :aggregate_failures do
+ visit explore_catalog_index_path
+
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(0)
+ expect(page).not_to have_content(project.name)
+ end
+ end
+
+ describe 'when releasing a Catalog resource' do
+ before do
+ visit new_project_tag_path(project)
+ fill_in('tag_name', with: tag_name)
+ click_button 'Create tag'
+
+ # Click on the option to create release from the tags page
+ find('a', text: 'Create release').click
+
+ # Makes the actual release
+ click_button 'Create release'
+ wait_for_requests
+
+ visit explore_catalog_index_path
+ end
+
+ it 'appears in the CI/CD Catalog', :aggregate_failures do
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(1)
+ within_testid('catalog-list-container') do
+ expect(page).to have_content(project.name)
+ expect(page).to have_content(tag_name)
+ expect(page).to have_content("Released")
+ end
+
+ visit explore_catalog_path(draft_catalog_resource)
+
+ expect(page).to have_content("Last release at")
+ expect(page).to have_content(tag_name)
+ end
+ end
+
+ describe 'when a resource has multiple releases' do
+ let_it_be(:project_with_components) do
+ create(
+ :project,
+ :catalog_resource_with_components,
+ description: 'Brand new thing',
+ namespace: namespace
+ )
+ end
+
+ let_it_be(:ci_resource) do
+ create(:ci_catalog_resource, :published, project: project_with_components)
+ end
+
+ let_it_be(:old_tag_name) { 'v0.5' }
+ let_it_be(:new_tag_name) { 'v1.0' }
+
+ let_it_be(:release_1) do
+ create(:release, :with_catalog_resource_version, project: project_with_components, tag: old_tag_name,
+ author: user)
+ end
+
+ let_it_be(:release_2) do
+ create(:release, :with_catalog_resource_version, project: project_with_components, tag: new_tag_name,
+ author: user)
+ end
+
+ it 'renders the last version on the catalog list item' do
+ visit explore_catalog_index_path
+
+ expect(page).to have_content(release_2.tag)
+ expect(page).not_to have_content(release_1.tag)
+ end
+
+ it 'renders the last version on the catalog details page' do
+ visit explore_catalog_path(ci_resource)
+
+ expect(page).to have_content(release_2.tag)
+ expect(page).not_to have_content(release_1.tag)
+ end
+ end
+end
diff --git a/spec/features/explore/catalog/catalog_settings_spec.rb b/spec/features/explore/catalog/catalog_settings_spec.rb
index bf324eafd7f..edaa8951a27 100644
--- a/spec/features/explore/catalog/catalog_settings_spec.rb
+++ b/spec/features/explore/catalog/catalog_settings_spec.rb
@@ -5,13 +5,22 @@ require 'spec_helper'
RSpec.describe 'CI/CD Catalog settings', :js, feature_category: :pipeline_composition do
let_it_be(:user) { create(:user) }
let_it_be_with_reload(:namespace) { create(:group) }
- let_it_be_with_reload(:new_project) { create(:project, :repository, namespace: namespace) }
+ let_it_be_with_reload(:project_with_ci_components) do
+ create(
+ :project,
+ :catalog_resource_with_components,
+ description: "catalog resource description",
+ namespace: namespace
+ )
+ end
context 'when user is not the owner' do
+ before_all do
+ namespace.add_maintainer(user)
+ end
+
before do
sign_in(user)
- visit edit_project_path(new_project)
- wait_for_requests
end
it 'does not show the CI/CD toggle settings' do
@@ -29,50 +38,96 @@ RSpec.describe 'CI/CD Catalog settings', :js, feature_category: :pipeline_compos
end
it 'shows the CI/CD toggle settings' do
- visit edit_project_path(new_project)
+ visit edit_project_path(project_with_ci_components)
wait_for_requests
expect(page).to have_content('CI/CD Catalog resource')
end
- describe 'when setting a project as a Catalog resource' do
+ context 'when a project is not a Catalog resource' do
before do
- visit project_path(new_project)
- wait_for_requests
+ visit project_path(project_with_ci_components)
end
- it 'adds the project to the CI/CD Catalog' do
+ it 'does not render the CI/CD resource badge' do
+ expect(page).to have_content(project_with_ci_components.name)
expect(page).not_to have_content('CI/CD catalog resource')
+ end
+ end
- visit edit_project_path(new_project)
+ describe 'when listing a project as a Catalog resource' do
+ let_it_be(:tag_name) { 'v0.1' }
+ before do
+ visit edit_project_path(project_with_ci_components)
find('[data-testid="catalog-resource-toggle"] button').click
+ wait_for_requests
+ end
- visit project_path(new_project)
+ it 'marks the project as a CI/CD Catalog' do
+ visit project_path(project_with_ci_components)
expect(page).to have_content('CI/CD catalog resource')
end
+
+ context 'and there are no releases' do
+ before do
+ visit explore_catalog_index_path
+ end
+
+ it 'does not add the resource to the catalog', :aggregate_failures do
+ expect(page).to have_content("CI/CD Catalog")
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(0)
+ end
+ end
+
+ context 'and there is a release' do
+ before do
+ create(:release, :with_catalog_resource_version, tag: tag_name, author: user,
+ project: project_with_ci_components)
+ # This call to `publish` is necessary to simulate what creating a release would really do
+ project_with_ci_components.catalog_resource.publish!
+ visit explore_catalog_index_path
+ end
+
+ it 'adds the resource to the catalog', :aggregate_failures do
+ expect(page).to have_content("CI/CD Catalog")
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(1)
+ expect(page).to have_content(tag_name)
+ end
+ end
end
describe 'when unlisting a project from the CI/CD Catalog' do
before do
- create(:ci_catalog_resource, project: new_project, state: :published)
- visit project_path(new_project)
- wait_for_requests
- end
+ create(:ci_catalog_resource, project: project_with_ci_components)
+ create(:release, :with_catalog_resource_version, tag: 'v0.1', author: user, project: project_with_ci_components)
+ project_with_ci_components.catalog_resource.publish!
- it 'removes the project to the CI/CD Catalog' do
- expect(page).to have_content('CI/CD catalog resource')
-
- visit edit_project_path(new_project)
+ visit edit_project_path(project_with_ci_components)
find('[data-testid="catalog-resource-toggle"] button').click
click_button 'Remove from the CI/CD catalog'
+ end
- visit project_path(new_project)
+ it 'removes the CI/CD Catalog tag on the project' do
+ visit project_path(project_with_ci_components)
expect(page).not_to have_content('CI/CD catalog resource')
end
+
+ it 'removes the resource from the catalog' do
+ visit explore_catalog_index_path
+
+ expect(page).not_to have_content(project_with_ci_components.name)
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(0)
+ end
+
+ it 'does not destroy existing releases' do
+ visit project_releases_path(project_with_ci_components)
+
+ expect(page).to have_content(project_with_ci_components.releases.last.name)
+ end
end
end
end
diff --git a/spec/features/explore/catalog/catalog_spec.rb b/spec/features/explore/catalog/catalog_spec.rb
index 00bbb02ebbf..1ad0e9679b8 100644
--- a/spec/features/explore/catalog/catalog_spec.rb
+++ b/spec/features/explore/catalog/catalog_spec.rb
@@ -5,52 +5,123 @@ require 'spec_helper'
RSpec.describe 'CI/CD Catalog', :js, feature_category: :pipeline_composition do
let_it_be(:namespace) { create(:group) }
let_it_be(:user) { create(:user) }
+ let_it_be(:public_projects_with_components) do
+ create_list(
+ :project,
+ 3,
+ :catalog_resource_with_components,
+ :public,
+ description: 'A simple component',
+ namespace: namespace
+ )
+ end
before_all do
- namespace.add_developer(user)
+ public_projects_with_components.map do |current_project|
+ create(:ci_catalog_resource, :published, project: current_project)
+ end
end
- before do
- sign_in(user)
- end
+ shared_examples 'basic page viewing' do
+ it 'shows CI Catalog title and description', :aggregate_failures do
+ expect(page).to have_content('CI/CD Catalog')
+ expect(page).to have_content(
+ 'Discover CI/CD components that can improve your pipeline with additional functionality'
+ )
+ end
- describe 'GET explore/catalog' do
- let_it_be(:project) { create(:project, :repository, namespace: namespace) }
+ it 'renders CI Catalog resources list' do
+ expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3)
+ end
- let_it_be(:ci_resource_projects) do
- create_list(
- :project,
- 3,
- :repository,
- description: 'A simple component',
- namespace: namespace
- )
+ it 'renders resource details', :aggregate_failures do
+ within_testid('catalog-resource-item', match: :first) do
+ expect(page).to have_content(public_projects_with_components[2].name)
+ expect(page).to have_content(public_projects_with_components[2].description)
+ expect(page).to have_content(namespace.name)
+ end
end
+ end
- let_it_be(:ci_catalog_resources) do
- ci_resource_projects.map do |current_project|
- create(:ci_catalog_resource, :published, project: current_project)
+ shared_examples 'navigates to the details page' do
+ context 'when clicking on a resource' do
+ before do
+ find_by_testid('ci-resource-link', match: :first).click
+ end
+
+ it 'navigates to the details page' do
+ expect(page).to have_content('Go to the project')
end
end
+ end
+ context 'when unauthenticated' do
before do
visit explore_catalog_index_path
- wait_for_requests
end
- it 'shows CI Catalog title and description', :aggregate_failures do
- expect(page).to have_content('CI/CD Catalog')
- expect(page).to have_content(
- 'Discover CI/CD components that can improve your pipeline with additional functionality'
+ it_behaves_like 'basic page viewing'
+ it_behaves_like 'navigates to the details page'
+ end
+
+ context 'when authenticated' do
+ before do
+ sign_in(user)
+ visit explore_catalog_index_path
+ end
+
+ it_behaves_like 'basic page viewing'
+ it_behaves_like 'navigates to the details page'
+ end
+
+ context 'for private catalog resources' do
+ let_it_be(:private_project) do
+ create(
+ :project,
+ :catalog_resource_with_components,
+ description: 'Our private project',
+ namespace: namespace
)
end
- it 'renders CI Catalog resources list' do
- expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3)
+ let_it_be(:catalog_resource) { create(:ci_catalog_resource, :published, project: private_project) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:browsing_user) { create(:user) }
+
+ context 'when browsing as a developer + member' do
+ before_all do
+ namespace.add_developer(developer)
+ end
+
+ before do
+ sign_in(developer)
+ visit explore_catalog_index_path
+ end
+
+ it 'shows the catalog resource' do
+ expect(page).to have_content(private_project.name)
+ end
+ end
+
+ context 'when browsing as a non-member of the project' do
+ before do
+ sign_in(browsing_user)
+ visit explore_catalog_index_path
+ end
+
+ it 'does not show the catalog resource' do
+ expect(page).not_to have_content(private_project.name)
+ end
+ end
+ end
+
+ describe 'Search and sorting' do
+ before do
+ visit explore_catalog_index_path
end
context 'when searching for a resource' do
- let(:project_name) { ci_resource_projects[0].name }
+ let(:project_name) { public_projects_with_components[0].name }
before do
find('input[data-testid="catalog-search-bar"]').send_keys project_name
@@ -70,8 +141,12 @@ RSpec.describe 'CI/CD Catalog', :js, feature_category: :pipeline_composition do
context 'with the creation date option' do
it 'sorts resources from last to first by default' do
expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3)
- expect(find_all('[data-testid="catalog-resource-item"]')[0]).to have_content(ci_resource_projects[2].name)
- expect(find_all('[data-testid="catalog-resource-item"]')[2]).to have_content(ci_resource_projects[0].name)
+ expect(find_all('[data-testid="catalog-resource-item"]')[0]).to have_content(
+ public_projects_with_components[2].name
+ )
+ expect(find_all('[data-testid="catalog-resource-item"]')[2]).to have_content(
+ public_projects_with_components[0].name
+ )
end
context 'when changing the sort direction' do
@@ -82,56 +157,15 @@ RSpec.describe 'CI/CD Catalog', :js, feature_category: :pipeline_composition do
it 'sorts resources from first to last' do
expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3)
- expect(find_all('[data-testid="catalog-resource-item"]')[0]).to have_content(ci_resource_projects[0].name)
- expect(find_all('[data-testid="catalog-resource-item"]')[2]).to have_content(ci_resource_projects[2].name)
+ expect(find_all('[data-testid="catalog-resource-item"]')[0]).to have_content(
+ public_projects_with_components[0].name
+ )
+ expect(find_all('[data-testid="catalog-resource-item"]')[2]).to have_content(
+ public_projects_with_components[2].name
+ )
end
end
end
end
-
- context 'for a single CI/CD catalog resource' do
- it 'renders resource details', :aggregate_failures do
- within_testid('catalog-resource-item', match: :first) do
- expect(page).to have_content(ci_resource_projects[2].name)
- expect(page).to have_content(ci_resource_projects[2].description)
- expect(page).to have_content(namespace.name)
- end
- end
-
- context 'when clicked' do
- before do
- find_by_testid('ci-resource-link', match: :first).click
- end
-
- it 'navigates to the details page' do
- expect(page).to have_content('Go to the project')
- end
- end
- end
- end
-
- describe 'GET explore/catalog/:id' do
- let_it_be(:project) { create(:project, :repository, namespace: namespace) }
-
- before do
- visit explore_catalog_path(new_ci_resource)
- end
-
- context 'when the resource is published' do
- let(:new_ci_resource) { create(:ci_catalog_resource, :published, project: project) }
-
- it 'navigates to the details page' do
- expect(page).to have_content('Go to the project')
- end
- end
-
- context 'when the resource is not published' do
- let(:new_ci_resource) { create(:ci_catalog_resource, project: project, state: :draft) }
-
- it 'returns a 404' do
- expect(page).to have_title('Not Found')
- expect(page).to have_content('Page Not Found')
- end
- end
end
end