diff --git a/.rubocop_todo/rspec/before_all_role_assignment.yml b/.rubocop_todo/rspec/before_all_role_assignment.yml index a39743664aa67d9e026ab55f67dfaa628b6b6491..8e1a2a28f1f16c0fc7ca3bd81f9950d4855c379d 100644 --- a/.rubocop_todo/rspec/before_all_role_assignment.yml +++ b/.rubocop_todo/rspec/before_all_role_assignment.yml @@ -68,7 +68,6 @@ RSpec/BeforeAllRoleAssignment: - 'ee/spec/features/boards/sidebar_spec.rb' - 'ee/spec/features/boards/swimlanes/epics_swimlanes_sidebar_spec.rb' - 'ee/spec/features/burnup_charts_spec.rb' - - 'ee/spec/features/ci/ci_catalog_spec.rb' - 'ee/spec/features/dashboards/todos_spec.rb' - 'ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb' - 'ee/spec/features/epic_boards/epic_boards_spec.rb' @@ -265,7 +264,6 @@ RSpec/BeforeAllRoleAssignment: - 'ee/spec/graphql/types/vulnerability_response_type_spec.rb' - 'ee/spec/graphql/types/vulnerability_scanner_type_spec.rb' - 'ee/spec/graphql/types/vulnerability_type_spec.rb' - - 'ee/spec/helpers/ee/ci/catalog/resources_helper_spec.rb' - 'ee/spec/helpers/ee/ci/pipeline_editor_helper_spec.rb' - 'ee/spec/helpers/ee/environments_helper_spec.rb' - 'ee/spec/helpers/ee/groups_helper_spec.rb' @@ -552,7 +550,6 @@ RSpec/BeforeAllRoleAssignment: - 'ee/spec/requests/jwt_controller_spec.rb' - 'ee/spec/requests/lfs_locks_api_spec.rb' - 'ee/spec/requests/projects/analytics/cycle_analytics/stages_controller_spec.rb' - - 'ee/spec/requests/projects/ci/catalog/resources_controller_spec.rb' - 'ee/spec/requests/projects/dependencies_controller_spec.rb' - 'ee/spec/requests/projects/issues_controller_spec.rb' - 'ee/spec/requests/projects/on_demand_scans_controller_spec.rb' diff --git a/.rubocop_todo/rspec/named_subject.yml b/.rubocop_todo/rspec/named_subject.yml index 79afdfa04f69fe674c41560b3841f94e8fb5c92d..2c77a52579c53e960ade52c98fb5fc5b08f415ca 100644 --- a/.rubocop_todo/rspec/named_subject.yml +++ b/.rubocop_todo/rspec/named_subject.yml @@ -193,7 +193,6 @@ RSpec/NamedSubject: - 'ee/spec/helpers/compliance_management/compliance_framework/group_settings_helper_spec.rb' - 'ee/spec/helpers/ee/auth_helper_spec.rb' - 'ee/spec/helpers/ee/branches_helper_spec.rb' - - 'ee/spec/helpers/ee/ci/catalog/resources_helper_spec.rb' - 'ee/spec/helpers/ee/ci/runners_helper_spec.rb' - 'ee/spec/helpers/ee/emails_helper_spec.rb' - 'ee/spec/helpers/ee/environments_helper_spec.rb' diff --git a/.rubocop_todo/style/inline_disable_annotation.yml b/.rubocop_todo/style/inline_disable_annotation.yml index 98690775f3c9d08288f5166e7d1ed65fd1b2c80e..473378c24fb7858dcbb8fe6d994478cfccb8097a 100644 --- a/.rubocop_todo/style/inline_disable_annotation.yml +++ b/.rubocop_todo/style/inline_disable_annotation.yml @@ -1986,7 +1986,6 @@ Style/InlineDisableAnnotation: - 'ee/spec/features/trials/saas/creation_with_one_existing_namespace_flow_spec.rb' - 'ee/spec/finders/audit_event_finder_spec.rb' - 'ee/spec/finders/ee/group_members_finder_spec.rb' - - 'ee/spec/frontend/fixtures/ci_catalog_resources.rb' - 'ee/spec/helpers/analytics/analytics_dashboards_helper_spec.rb' - 'ee/spec/helpers/ee/dashboard_helper_spec.rb' - 'ee/spec/helpers/ee/releases_helper_spec.rb' diff --git a/ee/app/assets/javascripts/ci/catalog/ci_namespace_catalog_app.vue b/ee/app/assets/javascripts/ci/catalog/ci_namespace_catalog_app.vue deleted file mode 100644 index f9c3f841008325ada7e144646124624716d39cf4..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/ci/catalog/ci_namespace_catalog_app.vue +++ /dev/null @@ -1,12 +0,0 @@ -<script> -import CiCatalogHome from '~/ci/catalog/components/ci_catalog_home.vue'; - -export default { - components: { - CiCatalogHome, - }, -}; -</script> -<template> - <ci-catalog-home /> -</template> diff --git a/ee/app/assets/javascripts/ci/catalog/components/pages/ci_resources_page.vue b/ee/app/assets/javascripts/ci/catalog/components/pages/ci_resources_page.vue deleted file mode 100644 index 13c47b33ed750445c883fdf79cdd2c6eeeb0aa52..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/ci/catalog/components/pages/ci_resources_page.vue +++ /dev/null @@ -1,114 +0,0 @@ -<script> -import { createAlert } from '~/alert'; -import { s__ } from '~/locale'; -import CatalogHeader from '~/ci/catalog/components/list/catalog_header.vue'; -import CatalogListSkeletonLoader from '~/ci/catalog/components/list/catalog_list_skeleton_loader.vue'; -import CiResourcesList from '~/ci/catalog/components/list/ci_resources_list.vue'; -import EmptyState from '~/ci/catalog/components/list/empty_state.vue'; -import { ciCatalogResourcesItemsCount } from '~/ci/catalog/graphql/settings'; -import getNamespaceCatalogResources from '../../graphql/queries/get_namespace_catalog_resources.query.graphql'; - -export default { - components: { - CatalogHeader, - CatalogListSkeletonLoader, - CiResourcesList, - EmptyState, - }, - inject: ['projectFullPath'], - data() { - return { - catalogResources: [], - currentPage: 1, - totalCount: 0, - pageInfo: {}, - }; - }, - apollo: { - catalogResources: { - query: getNamespaceCatalogResources, - variables() { - return { - fullPath: this.projectFullPath, - first: ciCatalogResourcesItemsCount, - }; - }, - update(data) { - return data?.ciCatalogResources?.nodes || []; - }, - result({ data }) { - const { pageInfo } = data?.ciCatalogResources || {}; - this.pageInfo = pageInfo; - this.totalCount = data?.ciCatalogResources?.count || 0; - }, - error(e) { - createAlert({ message: e.message || this.$options.i18n.fetchError, variant: 'danger' }); - }, - }, - }, - computed: { - hasResources() { - return this.catalogResources.length > 0; - }, - isLoading() { - return this.$apollo.queries.catalogResources.loading; - }, - }, - methods: { - async handlePrevPage() { - try { - await this.$apollo.queries.catalogResources.fetchMore({ - variables: { - before: this.pageInfo.startCursor, - last: ciCatalogResourcesItemsCount, - first: null, - }, - }); - - this.currentPage -= 1; - } catch (e) { - // Ensure that the current query is properly stopped if an error occurs. - this.$apollo.queries.catalogResources.stop(); - createAlert({ message: e?.message || this.$options.i18n.fetchError, variant: 'danger' }); - } - }, - async handleNextPage() { - try { - await this.$apollo.queries.catalogResources.fetchMore({ - variables: { - after: this.pageInfo.endCursor, - }, - }); - - this.currentPage += 1; - } catch (e) { - // Ensure that the current query is properly stopped if an error occurs. - this.$apollo.queries.catalogResources.stop(); - - createAlert({ message: e?.message || this.$options.i18n.fetchError, variant: 'danger' }); - } - }, - }, - i18n: { - fetchError: s__('CiCatalog|There was an error fetching CI/CD Catalog resources.'), - }, -}; -</script> -<template> - <div> - <catalog-header /> - <catalog-list-skeleton-loader v-if="isLoading" class="gl-w-full gl-mt-3" /> - <empty-state v-else-if="!hasResources" /> - <ci-resources-list - v-else - :current-page="currentPage" - :page-info="pageInfo" - :prev-text="__('Prev')" - :next-text="__('Next')" - :resources="catalogResources" - :total-count="totalCount" - @onPrevPage="handlePrevPage" - @onNextPage="handleNextPage" - /> - </div> -</template> diff --git a/ee/app/assets/javascripts/ci/catalog/constants.js b/ee/app/assets/javascripts/ci/catalog/constants.js deleted file mode 100644 index d2c06366649c2b23ecf4868a619e801bae99bc4c..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/ci/catalog/constants.js +++ /dev/null @@ -1 +0,0 @@ -export const CATALOG_FEEDBACK_DISMISSED_KEY = 'catalog_feedback_dismissed'; diff --git a/ee/app/assets/javascripts/ci/catalog/graphql/queries/get_namespace_catalog_resources.query.graphql b/ee/app/assets/javascripts/ci/catalog/graphql/queries/get_namespace_catalog_resources.query.graphql deleted file mode 100644 index d345e6cc783de13cdb3b77beac5bbaccf4264411..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/ci/catalog/graphql/queries/get_namespace_catalog_resources.query.graphql +++ /dev/null @@ -1,28 +0,0 @@ -#import "~/ci/catalog/graphql/fragments/catalog_resource.fragment.graphql" - -query getNamespaceCatalogResources( - $after: String - $before: String - $first: Int = 20 - $fullPath: ID! - $last: Int -) { - ciCatalogResources( - after: $after - before: $before - first: $first - projectPath: $fullPath - last: $last - ) { - pageInfo { - startCursor - endCursor - hasNextPage - hasPreviousPage - } - count - nodes { - ...CatalogResourceFields - } - } -} diff --git a/ee/app/assets/javascripts/ci/catalog/index.js b/ee/app/assets/javascripts/ci/catalog/index.js deleted file mode 100644 index 3069a59ebac336ffc0e807cd42b1049244bb79df..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/ci/catalog/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import Vue from 'vue'; -import VueApollo from 'vue-apollo'; - -import { s__ } from '~/locale'; -import createDefaultClient from '~/lib/graphql'; -import { createRouter } from '~/ci/catalog/router'; -import { cacheConfig } from '~/ci/catalog/graphql/settings'; -import CiNamespaceCatalogApp from './ci_namespace_catalog_app.vue'; -import CiResourcesPage from './components/pages/ci_resources_page.vue'; - -export const initNamespaceCatalog = (selector = '#js-ci-namespace-catalog') => { - const el = document.querySelector(selector); - - if (!el) { - return null; - } - - const { dataset } = el; - const { ciCatalogPath, projectFullPath } = dataset; - - Vue.use(VueApollo); - - const apolloProvider = new VueApollo({ - defaultClient: createDefaultClient({}, cacheConfig), - }); - - return new Vue({ - el, - name: 'CiCatalogRoot', - apolloProvider, - router: createRouter(ciCatalogPath, CiResourcesPage), - provide: { - ciCatalogPath, - projectFullPath, - pageDescription: s__( - 'CiCatalog|Repositories of pipeline components available in this namespace.', - ), - }, - render(h) { - return h(CiNamespaceCatalogApp); - }, - }); -}; diff --git a/ee/app/assets/javascripts/pages/projects/ci/catalog/resources/index.js b/ee/app/assets/javascripts/pages/projects/ci/catalog/resources/index.js deleted file mode 100644 index cba9707a3d597a2e7f6b35a9af82da1574970820..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/pages/projects/ci/catalog/resources/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { initNamespaceCatalog } from 'ee/ci/catalog'; - -initNamespaceCatalog(); diff --git a/ee/app/controllers/projects/ci/catalog/resources_controller.rb b/ee/app/controllers/projects/ci/catalog/resources_controller.rb deleted file mode 100644 index dbd4d0c1bb33eb0348d84f4a0be727843dd8ce4a..0000000000000000000000000000000000000000 --- a/ee/app/controllers/projects/ci/catalog/resources_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -module Projects - module Ci - module Catalog - class ResourcesController < Projects::ApplicationController - before_action :check_catalog_access - feature_category :pipeline_composition - - def show; end - - def index - render 'show' - end - - private - - def check_catalog_access - render_404 unless helpers.can_view_namespace_catalog?(@project) - end - end - end - end -end diff --git a/ee/app/helpers/ee/ci/catalog/resources_helper.rb b/ee/app/helpers/ee/ci/catalog/resources_helper.rb deleted file mode 100644 index 99243bd6de2fe20169b754968bdd662695fab223..0000000000000000000000000000000000000000 --- a/ee/app/helpers/ee/ci/catalog/resources_helper.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module EE - module Ci - module Catalog - module ResourcesHelper - extend ::Gitlab::Utils::Override - - override :can_view_namespace_catalog? - def can_view_namespace_catalog?(project) - super || can?(current_user, :read_namespace_catalog, project) - end - - override :js_ci_catalog_data - def js_ci_catalog_data(project) - return super unless can_view_namespace_catalog?(project) - - super.merge( - "ci_catalog_path" => project_ci_catalog_resources_path(project), - "project_full_path" => project.full_path - ) - end - end - end - end -end diff --git a/ee/app/models/gitlab_subscriptions/features.rb b/ee/app/models/gitlab_subscriptions/features.rb index ad61ff62327f350d3886e1a61492186796690852..6946c50de973ca80fc0bf121c396a5888d6ab5e3 100644 --- a/ee/app/models/gitlab_subscriptions/features.rb +++ b/ee/app/models/gitlab_subscriptions/features.rb @@ -79,7 +79,6 @@ class Features blocking_merge_requests board_assignee_lists board_milestone_lists - ci_namespace_catalog ci_secrets_management ci_pipeline_cancellation_restrictions cluster_agents_ci_impersonation diff --git a/ee/app/policies/ee/project_policy.rb b/ee/app/policies/ee/project_policy.rb index 36ddf81df6561265074d5d4ee71b4e4f8ca40c20..27775753bb26326e10ef1bbcd41dc9244f9735ff 100644 --- a/ee/app/policies/ee/project_policy.rb +++ b/ee/app/policies/ee/project_policy.rb @@ -893,10 +893,5 @@ def resource_access_token_feature_available? super end - - override :namespace_catalog_available? - def namespace_catalog_available? - project.licensed_feature_available?(:ci_namespace_catalog) - end end end diff --git a/ee/app/views/projects/ci/catalog/resources/show.html.haml b/ee/app/views/projects/ci/catalog/resources/show.html.haml deleted file mode 100644 index d68cd28207a5622c341922186e52de30d36129c3..0000000000000000000000000000000000000000 --- a/ee/app/views/projects/ci/catalog/resources/show.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- page_title s_('Pipelines|CI/CD Catalog') - -#js-ci-namespace-catalog{ data: js_ci_catalog_data(@project) } diff --git a/ee/config/routes/project.rb b/ee/config/routes/project.rb index 35a46bd10cbee10394a5aa1c852bae00700abca0..0881df7ac64b3798e3441cf83dbc65fb06f894cc 100644 --- a/ee/config/routes/project.rb +++ b/ee/config/routes/project.rb @@ -30,12 +30,6 @@ resources :test_cases, only: [:index, :new, :show] end - namespace :ci do - namespace :catalog do - resources :resources, only: [:index, :show], constraints: { id: /\d+/ } - end - end - resources :autocomplete_sources, only: [] do collection do get 'epics' diff --git a/ee/spec/features/ci/ci_catalog_spec.rb b/ee/spec/features/ci/ci_catalog_spec.rb deleted file mode 100644 index fa7d4ef7f693b893d541e5e6b305130b673903f0..0000000000000000000000000000000000000000 --- a/ee/spec/features/ci/ci_catalog_spec.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Ci Catalog', :js, feature_category: :pipeline_composition do - let_it_be(:namespace) { create(:group) } - let_it_be(:user) { create(:user) } - - let_it_be(:project) { create(:project, :repository, namespace: namespace) } - let(: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, :published, project: current_project) - end - - namespace.add_developer(user) - stub_licensed_features(ci_namespace_catalog: true) - - sign_in(user) - end - - describe 'GET /:project/-/ci/catalog/resources' do - before do - visit project_ci_catalog_resources_path(project) - 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('Repositories of pipeline components available in this namespace.') - 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("Name") - expect(page).to have_content("A simple component") - 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', :aggregate_failures do - expect(page).to have_content('Go to the project') - end - end - end - end - - describe 'GET /:project/-/ci/catalog/resources/:id' do - before do - visit project_ci_catalog_resources_path(project) - wait_for_requests - find_by_testid('ci-resource-link', match: :first).click - end - - it 'shows CI Catalog title in details page' do - expect(page).to have_content('Go to the project') - end - end -end diff --git a/ee/spec/frontend/ci/catalog/ci_namespace_catalog_app_spec.js b/ee/spec/frontend/ci/catalog/ci_namespace_catalog_app_spec.js deleted file mode 100644 index 59d108a25e69f02b3e042bd7c484d0f8fb6f9b0b..0000000000000000000000000000000000000000 --- a/ee/spec/frontend/ci/catalog/ci_namespace_catalog_app_spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import CiNamespaceCatalogApp from 'ee/ci/catalog/ci_namespace_catalog_app.vue'; -import CiCatalogHome from '~/ci/catalog/components/ci_catalog_home.vue'; - -describe('CiNamespaceCatalogApp', () => { - let wrapper; - - const findCatalogHome = () => wrapper.findComponent(CiCatalogHome); - - const defaultProps = {}; - - const createComponent = ({ mountFn = shallowMount, props = {} } = {}) => { - wrapper = mountFn(CiNamespaceCatalogApp, { - propsData: { - ...defaultProps, - ...props, - }, - }); - }; - - describe('Home component', () => { - beforeEach(() => { - createComponent(); - }); - - it('renders the home component', () => { - expect(findCatalogHome().exists()).toBe(true); - }); - }); -}); diff --git a/ee/spec/frontend/ci/catalog/components/page/ci_resources_page_spec.js b/ee/spec/frontend/ci/catalog/components/page/ci_resources_page_spec.js deleted file mode 100644 index f048ffb39edc6137715f1f86b32d31e98b2e9f57..0000000000000000000000000000000000000000 --- a/ee/spec/frontend/ci/catalog/components/page/ci_resources_page_spec.js +++ /dev/null @@ -1,218 +0,0 @@ -import Vue from 'vue'; -import VueApollo from 'vue-apollo'; - -import responseBody from 'test_fixtures/graphql/ci/catalog/namespace_catalog_resources.json'; -import emptyResponseBody from 'test_fixtures/graphql/ci/catalog/namespace_catalog_resources_empty.json'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import waitForPromises from 'helpers/wait_for_promises'; -import createMockApollo from 'helpers/mock_apollo_helper'; -import { createAlert } from '~/alert'; - -import CatalogHeader from '~/ci/catalog/components/list/catalog_header.vue'; -import CiResourcesList from '~/ci/catalog/components/list/ci_resources_list.vue'; -import CatalogListSkeletonLoader from '~/ci/catalog/components/list/catalog_list_skeleton_loader.vue'; -import EmptyState from '~/ci/catalog/components/list/empty_state.vue'; -import { cacheConfig } from '~/ci/catalog/graphql/settings'; - -import ciResourcesPage from 'ee/ci/catalog/components/pages/ci_resources_page.vue'; -import getNamespaceCatalogResources from 'ee/ci/catalog/graphql/queries/get_namespace_catalog_resources.query.graphql'; - -Vue.use(VueApollo); -jest.mock('~/alert'); - -describe('CiResourcesPage', () => { - let wrapper; - let catalogResourcesResponse; - - const defaultProvide = { projectFullPath: 'my-org/project' }; - - const createComponent = () => { - const handlers = [[getNamespaceCatalogResources, catalogResourcesResponse]]; - const mockApollo = createMockApollo(handlers, {}, cacheConfig); - - wrapper = shallowMountExtended(ciResourcesPage, { - provide: { - ...defaultProvide, - }, - apolloProvider: mockApollo, - }); - - return waitForPromises(); - }; - - const findCatalogHeader = () => wrapper.findComponent(CatalogHeader); - const findCiResourcesList = () => wrapper.findComponent(CiResourcesList); - const findLoadingState = () => wrapper.findComponent(CatalogListSkeletonLoader); - const findEmptyState = () => wrapper.findComponent(EmptyState); - - beforeEach(() => { - catalogResourcesResponse = jest.fn(); - }); - - describe('when initial queries are loading', () => { - beforeEach(() => { - createComponent(); - }); - - it('shows a loading icon and no list', () => { - expect(findLoadingState().exists()).toBe(true); - expect(findEmptyState().exists()).toBe(false); - expect(findCiResourcesList().exists()).toBe(false); - }); - }); - - describe('when queries have loaded', () => { - it('renders the Catalog Header', async () => { - await createComponent(); - - expect(findCatalogHeader().exists()).toBe(true); - }); - - describe('and there are no resources', () => { - beforeEach(async () => { - catalogResourcesResponse.mockResolvedValue(emptyResponseBody); - - await createComponent(); - }); - - it('renders the empty state', () => { - expect(findLoadingState().exists()).toBe(false); - expect(findEmptyState().exists()).toBe(true); - expect(findCiResourcesList().exists()).toBe(false); - }); - }); - - describe('and there are resources', () => { - const { nodes, pageInfo, count } = responseBody.data.ciCatalogResources; - - beforeEach(async () => { - catalogResourcesResponse.mockResolvedValue(responseBody); - - await createComponent(); - }); - it('renders the resources list', () => { - expect(findLoadingState().exists()).toBe(false); - expect(findEmptyState().exists()).toBe(false); - expect(findCiResourcesList().exists()).toBe(true); - }); - - it('passes down props to the resources list', () => { - expect(findCiResourcesList().props()).toMatchObject({ - currentPage: 1, - resources: nodes, - pageInfo, - totalCount: count, - }); - }); - }); - }); - - describe('pagination', () => { - it.each` - eventName - ${'onPrevPage'} - ${'onNextPage'} - `('refetch query with new params when receiving $eventName', async ({ eventName }) => { - const { pageInfo } = responseBody.data.ciCatalogResources; - - catalogResourcesResponse.mockResolvedValue(responseBody); - await createComponent(); - - expect(catalogResourcesResponse).toHaveBeenCalledTimes(1); - - await findCiResourcesList().vm.$emit(eventName); - - expect(catalogResourcesResponse).toHaveBeenCalledTimes(2); - - if (eventName === 'onNextPage') { - expect(catalogResourcesResponse.mock.calls[1][0]).toEqual({ - after: pageInfo.endCursor, - first: 20, - fullPath: defaultProvide.projectFullPath, - }); - } else { - expect(catalogResourcesResponse.mock.calls[1][0]).toEqual({ - before: pageInfo.startCursor, - last: 20, - first: null, - fullPath: defaultProvide.projectFullPath, - }); - } - }); - }); - - describe('pages count', () => { - describe('when the fetchMore call suceeds', () => { - beforeEach(async () => { - catalogResourcesResponse.mockResolvedValue(responseBody); - - await createComponent(); - }); - - it('increments and drecrements the page count correctly', async () => { - expect(findCiResourcesList().props().currentPage).toBe(1); - - findCiResourcesList().vm.$emit('onNextPage'); - await waitForPromises(); - - expect(findCiResourcesList().props().currentPage).toBe(2); - - await findCiResourcesList().vm.$emit('onPrevPage'); - await waitForPromises(); - - expect(findCiResourcesList().props().currentPage).toBe(1); - }); - }); - - describe('when the fetchMore call fails', () => { - const errorMessage = 'there was an error'; - - describe('for next page', () => { - beforeEach(async () => { - catalogResourcesResponse.mockResolvedValueOnce(responseBody); - catalogResourcesResponse.mockRejectedValue({ message: errorMessage }); - - await createComponent(); - }); - - it('does not increment the page and calls createAlert', async () => { - expect(findCiResourcesList().props().currentPage).toBe(1); - - findCiResourcesList().vm.$emit('onNextPage'); - await waitForPromises(); - - expect(findCiResourcesList().props().currentPage).toBe(1); - expect(createAlert).toHaveBeenCalledWith({ message: errorMessage, variant: 'danger' }); - }); - }); - - describe('for previous page', () => { - beforeEach(async () => { - // Initial query - catalogResourcesResponse.mockResolvedValueOnce(responseBody); - // When clicking on next - catalogResourcesResponse.mockResolvedValueOnce(responseBody); - // when clicking on previous - catalogResourcesResponse.mockRejectedValue({ message: errorMessage }); - - await createComponent(); - }); - - it('does not decrement the page and calls createAlert', async () => { - expect(findCiResourcesList().props().currentPage).toBe(1); - - findCiResourcesList().vm.$emit('onNextPage'); - await waitForPromises(); - - expect(findCiResourcesList().props().currentPage).toBe(2); - - findCiResourcesList().vm.$emit('onPrevPage'); - await waitForPromises(); - - expect(findCiResourcesList().props().currentPage).toBe(2); - expect(createAlert).toHaveBeenCalledWith({ message: errorMessage, variant: 'danger' }); - }); - }); - }); - }); -}); diff --git a/ee/spec/frontend/ci/catalog/index_spec.js b/ee/spec/frontend/ci/catalog/index_spec.js deleted file mode 100644 index 9fd475eb66003f6fac7467ad20dbddea898c20e6..0000000000000000000000000000000000000000 --- a/ee/spec/frontend/ci/catalog/index_spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import Vue from 'vue'; -import { initNamespaceCatalog } from 'ee/ci/catalog/index'; -import * as Router from '~/ci/catalog/router'; -import CiResourcesPage from 'ee/ci/catalog/components/pages/ci_resources_page.vue'; - -describe('ee/ci/catalog/index', () => { - describe('initNamespaceCatalog', () => { - const SELECTOR = 'SELECTOR'; - - let el; - let component; - const baseRoute = '/ci/catalog/resources'; - - const createElement = () => { - el = document.createElement('div'); - el.id = SELECTOR; - el.dataset.ciCatalogPath = baseRoute; - document.body.appendChild(el); - }; - - afterEach(() => { - el = null; - }); - - describe('when the element exists', () => { - beforeEach(() => { - createElement(); - jest.spyOn(Router, 'createRouter'); - component = initNamespaceCatalog(`#${SELECTOR}`); - }); - - it('returns a Vue Instance', () => { - expect(component).toBeInstanceOf(Vue); - }); - - it('creates a router with the received base path and component', () => { - expect(Router.createRouter).toHaveBeenCalledTimes(1); - expect(Router.createRouter).toHaveBeenCalledWith(baseRoute, CiResourcesPage); - }); - }); - - describe('When the element does not exist', () => { - it('returns `null`', () => { - expect(initNamespaceCatalog('foo')).toBe(null); - }); - }); - }); -}); diff --git a/ee/spec/frontend/fixtures/ci_catalog_resources.rb b/ee/spec/frontend/fixtures/ci_catalog_resources.rb deleted file mode 100644 index 0e1b84f10d540e9db62284a2f14facc9044b05d3..0000000000000000000000000000000000000000 --- a/ee/spec/frontend/fixtures/ci_catalog_resources.rb +++ /dev/null @@ -1,87 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe "GraphQL CI/CD catalog resources", '(JavaScript fixtures)', type: :request, feature_category: :pipeline_composition do - include ApiHelpers - include GraphqlHelpers - include JavaScriptFixturesHelpers - - let_it_be(:namespace) { create(:group, name: 'frontend-fixtures') } - let_it_be(:project) { create(:project, :public, namespace: namespace) } - let_it_be(:current_user) { create(:user) } - - query_name = 'namespace_catalog_resources' - get_namespace_catalog_resources = "ci/catalog/graphql/queries/get_#{query_name}.query.graphql" - - before_all do - namespace.add_developer(current_user) - end - - before do - stub_licensed_features(ci_namespace_catalog: true) - end - - context 'when there are no CI Catalog resources' do - it "graphql/ci/catalog/#{query_name}_empty.json" do - query = get_graphql_query_as_string(get_namespace_catalog_resources, ee: true) - - post_graphql(query, current_user: current_user, variables: { fullPath: project.full_path }) - - expect_graphql_errors_to_be_empty - end - end - - context 'when there is a single page of CI Catalog resources' do - let_it_be(:projects) do - create_list( - :project, - 3, - description: 'A simple component', - namespace: namespace - ) - end - - let_it_be(:ci_catalog_resources) do - projects.map do |current_project| - create(:ci_catalog_resource, :published, project: current_project) - end - end - - it "graphql/ci/catalog/#{query_name}_single_page.json" do - query = get_graphql_query_as_string(get_namespace_catalog_resources, ee: true) - - post_graphql(query, current_user: current_user, variables: { fullPath: project.full_path }) - - expect_graphql_errors_to_be_empty - end - end - - context 'when there are multiple pages of CI Catalog resources' do - # rubocop:disable RSpec/FactoryBot/ExcessiveCreateList because we - # need a minimum of 3 pages to test pagination and each page is 20 items long. - let_it_be(:projects) do - create_list( - :project, - 41, - description: 'A simple component', - namespace: namespace - ) - end - # rubocop:enable RSpec/FactoryBot/ExcessiveCreateList - - let_it_be(:ci_catalog_resources) do - projects.map do |current_project| - create(:ci_catalog_resource, :published, project: current_project) - end - end - - it "graphql/ci/catalog/#{query_name}.json" do - query = get_graphql_query_as_string(get_namespace_catalog_resources, ee: true) - - post_graphql(query, current_user: current_user, variables: { fullPath: project.full_path }) - - expect_graphql_errors_to_be_empty - end - end -end diff --git a/ee/spec/helpers/ee/ci/catalog/resources_helper_spec.rb b/ee/spec/helpers/ee/ci/catalog/resources_helper_spec.rb deleted file mode 100644 index 788225b73eaa2224541674ed64e6cbad32187b03..0000000000000000000000000000000000000000 --- a/ee/spec/helpers/ee/ci/catalog/resources_helper_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Ci::Catalog::ResourcesHelper, feature_category: :pipeline_composition do - include Devise::Test::ControllerHelpers - - let_it_be(:project) { create_default(:project) } - let_it_be(:user) { create_default(:user) } - - before do - allow(helper).to receive(:current_user).and_return(user) - end - - describe '#can_view_namespace_catalog?' do - subject { helper.can_view_namespace_catalog?(project) } - - context 'when user has no permissions to collaborate' do - before do - stub_licensed_features(ci_namespace_catalog: true) - end - - it 'returns false' do - expect(subject).to be false - end - end - - context 'when user has permissions to collaborate' do - before do - project.add_owner(user) - end - - context 'when license for namespace catalog is enabled' do - before do - stub_licensed_features(ci_namespace_catalog: true) - end - - it 'returns true' do - expect(subject).to be true - end - end - - context 'when license for namespace catalog is not enabled' do - before do - stub_licensed_features(ci_namespace_catalog: false) - end - - it 'returns false' do - expect(subject).to be false - end - end - end - end - - describe '#js_ci_catalog_data' do - subject { helper.js_ci_catalog_data(project) } - - context 'without the right permissions' do - before do - stub_licensed_features(ci_namespace_catalog: false) - end - - it 'does not return the EE specific attributes' do - expect(subject.keys).not_to include('ci_catalog_path') - end - end - - context 'with the right permissions' do - before do - stub_licensed_features(ci_namespace_catalog: true) - - project.add_owner(user) - end - - it 'returns both the super and EE specific properties' do - expect(subject).to eq( - "ci_catalog_path" => "/#{project.full_path}/-/ci/catalog/resources", - "project_full_path" => project.full_path - ) - end - end - end -end diff --git a/ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb b/ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb index e737f6a65f80e667f4c2f593572b8cfbdbb090ae..72b966c64193c9cdbc95f703950965f559c6b02e 100644 --- a/ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb +++ b/ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe Sidebars::Projects::Menus::CiCdMenu do - include EE::Ci::Catalog::ResourcesHelper - let(:project) { build(:project) } let(:user) { project.first_owner } let(:context) { Sidebars::Projects::Context.new(current_user: user, current_ref: 'main', container: project, can_view_pipeline_editor: true) } diff --git a/ee/spec/policies/project_policy_spec.rb b/ee/spec/policies/project_policy_spec.rb index 1acbdd393da7c67fc2caef71300576db3516cb1e..9f28922ee917d6e0006f34015097f25c93e4ce91 100644 --- a/ee/spec/policies/project_policy_spec.rb +++ b/ee/spec/policies/project_policy_spec.rb @@ -2853,42 +2853,6 @@ def create_member_role(member, abilities = member_role_abilities) end end - describe 'read_namespace_catalog' do - let(:current_user) { owner } - - context 'when the ci_namespace_catalog licensed feature is unavailable' do - before do - stub_licensed_features(ci_namespace_catalog: false) - end - - it { is_expected.to be_disallowed(:read_namespace_catalog) } - end - - context 'when ci_namespace_catalog is available' do - using RSpec::Parameterized::TableSyntax - - let(:current_user) { public_send(role) } - - where(:role, :allowed) do - :owner | true - :maintainer | true - :developer | true - :reporter | false - :guest | false - end - - before do - stub_licensed_features(ci_namespace_catalog: true) - end - - with_them do - it do - expect(subject.can?(:read_namespace_catalog)).to be(allowed) - end - end - end - end - describe 'read_project_runners' do context 'with auditor' do let(:current_user) { auditor } diff --git a/ee/spec/requests/projects/ci/catalog/resources_controller_spec.rb b/ee/spec/requests/projects/ci/catalog/resources_controller_spec.rb deleted file mode 100644 index 509669d27299438a06c88b140033d620d845b51d..0000000000000000000000000000000000000000 --- a/ee/spec/requests/projects/ci/catalog/resources_controller_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Ci::Catalog::ResourcesController, feature_category: :pipeline_composition do - let_it_be(:project) { create(:project, :repository) } - let_it_be(:user) { create(:user) } - - before do - sign_in(user) - end - - shared_examples 'basic get requests' do |action| - let(:path) do - if action == :index - project_ci_catalog_resources_path(project) - else - project_ci_catalog_resource_path(project, id: 1) - end - end - - context 'with license for `ci_namespace_catalog`' do - before do - stub_licensed_features(ci_namespace_catalog: true) - end - - context 'with enough privileges' do - before do - project.add_developer(user) - end - - it 'responds with 200' do - get path - - expect(response).to have_gitlab_http_status(:ok) - end - end - - context 'without enough privileges' do - before do - project.add_reporter(user) - end - - it 'responds with 404' do - get path - - expect(response).to have_gitlab_http_status(:not_found) - end - end - end - - context 'without license for `ci_namespace_catalog`' do - context 'with enough privileges' do - before do - project.add_developer(user) - end - - it 'responds with 404' do - get path - - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'without enough privileges' do - before do - project.add_reporter(user) - end - - it 'responds with 404' do - get path - - expect(response).to have_gitlab_http_status(:not_found) - end - end - end - end - - describe 'GET #show' do - it_behaves_like 'basic get requests', :show - end - - describe 'GET #index' do - it_behaves_like 'basic get requests', :index - end -end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index cfca5a3610e551eec0eb5d76c9840637de5ec1d8..8b66e415d9ae89886ebd347a82d85b7509eb991e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -10516,9 +10516,6 @@ msgstr "" msgid "CiCatalog|Remove project from the CI/CD Catalog?" msgstr "" -msgid "CiCatalog|Repositories of pipeline components available in this namespace." -msgstr "" - msgid "CiCatalog|Search must be at least 3 characters" msgstr "" @@ -35826,9 +35823,6 @@ msgstr "" msgid "Pipelines|CI lint" msgstr "" -msgid "Pipelines|CI/CD Catalog" -msgstr "" - msgid "Pipelines|Child pipeline (%{linkStart}parent%{linkEnd})" msgstr "" diff --git a/spec/helpers/ci/catalog/resources_helper_spec.rb b/spec/helpers/ci/catalog/resources_helper_spec.rb index 5c5d02ce6d8577236df048daf83a29388d223754..68d564372494dba02a9951b94d0c3bda1e05226d 100644 --- a/spec/helpers/ci/catalog/resources_helper_spec.rb +++ b/spec/helpers/ci/catalog/resources_helper_spec.rb @@ -36,18 +36,6 @@ end end - describe '#can_view_namespace_catalog?' do - subject { helper.can_view_namespace_catalog?(project) } - - before do - stub_licensed_features(ci_namespace_catalog: false) - end - - it 'user cannot view the Catalog in CE regardless of permissions' do - expect(subject).to be false - end - end - describe '#js_ci_catalog_data' do let(:project) { build(:project, :repository) } diff --git a/spec/services/ci/catalog/resources/create_service_spec.rb b/spec/services/ci/catalog/resources/create_service_spec.rb index 202c76acaecc6018765b626f751367f6ceb6b5d7..5839b9ac2fe8989ca0d19ee6412eb40f2beae0b6 100644 --- a/spec/services/ci/catalog/resources/create_service_spec.rb +++ b/spec/services/ci/catalog/resources/create_service_spec.rb @@ -8,10 +8,6 @@ let(:service) { described_class.new(project, user) } - before do - stub_licensed_features(ci_namespace_catalog: true) - end - describe '#execute' do context 'with an unauthorized user' do it 'raises an AccessDeniedError' do diff --git a/spec/services/ci/catalog/resources/destroy_service_spec.rb b/spec/services/ci/catalog/resources/destroy_service_spec.rb index da5ba7ad0bce5490d5fd51c099f8257bccf8a066..4783506416d71617d0e5a882b9793db3bb6ef053 100644 --- a/spec/services/ci/catalog/resources/destroy_service_spec.rb +++ b/spec/services/ci/catalog/resources/destroy_service_spec.rb @@ -9,10 +9,6 @@ let(:service) { described_class.new(project, user) } - before do - stub_licensed_features(ci_namespace_catalog: true) - end - describe '#execute' do context 'with an unauthorized user' do it 'raises an AccessDeniedError' do