diff options
Diffstat (limited to 'spec/features/explore')
-rw-r--r-- | spec/features/explore/catalog/catalog_settings_spec.rb | 78 | ||||
-rw-r--r-- | spec/features/explore/catalog/catalog_spec.rb | 137 | ||||
-rw-r--r-- | spec/features/explore/catalog_spec.rb | 80 | ||||
-rw-r--r-- | spec/features/explore/navbar_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/explore/user_explores_projects_spec.rb | 2 |
5 files changed, 216 insertions, 93 deletions
diff --git a/spec/features/explore/catalog/catalog_settings_spec.rb b/spec/features/explore/catalog/catalog_settings_spec.rb new file mode 100644 index 00000000000..bf324eafd7f --- /dev/null +++ b/spec/features/explore/catalog/catalog_settings_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +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) } + + context 'when user is not the owner' do + 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 + expect(page).not_to have_content('CI/CD Catalog resource') + end + end + + context 'when user is the owner' do + before_all do + namespace.add_owner(user) + end + + before do + sign_in(user) + end + + it 'shows the CI/CD toggle settings' do + visit edit_project_path(new_project) + wait_for_requests + + expect(page).to have_content('CI/CD Catalog resource') + end + + describe 'when setting a project as a Catalog resource' do + before do + visit project_path(new_project) + wait_for_requests + end + + it 'adds the project to the CI/CD Catalog' do + expect(page).not_to have_content('CI/CD catalog resource') + + visit edit_project_path(new_project) + + find('[data-testid="catalog-resource-toggle"] button').click + + visit project_path(new_project) + + expect(page).to have_content('CI/CD catalog resource') + 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 + + 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) + + find('[data-testid="catalog-resource-toggle"] button').click + click_button 'Remove from the CI/CD catalog' + + visit project_path(new_project) + + expect(page).not_to have_content('CI/CD catalog resource') + end + end + end +end diff --git a/spec/features/explore/catalog/catalog_spec.rb b/spec/features/explore/catalog/catalog_spec.rb new file mode 100644 index 00000000000..00bbb02ebbf --- /dev/null +++ b/spec/features/explore/catalog/catalog_spec.rb @@ -0,0 +1,137 @@ +# frozen_string_literal: true + +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) } + + before_all do + namespace.add_developer(user) + end + + before do + sign_in(user) + end + + describe 'GET explore/catalog' do + let_it_be(:project) { create(:project, :repository, namespace: namespace) } + + let_it_be(:ci_resource_projects) do + create_list( + :project, + 3, + :repository, + description: 'A simple component', + namespace: namespace + ) + end + + let_it_be(:ci_catalog_resources) do + ci_resource_projects.map do |current_project| + create(:ci_catalog_resource, :published, project: current_project) + end + end + + 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' + ) + end + + it 'renders CI Catalog resources list' do + expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3) + end + + context 'when searching for a resource' do + let(:project_name) { ci_resource_projects[0].name } + + before do + find('input[data-testid="catalog-search-bar"]').send_keys project_name + find('input[data-testid="catalog-search-bar"]').send_keys :enter + wait_for_requests + end + + it 'renders only a subset of items' do + expect(find_all('[data-testid="catalog-resource-item"]').length).to be(1) + within_testid('catalog-resource-item', match: :first) do + expect(page).to have_content(project_name) + end + end + end + + context 'when sorting' 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) + end + + context 'when changing the sort direction' do + before do + find('.sorting-direction-button').click + wait_for_requests + end + + 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) + 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 diff --git a/spec/features/explore/catalog_spec.rb b/spec/features/explore/catalog_spec.rb deleted file mode 100644 index 52ce52e43fe..00000000000 --- a/spec/features/explore/catalog_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Global Catalog', :js, feature_category: :pipeline_composition do - let_it_be(:namespace) { create(:group) } - let_it_be(:user) { create(:user) } - - before_all do - namespace.add_developer(user) - end - - before do - sign_in(user) - end - - describe 'GET explore/catalog' do - let_it_be(:project) { create(:project, :repository, namespace: namespace) } - let_it_be(:ci_resource_projects) do - create_list( - :project, - 3, - :repository, - description: 'A simple component', - namespace: namespace - ) - end - - before do - ci_resource_projects.each do |current_project| - create(:ci_catalog_resource, project: current_project) - end - - 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 configuration resources for a seamless CI/CD experience.') - end - - it 'renders CI Catalog resources list' do - expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3) - 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 'navigate 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) } - let_it_be(:new_ci_resource) { create(:ci_catalog_resource, project: project) } - - before do - visit explore_catalog_path(id: new_ci_resource["id"]) - end - - it 'navigates to the details page' do - expect(page).to have_content('Go to the project') - end - end -end diff --git a/spec/features/explore/navbar_spec.rb b/spec/features/explore/navbar_spec.rb index c172760eb2c..f8fe9bc9af3 100644 --- a/spec/features/explore/navbar_spec.rb +++ b/spec/features/explore/navbar_spec.rb @@ -7,19 +7,7 @@ RSpec.describe '"Explore" navbar', :js, feature_category: :navigation do it_behaves_like 'verified navigation bar' do before do - stub_feature_flags(global_ci_catalog: false) visit explore_projects_path end end - - context "with 'global_ci_catalog' enabled" do - include_context '"Explore" navbar structure with global_ci_catalog FF' - - it_behaves_like 'verified navigation bar', global_ci_catalog: true do - before do - stub_feature_flags(global_ci_catalog: true) - visit explore_projects_path - end - end - end end diff --git a/spec/features/explore/user_explores_projects_spec.rb b/spec/features/explore/user_explores_projects_spec.rb index e1341824bfd..369297ff04a 100644 --- a/spec/features/explore/user_explores_projects_spec.rb +++ b/spec/features/explore/user_explores_projects_spec.rb @@ -25,7 +25,7 @@ RSpec.describe 'User explores projects', feature_category: :user_profile do describe 'breadcrumbs' do it 'has "Explore" as its root breadcrumb' do - within '.breadcrumbs-list li:first' do + within '.gl-breadcrumb-list li:first' do expect(page).to have_link('Explore', href: explore_root_path) end end |