diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 15:15:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 15:15:59 +0300 |
commit | 2017bc90a671eac669f0114b6ef508e151409c4f (patch) | |
tree | 79bbbedede417d3ce13ae2e13dd1ad3bb069c975 /spec | |
parent | 9450a63064cd1572f030628dbf155f5c047f28c7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
104 files changed, 678 insertions, 570 deletions
diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb index cb310c7b7f9..a47bac4d2ef 100644 --- a/spec/controllers/admin/clusters_controller_spec.rb +++ b/spec/controllers/admin/clusters_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Admin::ClustersController, feature_category: :kubernetes_management do +RSpec.describe Admin::ClustersController, feature_category: :deployment_management do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers diff --git a/spec/controllers/concerns/kas_cookie_spec.rb b/spec/controllers/concerns/kas_cookie_spec.rb index b1a951c663b..d80df106cfd 100644 --- a/spec/controllers/concerns/kas_cookie_spec.rb +++ b/spec/controllers/concerns/kas_cookie_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe KasCookie, feature_category: :kubernetes_management do +RSpec.describe KasCookie, feature_category: :deployment_management do describe '#set_kas_cookie' do controller(ApplicationController) do include KasCookie diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index c020aeedf1c..410579c0bed 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Groups::ClustersController, feature_category: :kubernetes_management do +RSpec.describe Groups::ClustersController, feature_category: :deployment_management do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb index f322c78b5e3..06c82bcb404 100644 --- a/spec/controllers/projects/blame_controller_spec.rb +++ b/spec/controllers/projects/blame_controller_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' -RSpec.describe Projects::BlameController do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } +RSpec.describe Projects::BlameController, feature_category: :source_code_management do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } before do sign_in(user) @@ -13,20 +13,14 @@ RSpec.describe Projects::BlameController do controller.instance_variable_set(:@project, project) end - describe "GET show" do - render_views - - before do - get :show, params: { namespace_id: project.namespace, project_id: project, id: id } - end - - context "valid branch, valid file" do + shared_examples 'blame_response' do + context 'valid branch, valid file' do let(:id) { 'master/files/ruby/popen.rb' } it { is_expected.to respond_with(:success) } end - context "valid branch, invalid file" do + context 'valid branch, invalid file' do let(:id) { 'master/files/ruby/invalid-path.rb' } it 'redirects' do @@ -34,10 +28,30 @@ RSpec.describe Projects::BlameController do end end - context "invalid branch, valid file" do + context 'invalid branch, valid file' do let(:id) { 'invalid-branch/files/ruby/missing_file.rb' } it { is_expected.to respond_with(:not_found) } end end + + describe 'GET show' do + render_views + + before do + get :show, params: { namespace_id: project.namespace, project_id: project, id: id } + end + + it_behaves_like 'blame_response' + end + + describe 'GET page' do + render_views + + before do + get :page, params: { namespace_id: project.namespace, project_id: project, id: id } + end + + it_behaves_like 'blame_response' + end end diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index 236e1845d3f..ea73f62981e 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::ClustersController, feature_category: :kubernetes_management do +RSpec.describe Projects::ClustersController, feature_category: :deployment_management do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers include KubernetesHelpers diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index fe528719f26..ff20f95a8aa 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -199,22 +199,6 @@ RSpec.describe Projects::PipelinesController, feature_category: :continuous_inte check_pipeline_response(returned: 6, all: 6) end end - - context "with lazy_load_pipeline_dropdown_actions feature flag disabled" do - before do - stub_feature_flags(lazy_load_pipeline_dropdown_actions: false) - end - - it 'returns manual and scheduled actions' do - get_pipelines_index_json - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('pipeline') - - expect(json_response.dig('pipelines', 0, 'details')).to include('manual_actions') - expect(json_response.dig('pipelines', 0, 'details')).to include('scheduled_actions') - end - end end def get_pipelines_index_html(params = {}) diff --git a/spec/features/clusters/cluster_detail_page_spec.rb b/spec/features/clusters/cluster_detail_page_spec.rb index e8fb5f4105d..31dec5e38da 100644 --- a/spec/features/clusters/cluster_detail_page_spec.rb +++ b/spec/features/clusters/cluster_detail_page_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Clusterable > Show page', feature_category: :kubernetes_management do +RSpec.describe 'Clusterable > Show page', feature_category: :deployment_management do include KubernetesHelpers let(:current_user) { create(:user) } diff --git a/spec/features/clusters/cluster_health_dashboard_spec.rb b/spec/features/clusters/cluster_health_dashboard_spec.rb index b557f803a99..ebbc184eaef 100644 --- a/spec/features/clusters/cluster_health_dashboard_spec.rb +++ b/spec/features/clusters/cluster_health_dashboard_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Cluster Health board', :js, :kubeclient, :use_clean_rails_memory_store_caching, :sidekiq_inline, -feature_category: :kubernetes_management do +feature_category: :deployment_management do include KubernetesHelpers include PrometheusHelpers diff --git a/spec/features/clusters/create_agent_spec.rb b/spec/features/clusters/create_agent_spec.rb index 01902c36e99..93a49151978 100644 --- a/spec/features/clusters/create_agent_spec.rb +++ b/spec/features/clusters/create_agent_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Cluster agent registration', :js, feature_category: :kubernetes_management do +RSpec.describe 'Cluster agent registration', :js, feature_category: :deployment_management do let_it_be(:project) { create(:project, :custom_repo, files: { '.gitlab/agents/example-agent-1/config.yaml' => '' }) } let_it_be(:current_user) { create(:user, maintainer_projects: [project]) } let_it_be(:token) { Devise.friendly_token } diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb index 1a2268a838b..ee1e704c6c4 100644 --- a/spec/features/dashboard/issues_filter_spec.rb +++ b/spec/features/dashboard/issues_filter_spec.rb @@ -44,7 +44,7 @@ RSpec.describe 'Dashboard Issues filtering', :js, feature_category: :team_planni it 'updates atom feed link' do visit_issues(milestone_title: '', assignee_username: user.username) - link = find('[data-testid="rss-feed-link"]') + link = find_link('Subscribe to RSS feed') params = CGI.parse(URI.parse(link[:href]).query) auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query) diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index 00c0d4c3ebe..9f6fa146972 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -30,29 +30,15 @@ RSpec.describe 'Group issues page', feature_category: :subgroups do user_in_group end + it_behaves_like "it has an RSS link with current_user's feed token" it_behaves_like "an autodiscoverable RSS feed with current_user's feed token" - - # Note: The one from rss_shared_example.rb uses a css pseudo-class `:has` - # which is VERY experimental and only supported in Nokogiri used by Capybara - # However,`:js` option forces Capybara to use Selenium that doesn't support`:has` - context "it has an RSS button with current_user's feed token" do - it "shows the RSS button with current_user's feed token" do - expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/ - end - end end context 'when signed out' do let(:user) { nil } + it_behaves_like "it has an RSS link without a feed token" it_behaves_like "an autodiscoverable RSS feed without a feed token" - - # Note: please see the above - context "it has an RSS button without a feed token" do - it "shows the RSS button without a feed token" do - expect(page).not_to have_link 'Subscribe to RSS feed', href: /feed_token/ - end - end end end diff --git a/spec/features/issues/rss_spec.rb b/spec/features/issues/rss_spec.rb index 36dffeded50..75e7cd03a65 100644 --- a/spec/features/issues/rss_spec.rb +++ b/spec/features/issues/rss_spec.rb @@ -25,10 +25,7 @@ RSpec.describe 'Project Issues RSS', :js, feature_category: :team_planning do visit path end - it "shows the RSS button with current_user's feed token" do - expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/ - end - + it_behaves_like "it has an RSS link with current_user's feed token" it_behaves_like "an autodiscoverable RSS feed with current_user's feed token" end @@ -37,10 +34,7 @@ RSpec.describe 'Project Issues RSS', :js, feature_category: :team_planning do visit path end - it "shows the RSS button without a feed token" do - expect(page).not_to have_link 'Subscribe to RSS feed', href: /feed_token/ - end - + it_behaves_like "it has an RSS link without a feed token" it_behaves_like "an autodiscoverable RSS feed without a feed token" end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index 114182982e2..f9195904ea3 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Gcp Cluster', :js, feature_category: :kubernetes_management do +RSpec.describe 'Gcp Cluster', :js, feature_category: :deployment_management do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb index 34fc0a76c7f..eb2601bb85f 100644 --- a/spec/features/projects/clusters/user_spec.rb +++ b/spec/features/projects/clusters/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User Cluster', :js, feature_category: :kubernetes_management do +RSpec.describe 'User Cluster', :js, feature_category: :deployment_management do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } diff --git a/spec/finders/clusters/agents/authorizations/ci_access/finder_spec.rb b/spec/finders/clusters/agents/authorizations/ci_access/finder_spec.rb index c311b19139f..0d010729d5c 100644 --- a/spec/finders/clusters/agents/authorizations/ci_access/finder_spec.rb +++ b/spec/finders/clusters/agents/authorizations/ci_access/finder_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::Finder, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::Finder, feature_category: :deployment_management do describe '#execute' do let_it_be(:top_level_group) { create(:group) } let_it_be(:subgroup1) { create(:group, parent: top_level_group) } diff --git a/spec/frontend/__helpers__/wait_for_text.js b/spec/frontend/__helpers__/wait_for_text.js index 6bed8a90a98..991adc5d6c0 100644 --- a/spec/frontend/__helpers__/wait_for_text.js +++ b/spec/frontend/__helpers__/wait_for_text.js @@ -1,3 +1,3 @@ import { findByText } from '@testing-library/dom'; -export const waitForText = async (text, container = document) => findByText(container, text); +export const waitForText = (text, container = document) => findByText(container, text); diff --git a/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js b/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js index 06b3ec4aab8..a25d325f7a1 100644 --- a/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js +++ b/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js @@ -626,7 +626,7 @@ describe('Ci Variable Shared Component', () => { } }); - it('report custom validator error on wrong data', async () => { + it('report custom validator error on wrong data', () => { expect(() => assertProps( ciVariableShared, diff --git a/spec/frontend/ci/runner/components/registration/registration_instructions_spec.js b/spec/frontend/ci/runner/components/registration/registration_instructions_spec.js index 629272c0bf0..8c196d7b5e3 100644 --- a/spec/frontend/ci/runner/components/registration/registration_instructions_spec.js +++ b/spec/frontend/ci/runner/components/registration/registration_instructions_spec.js @@ -280,7 +280,7 @@ describe('RegistrationInstructions', () => { }); describe('when the page is closing', () => { - it('warns the user against closing', async () => { + it('warns the user against closing', () => { const { event, preventDefault, returnValueSetter } = mockBeforeunload(); expect(preventDefault).not.toHaveBeenCalled(); diff --git a/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js b/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js index c8fa02cb6aa..f08efc0c685 100644 --- a/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js +++ b/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js @@ -124,7 +124,7 @@ describe('Design reply form component', () => { ${'gid://gitlab/DiffDiscussion/123'} | ${123} `( 'initializes autosave support on discussion with proper key', - async ({ discussionId, shortDiscussionId }) => { + ({ discussionId, shortDiscussionId }) => { createComponent({ props: { discussionId } }); expect(Autosave).toHaveBeenCalledWith(expect.any(Element), [ @@ -136,7 +136,7 @@ describe('Design reply form component', () => { ); describe('when form has no text', () => { - beforeEach(async () => { + beforeEach(() => { createComponent(); }); @@ -148,7 +148,7 @@ describe('Design reply form component', () => { key | keyData ${'ctrl'} | ${ctrlKey} ${'meta'} | ${metaKey} - `('does not perform mutation on textarea $key+enter keydown', async ({ keyData }) => { + `('does not perform mutation on textarea $key+enter keydown', ({ keyData }) => { findTextarea().trigger('keydown.enter', keyData); expect(mockMutationHandler).not.toHaveBeenCalled(); @@ -266,7 +266,7 @@ describe('Design reply form component', () => { expect(wrapper.emitted('cancel-form')).toHaveLength(1); }); - it('opens confirmation modal on Escape key when text has changed', async () => { + it('opens confirmation modal on Escape key when text has changed', () => { createComponent(); findTextarea().setValue(mockComment); diff --git a/spec/frontend/diffs/components/diff_view_spec.js b/spec/frontend/diffs/components/diff_view_spec.js index 9bff6bd14f1..cfc80e61b30 100644 --- a/spec/frontend/diffs/components/diff_view_spec.js +++ b/spec/frontend/diffs/components/diff_view_spec.js @@ -14,7 +14,7 @@ describe('DiffView', () => { const setSelectedCommentPosition = jest.fn(); const getDiffRow = (wrapper) => wrapper.findComponent(DiffRow).vm; - const createWrapper = (props, provide = {}) => { + const createWrapper = (props) => { Vue.use(Vuex); const batchComments = { @@ -48,7 +48,7 @@ describe('DiffView', () => { ...props, }; const stubs = { DiffExpansionCell, DiffRow, DiffCommentCell, DraftNote }; - return shallowMount(DiffView, { propsData, store, stubs, provide }); + return shallowMount(DiffView, { propsData, store, stubs }); }; it('does not render a diff-line component when there is no finding', () => { @@ -56,24 +56,13 @@ describe('DiffView', () => { expect(wrapper.findComponent(DiffLine).exists()).toBe(false); }); - it('does render a diff-line component with the correct props when there is a finding & refactorCodeQualityInlineFindings flag is true', async () => { - const wrapper = createWrapper(diffCodeQuality, { - glFeatures: { refactorCodeQualityInlineFindings: true }, - }); + it('does render a diff-line component with the correct props when there is a finding', async () => { + const wrapper = createWrapper(diffCodeQuality); wrapper.findComponent(DiffRow).vm.$emit('toggleCodeQualityFindings', 2); await nextTick(); expect(wrapper.findComponent(DiffLine).props('line')).toBe(diffCodeQuality.diffLines[2]); }); - it('does not render a diff-line component when there is a finding & refactorCodeQualityInlineFindings flag is false', async () => { - const wrapper = createWrapper(diffCodeQuality, { - glFeatures: { refactorCodeQualityInlineFindings: false }, - }); - wrapper.findComponent(DiffRow).vm.$emit('toggleCodeQualityFindings', 2); - await nextTick(); - expect(wrapper.findComponent(DiffLine).exists()).toBe(false); - }); - it.each` type | side | container | sides | total ${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDrafts: [], renderDiscussion: true }, right: { lineDrafts: [], renderDiscussion: true } }} | ${2} diff --git a/spec/frontend/pipelines/pipeline_operations_spec.js b/spec/frontend/pipelines/pipeline_operations_spec.js index 15fc23e8b54..b2191453824 100644 --- a/spec/frontend/pipelines/pipeline_operations_spec.js +++ b/spec/frontend/pipelines/pipeline_operations_spec.js @@ -1,6 +1,5 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import PipelinesManualActions from '~/pipelines/components/pipelines_list/pipelines_manual_actions.vue'; -import PipelinesManualActionsLegacy from '~/pipelines/components/pipelines_list/pipelines_manual_actions_legacy.vue'; import PipelineMultiActions from '~/pipelines/components/pipelines_list/pipeline_multi_actions.vue'; import PipelineOperations from '~/pipelines/components/pipelines_list/pipeline_operations.vue'; import eventHub from '~/pipelines/event_hub'; @@ -15,15 +14,6 @@ describe('Pipeline operations', () => { details: { has_manual_actions: true, has_scheduled_actions: false, - manual_actions: [ - { - name: 'dont-interrupt-me', - path: '/root/ci-project/-/jobs/3974323562/play', - playable: true, - scheduled: false, - }, - ], - scheduled_actions: [], }, flags: { retryable: true, @@ -34,20 +24,14 @@ describe('Pipeline operations', () => { }, }; - const createComponent = (props = defaultProps, flagState = true) => { + const createComponent = (props = defaultProps) => { wrapper = shallowMountExtended(PipelineOperations, { - provide: { - glFeatures: { - lazyLoadPipelineDropdownActions: flagState, - }, - }, propsData: { ...props, }, }); }; - const findLegacyManualActions = () => wrapper.findComponent(PipelinesManualActionsLegacy); const findManualActions = () => wrapper.findComponent(PipelinesManualActions); const findMultiActions = () => wrapper.findComponent(PipelineMultiActions); const findRetryBtn = () => wrapper.findByTestId('pipelines-retry-button'); @@ -57,14 +41,6 @@ describe('Pipeline operations', () => { createComponent(); expect(findManualActions().exists()).toBe(true); - expect(findLegacyManualActions().exists()).toBe(false); - }); - - it('should display legacy pipeline manual actions', () => { - createComponent(defaultProps, false); - - expect(findLegacyManualActions().exists()).toBe(true); - expect(findManualActions().exists()).toBe(false); }); it('should display pipeline multi actions', () => { diff --git a/spec/frontend/pipelines/pipelines_manual_actions_legacy_spec.js b/spec/frontend/pipelines/pipelines_manual_actions_legacy_spec.js deleted file mode 100644 index 50ff301060b..00000000000 --- a/spec/frontend/pipelines/pipelines_manual_actions_legacy_spec.js +++ /dev/null @@ -1,168 +0,0 @@ -import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; -import MockAdapter from 'axios-mock-adapter'; -import { nextTick } from 'vue'; -import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; -import waitForPromises from 'helpers/wait_for_promises'; -import { TEST_HOST } from 'spec/test_constants'; -import { createAlert } from '~/alert'; -import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; -import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal'; -import PipelinesManualActionsLegacy from '~/pipelines/components/pipelines_list/pipelines_manual_actions_legacy.vue'; -import GlCountdown from '~/vue_shared/components/gl_countdown.vue'; -import { TRACKING_CATEGORIES } from '~/pipelines/constants'; - -jest.mock('~/alert'); -jest.mock('~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal'); - -describe('Pipelines Actions dropdown', () => { - let wrapper; - let mock; - - const createComponent = (props, mountFn = shallowMount) => { - wrapper = mountFn(PipelinesManualActionsLegacy, { - propsData: { - ...props, - }, - }); - }; - - const findDropdown = () => wrapper.findComponent(GlDropdown); - const findAllDropdownItems = () => wrapper.findAllComponents(GlDropdownItem); - const findAllCountdowns = () => wrapper.findAllComponents(GlCountdown); - - beforeEach(() => { - mock = new MockAdapter(axios); - }); - - afterEach(() => { - mock.restore(); - confirmAction.mockReset(); - }); - - describe('manual actions', () => { - const mockActions = [ - { - name: 'stop_review', - path: `${TEST_HOST}/root/review-app/builds/1893/play`, - }, - { - name: 'foo', - path: `${TEST_HOST}/disabled/pipeline/action`, - playable: false, - }, - ]; - - beforeEach(() => { - createComponent({ actions: mockActions }); - }); - - it('renders a dropdown with the provided actions', () => { - expect(findAllDropdownItems()).toHaveLength(mockActions.length); - }); - - it("renders a disabled action when it's not playable", () => { - expect(findAllDropdownItems().at(1).attributes('disabled')).toBe('true'); - }); - - describe('on click', () => { - it('makes a request and toggles the loading state', async () => { - mock.onPost(mockActions.path).reply(HTTP_STATUS_OK); - - findAllDropdownItems().at(0).vm.$emit('click'); - - await nextTick(); - expect(findDropdown().props('loading')).toBe(true); - - await waitForPromises(); - expect(findDropdown().props('loading')).toBe(false); - }); - - it('makes a failed request and toggles the loading state', async () => { - mock.onPost(mockActions.path).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR); - - findAllDropdownItems().at(0).vm.$emit('click'); - - await nextTick(); - expect(findDropdown().props('loading')).toBe(true); - - await waitForPromises(); - expect(findDropdown().props('loading')).toBe(false); - expect(createAlert).toHaveBeenCalledTimes(1); - }); - }); - - describe('tracking', () => { - afterEach(() => { - unmockTracking(); - }); - - it('tracks manual actions click', () => { - const trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); - - findDropdown().vm.$emit('shown'); - - expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_manual_actions', { - label: TRACKING_CATEGORIES.table, - }); - }); - }); - }); - - describe('scheduled jobs', () => { - const scheduledJobAction = { - name: 'scheduled action', - path: `${TEST_HOST}/scheduled/job/action`, - playable: true, - scheduled_at: '2063-04-05T00:42:00Z', - }; - const expiredJobAction = { - name: 'expired action', - path: `${TEST_HOST}/expired/job/action`, - playable: true, - scheduled_at: '2018-10-05T08:23:00Z', - }; - - beforeEach(() => { - jest.spyOn(Date, 'now').mockImplementation(() => new Date('2063-04-04T00:42:00Z').getTime()); - createComponent({ actions: [scheduledJobAction, expiredJobAction] }); - }); - - it('makes post request after confirming', async () => { - mock.onPost(scheduledJobAction.path).reply(HTTP_STATUS_OK); - confirmAction.mockResolvedValueOnce(true); - - findAllDropdownItems().at(0).vm.$emit('click'); - - expect(confirmAction).toHaveBeenCalled(); - - await waitForPromises(); - - expect(mock.history.post).toHaveLength(1); - }); - - it('does not make post request if confirmation is cancelled', async () => { - mock.onPost(scheduledJobAction.path).reply(HTTP_STATUS_OK); - confirmAction.mockResolvedValueOnce(false); - - findAllDropdownItems().at(0).vm.$emit('click'); - - expect(confirmAction).toHaveBeenCalled(); - - await waitForPromises(); - - expect(mock.history.post).toHaveLength(0); - }); - - it('displays the remaining time in the dropdown', () => { - expect(findAllCountdowns().at(0).props('endDateString')).toBe( - scheduledJobAction.scheduled_at, - ); - }); - - it('displays 00:00:00 for expired jobs in the dropdown', () => { - expect(findAllCountdowns().at(1).props('endDateString')).toBe(expiredJobAction.scheduled_at); - }); - }); -}); diff --git a/spec/frontend/repository/components/fork_info_spec.js b/spec/frontend/repository/components/fork_info_spec.js index 6b3d7552bb3..8521f91a6c7 100644 --- a/spec/frontend/repository/components/fork_info_spec.js +++ b/spec/frontend/repository/components/fork_info_spec.js @@ -224,7 +224,7 @@ describe('ForkInfo component', () => { ); }); - it('does not render Update Fork button', async () => { + it('does not render Update Fork button', () => { expect(findUpdateForkButton().exists()).toBe(false); }); }); diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 38260c5b1cd..02b505c828c 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -63,7 +63,7 @@ describe('Repository table row component', () => { const findRouterLink = () => wrapper.findComponent(RouterLinkStub); const findIntersectionObserver = () => wrapper.findComponent(GlIntersectionObserver); - it('renders table row', async () => { + it('renders table row', () => { factory({ propsData: { id: '1', @@ -77,7 +77,7 @@ describe('Repository table row component', () => { expect(wrapper.element).toMatchSnapshot(); }); - it('renders a symlink table row', async () => { + it('renders a symlink table row', () => { factory({ propsData: { id: '1', @@ -92,7 +92,7 @@ describe('Repository table row component', () => { expect(wrapper.element).toMatchSnapshot(); }); - it('renders table row for path with special character', async () => { + it('renders table row for path with special character', () => { factory({ propsData: { id: '1', @@ -128,7 +128,7 @@ describe('Repository table row component', () => { ${'tree'} | ${RouterLinkStub} | ${'RouterLink'} ${'blob'} | ${RouterLinkStub} | ${'RouterLink'} ${'commit'} | ${'a'} | ${'hyperlink'} - `('renders a $componentName for type $type', async ({ type, component }) => { + `('renders a $componentName for type $type', ({ type, component }) => { factory({ propsData: { id: '1', @@ -146,7 +146,7 @@ describe('Repository table row component', () => { path ${'test#'} ${'Änderungen'} - `('renders link for $path', async ({ path }) => { + `('renders link for $path', ({ path }) => { factory({ propsData: { id: '1', @@ -162,7 +162,7 @@ describe('Repository table row component', () => { }); }); - it('renders link for directory with hash', async () => { + it('renders link for directory with hash', () => { factory({ propsData: { id: '1', @@ -176,7 +176,7 @@ describe('Repository table row component', () => { expect(wrapper.find('.tree-item-link').props('to')).toEqual({ path: '/-/tree/main/test%23' }); }); - it('renders commit ID for submodule', async () => { + it('renders commit ID for submodule', () => { factory({ propsData: { id: '1', @@ -190,7 +190,7 @@ describe('Repository table row component', () => { expect(wrapper.find('.commit-sha').text()).toContain('1'); }); - it('renders link with href', async () => { + it('renders link with href', () => { factory({ propsData: { id: '1', @@ -205,7 +205,7 @@ describe('Repository table row component', () => { expect(wrapper.find('a').attributes('href')).toEqual('https://test.com'); }); - it('renders LFS badge', async () => { + it('renders LFS badge', () => { factory({ propsData: { id: '1', @@ -220,7 +220,7 @@ describe('Repository table row component', () => { expect(findBadge().exists()).toBe(true); }); - it('renders commit and web links with href for submodule', async () => { + it('renders commit and web links with href for submodule', () => { factory({ propsData: { id: '1', @@ -237,7 +237,7 @@ describe('Repository table row component', () => { expect(wrapper.findComponent(GlLink).attributes('href')).toEqual('https://test.com/commit'); }); - it('renders lock icon', async () => { + it('renders lock icon', () => { factory({ propsData: { id: '1', diff --git a/spec/frontend/search/sidebar/components/scope_new_navigation_spec.js b/spec/frontend/search/sidebar/components/scope_new_navigation_spec.js new file mode 100644 index 00000000000..105beae8638 --- /dev/null +++ b/spec/frontend/search/sidebar/components/scope_new_navigation_spec.js @@ -0,0 +1,83 @@ +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; +import Vuex from 'vuex'; +import ScopeNewNavigation from '~/search/sidebar/components/scope_new_navigation.vue'; +import NavItem from '~/super_sidebar/components/nav_item.vue'; +import { MOCK_QUERY, MOCK_NAVIGATION, MOCK_NAVIGATION_ITEMS } from '../../mock_data'; + +Vue.use(Vuex); + +describe('ScopeNewNavigation', () => { + let wrapper; + + const actionSpies = { + fetchSidebarCount: jest.fn(), + }; + + const getterSpies = { + currentScope: jest.fn(() => 'issues'), + navigationItems: jest.fn(() => MOCK_NAVIGATION_ITEMS), + }; + + const createComponent = (initialState) => { + const store = new Vuex.Store({ + state: { + urlQuery: MOCK_QUERY, + navigation: MOCK_NAVIGATION, + ...initialState, + }, + actions: actionSpies, + getters: getterSpies, + }); + + wrapper = shallowMount(ScopeNewNavigation, { + store, + stubs: { + NavItem, + }, + }); + }; + + const findNavElement = () => wrapper.findComponent('nav'); + const findNavItems = () => wrapper.findAllComponents(NavItem); + const findNavItemActive = () => wrapper.find('[aria-current=page]'); + const findNavItemActiveLabel = () => + findNavItemActive().find('[class="gl-pr-3 gl-text-gray-900 gl-truncate-end"]'); + + describe('scope navigation', () => { + beforeEach(() => { + createComponent({ urlQuery: { ...MOCK_QUERY, search: 'test' } }); + }); + + it('renders section', () => { + expect(findNavElement().exists()).toBe(true); + }); + + it('calls proper action when rendered', async () => { + await nextTick(); + expect(actionSpies.fetchSidebarCount).toHaveBeenCalled(); + }); + + it('renders all nav item components', () => { + expect(findNavItems()).toHaveLength(9); + }); + + it('has all proper links', () => { + const linkAtPosition = 3; + const { link } = MOCK_NAVIGATION[Object.keys(MOCK_NAVIGATION)[linkAtPosition]]; + + expect(findNavItems().at(linkAtPosition).findComponent('a').attributes('href')).toBe(link); + }); + }); + + describe('scope navigation sets proper state with url scope set', () => { + beforeEach(() => { + createComponent(); + }); + + it('has correct active item', () => { + expect(findNavItemActive().exists()).toBe(true); + expect(findNavItemActiveLabel().text()).toBe('Issues'); + }); + }); +}); diff --git a/spec/frontend/super_sidebar/components/create_menu_spec.js b/spec/frontend/super_sidebar/components/create_menu_spec.js index b24c6b8de7f..e05b5d30e69 100644 --- a/spec/frontend/super_sidebar/components/create_menu_spec.js +++ b/spec/frontend/super_sidebar/components/create_menu_spec.js @@ -1,3 +1,4 @@ +import { nextTick } from 'vue'; import { GlDisclosureDropdown, GlTooltip } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { __ } from '~/locale'; @@ -23,6 +24,14 @@ describe('CreateMenu component', () => { createWrapper(); }); + it('passes popper options to the dropdown', () => { + createWrapper(); + + expect(findGlDisclosureDropdown().props('popperOptions')).toEqual({ + modifiers: [{ name: 'offset', options: { offset: [-147, 4] } }], + }); + }); + it("sets the toggle's label", () => { expect(findGlDisclosureDropdown().props('toggleText')).toBe(__('Create new...')); }); @@ -35,5 +44,20 @@ describe('CreateMenu component', () => { expect(findGlDisclosureDropdown().props('toggleId')).toBe(wrapper.vm.$options.toggleId); expect(findGlTooltip().props('target')).toBe(`#${wrapper.vm.$options.toggleId}`); }); + + it('hides the tooltip when the dropdown is opened', async () => { + findGlDisclosureDropdown().vm.$emit('shown'); + await nextTick(); + + expect(findGlTooltip().exists()).toBe(false); + }); + + it('shows the tooltip when the dropdown is closed', async () => { + findGlDisclosureDropdown().vm.$emit('shown'); + findGlDisclosureDropdown().vm.$emit('hidden'); + await nextTick(); + + expect(findGlTooltip().exists()).toBe(true); + }); }); }); diff --git a/spec/frontend/super_sidebar/components/help_center_spec.js b/spec/frontend/super_sidebar/components/help_center_spec.js index 839677f29d5..4c0e7a89a43 100644 --- a/spec/frontend/super_sidebar/components/help_center_spec.js +++ b/spec/frontend/super_sidebar/components/help_center_spec.js @@ -88,6 +88,12 @@ describe('HelpCenter component', () => { ]); }); + it('passes popper options to the dropdown', () => { + expect(findDropdown().props('popperOptions')).toEqual({ + modifiers: [{ name: 'offset', options: { offset: [-4, 4] } }], + }); + }); + describe('with Gitlab version check feature enabled', () => { beforeEach(() => { createWrapper({ ...sidebarData, show_version_check: true }); diff --git a/spec/frontend/super_sidebar/components/user_menu_spec.js b/spec/frontend/super_sidebar/components/user_menu_spec.js index 25bcd322d32..995095d0e35 100644 --- a/spec/frontend/super_sidebar/components/user_menu_spec.js +++ b/spec/frontend/super_sidebar/components/user_menu_spec.js @@ -14,7 +14,8 @@ describe('UserMenu component', () => { const GlEmoji = { template: '<img/>' }; const toggleNewNavEndpoint = invalidUrl; - const showDropdown = () => wrapper.findComponent(GlDisclosureDropdown).vm.$emit('shown'); + const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown); + const showDropdown = () => findDropdown().vm.$emit('shown'); const createWrapper = (userDataChanges = {}) => { wrapper = mountExtended(UserMenu, { @@ -36,6 +37,14 @@ describe('UserMenu component', () => { trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); }; + it('passes popper options to the dropdown', () => { + createWrapper(); + + expect(findDropdown().props('popperOptions')).toEqual({ + modifiers: [{ name: 'offset', options: { offset: [-211, 4] } }], + }); + }); + describe('Toggle button', () => { let toggle; diff --git a/spec/frontend/tags/components/delete_tag_modal_spec.js b/spec/frontend/tags/components/delete_tag_modal_spec.js index 8438bdb7db0..8ec9925563a 100644 --- a/spec/frontend/tags/components/delete_tag_modal_spec.js +++ b/spec/frontend/tags/components/delete_tag_modal_spec.js @@ -69,7 +69,7 @@ describe('Delete tag modal', () => { expect(submitFormSpy).toHaveBeenCalled(); }); - it('calls show on the modal when a `openModal` event is received through the event hub', async () => { + it('calls show on the modal when a `openModal` event is received through the event hub', () => { const showSpy = jest.spyOn(wrapper.vm.$refs.modal, 'show'); eventHub.$emit('openModal', { diff --git a/spec/frontend/vue_merge_request_widget/components/mr_widget_rebase_spec.js b/spec/frontend/vue_merge_request_widget/components/mr_widget_rebase_spec.js index f284ec98a73..9bd46267daa 100644 --- a/spec/frontend/vue_merge_request_widget/components/mr_widget_rebase_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/mr_widget_rebase_spec.js @@ -1,56 +1,101 @@ +import Vue, { nextTick } from 'vue'; +import VueApollo from 'vue-apollo'; import { GlModal } from '@gitlab/ui'; -import { mount } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import BoldText from '~/vue_merge_request_widget/components/bold_text.vue'; import WidgetRebase from '~/vue_merge_request_widget/components/states/mr_widget_rebase.vue'; +import rebaseQuery from '~/vue_merge_request_widget/queries/states/rebase.query.graphql'; import eventHub from '~/vue_merge_request_widget/event_hub'; +import StateContainer from '~/vue_merge_request_widget/components/state_container.vue'; import toast from '~/vue_shared/plugins/global_toast'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; +import { stubComponent } from 'helpers/stub_component'; jest.mock('~/vue_shared/plugins/global_toast'); let wrapper; - -function createWrapper(propsData, provideData) { - wrapper = mount(WidgetRebase, { - provide: { - ...provideData, +const showMock = jest.fn(); + +const mockPipelineNodes = [ + { + id: '1', + project: { + id: '2', + fullPath: 'user/forked', }, - propsData, - data() { - return { - state: { - rebaseInProgress: propsData.mr.rebaseInProgress, - targetBranch: propsData.mr.targetBranch, + }, +]; + +const mockQueryHandler = ({ + rebaseInProgress = false, + targetBranch = '', + pushToSourceBranch = false, + nodes = mockPipelineNodes, +} = {}) => + jest.fn().mockResolvedValue({ + data: { + project: { + id: '1', + mergeRequest: { + id: '2', + rebaseInProgress, + targetBranch, userPermissions: { - pushToSourceBranch: propsData.mr.canPushToSourceBranch, + pushToSourceBranch, + }, + pipelines: { + nodes, }, - pipelines: propsData.mr.pipelines, }, - }; + }, + }, + }); + +const createMockApolloProvider = (handler) => { + Vue.use(VueApollo); + + return createMockApollo([[rebaseQuery, handler]]); +}; + +function createWrapper({ propsData = {}, provideData = {}, handler = mockQueryHandler() } = {}) { + wrapper = shallowMountExtended(WidgetRebase, { + apolloProvider: createMockApolloProvider(handler), + provide: { + ...provideData, }, - mocks: { - $apollo: { - queries: { - state: { loading: false }, + propsData: { + mr: {}, + service: {}, + ...propsData, + }, + stubs: { + StateContainer, + GlModal: stubComponent(GlModal, { + methods: { + show: showMock, }, - }, + }), }, }); } describe('Merge request widget rebase component', () => { - const findRebaseMessage = () => wrapper.find('[data-testid="rebase-message"]'); + const findRebaseMessage = () => wrapper.findByTestId('rebase-message'); + const findBoldText = () => wrapper.findComponent(BoldText); const findRebaseMessageText = () => findRebaseMessage().text(); - const findStandardRebaseButton = () => wrapper.find('[data-testid="standard-rebase-button"]'); - const findRebaseWithoutCiButton = () => wrapper.find('[data-testid="rebase-without-ci-button"]'); + const findStandardRebaseButton = () => wrapper.findByTestId('standard-rebase-button'); + const findRebaseWithoutCiButton = () => wrapper.findByTestId('rebase-without-ci-button'); const findModal = () => wrapper.findComponent(GlModal); describe('while rebasing', () => { - it('should show progress message', () => { + it('should show progress message', async () => { createWrapper({ - mr: { rebaseInProgress: true }, - service: {}, + handler: mockQueryHandler({ rebaseInProgress: true }), }); + await waitForPromises(); + expect(findRebaseMessageText()).toContain('Rebase in progress'); }); }); @@ -59,95 +104,110 @@ describe('Merge request widget rebase component', () => { const rebaseMock = jest.fn().mockResolvedValue(); const pollMock = jest.fn().mockResolvedValue({}); - it('renders the warning message', () => { + it('renders the warning message', async () => { createWrapper({ - mr: { + handler: mockQueryHandler({ rebaseInProgress: false, - canPushToSourceBranch: true, - }, - service: { - rebase: rebaseMock, - poll: pollMock, - }, + pushToSourceBranch: false, + }), }); - const text = findRebaseMessageText(); + await waitForPromises(); - expect(text).toContain('Merge blocked'); - expect(text.replace(/\s\s+/g, ' ')).toContain( + expect(findBoldText().props('message')).toContain('Merge blocked'); + expect(findBoldText().props('message').replace(/\s\s+/g, ' ')).toContain( 'the source branch must be rebased onto the target branch', ); }); it('renders an error message when rebasing has failed', async () => { createWrapper({ - mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, - }, - service: { - rebase: rebaseMock, - poll: pollMock, + propsData: { + service: { + rebase: jest.fn().mockRejectedValue({ + response: { + data: { + merge_error: 'Something went wrong!', + }, + }, + }), + }, }, + handler: mockQueryHandler({ pushToSourceBranch: true }), }); + await waitForPromises(); - // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details - // eslint-disable-next-line no-restricted-syntax - wrapper.setData({ rebasingError: 'Something went wrong!' }); + findStandardRebaseButton().vm.$emit('click'); - await nextTick(); + await waitForPromises(); expect(findRebaseMessageText()).toContain('Something went wrong!'); }); describe('Rebase buttons', () => { - beforeEach(() => { + it('renders both buttons', async () => { createWrapper({ - mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, - }, - service: { - rebase: rebaseMock, - poll: pollMock, - }, + handler: mockQueryHandler({ pushToSourceBranch: true }), }); - }); - it('renders both buttons', () => { + await waitForPromises(); + expect(findRebaseWithoutCiButton().exists()).toBe(true); expect(findStandardRebaseButton().exists()).toBe(true); }); it('starts the rebase when clicking', async () => { - findStandardRebaseButton().vm.$emit('click'); + createWrapper({ + propsData: { + service: { + rebase: rebaseMock, + poll: pollMock, + }, + }, + handler: mockQueryHandler({ pushToSourceBranch: true }), + }); - await nextTick(); + await waitForPromises(); + + findStandardRebaseButton().vm.$emit('click'); expect(rebaseMock).toHaveBeenCalledWith({ skipCi: false }); }); it('starts the CI-skipping rebase when clicking on "Rebase without CI"', async () => { - findRebaseWithoutCiButton().vm.$emit('click'); + createWrapper({ + propsData: { + service: { + rebase: rebaseMock, + poll: pollMock, + }, + }, + handler: mockQueryHandler({ pushToSourceBranch: true }), + }); - await nextTick(); + await waitForPromises(); + + findRebaseWithoutCiButton().vm.$emit('click'); expect(rebaseMock).toHaveBeenCalledWith({ skipCi: true }); }); }); describe('Rebase when pipelines must succeed is enabled', () => { - beforeEach(() => { + beforeEach(async () => { createWrapper({ - mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, - onlyAllowMergeIfPipelineSucceeds: true, - }, - service: { - rebase: rebaseMock, - poll: pollMock, + propsData: { + mr: { + onlyAllowMergeIfPipelineSucceeds: true, + }, + service: { + rebase: rebaseMock, + poll: pollMock, + }, }, + handler: mockQueryHandler({ pushToSourceBranch: true }), }); + + await waitForPromises(); }); it('renders only the rebase button', () => { @@ -165,19 +225,22 @@ describe('Merge request widget rebase component', () => { }); describe('Rebase when pipelines must succeed and skipped pipelines are considered successful are enabled', () => { - beforeEach(() => { + beforeEach(async () => { createWrapper({ - mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, - onlyAllowMergeIfPipelineSucceeds: true, - allowMergeOnSkippedPipeline: true, - }, - service: { - rebase: rebaseMock, - poll: pollMock, + propsData: { + mr: { + onlyAllowMergeIfPipelineSucceeds: true, + allowMergeOnSkippedPipeline: true, + }, + service: { + rebase: rebaseMock, + poll: pollMock, + }, }, + handler: mockQueryHandler({ pushToSourceBranch: true }), }); + + await waitForPromises(); }); it('renders both rebase buttons', () => { @@ -203,51 +266,36 @@ describe('Merge request widget rebase component', () => { }); describe('security modal', () => { - it('displays modal and rebases after confirming', () => { - createWrapper( - { + it('displays modal and rebases after confirming', async () => { + createWrapper({ + propsData: { mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, sourceProjectFullPath: 'user/forked', targetProjectFullPath: 'root/original', - pipelines: { - nodes: [ - { - id: '1', - project: { - id: '2', - fullPath: 'user/forked', - }, - }, - ], - }, }, service: { rebase: rebaseMock, poll: pollMock, }, }, - { canCreatePipelineInTargetProject: true }, - ); + provideData: { canCreatePipelineInTargetProject: true }, + handler: mockQueryHandler({ pushToSourceBranch: true }), + }); - findModal().vm.show = jest.fn(); + await waitForPromises(); findStandardRebaseButton().vm.$emit('click'); - - expect(findModal().vm.show).toHaveBeenCalled(); + expect(showMock).toHaveBeenCalled(); findModal().vm.$emit('primary'); expect(rebaseMock).toHaveBeenCalled(); }); - it('does not display modal', () => { - createWrapper( - { + it('does not display modal', async () => { + createWrapper({ + propsData: { mr: { - rebaseInProgress: false, - canPushToSourceBranch: true, sourceProjectFullPath: 'user/forked', targetProjectFullPath: 'root/original', }, @@ -256,14 +304,15 @@ describe('Merge request widget rebase component', () => { poll: pollMock, }, }, - { canCreatePipelineInTargetProject: false }, - ); + provideData: { canCreatePipelineInTargetProject: false }, + handler: mockQueryHandler({ pushToSourceBranch: true }), + }); - findModal().vm.show = jest.fn(); + await waitForPromises(); findStandardRebaseButton().vm.$emit('click'); - expect(findModal().vm.show).not.toHaveBeenCalled(); + expect(showMock).not.toHaveBeenCalled(); expect(rebaseMock).toHaveBeenCalled(); }); }); @@ -273,42 +322,41 @@ describe('Merge request widget rebase component', () => { const exampleTargetBranch = 'fake-branch-to-test-with'; describe('UI text', () => { - beforeEach(() => { + beforeEach(async () => { createWrapper({ - mr: { - rebaseInProgress: false, - canPushToSourceBranch: false, + handler: mockQueryHandler({ + pushToSourceBranch: false, targetBranch: exampleTargetBranch, - }, - service: {}, + }), }); + + await waitForPromises(); }); it('renders a message explaining user does not have permissions', () => { - const text = findRebaseMessageText(); - - expect(text).toContain('Merge blocked:'); - expect(text).toContain('the source branch must be rebased'); + expect(findBoldText().props('message')).toContain('Merge blocked'); + expect(findBoldText().props('message')).toContain('the source branch must be rebased'); }); it('renders the correct target branch name', () => { - const text = findRebaseMessageText(); - - expect(text).toContain('Merge blocked:'); - expect(text).toContain('the source branch must be rebased onto the target branch.'); + expect(findBoldText().props('message')).toContain('Merge blocked:'); + expect(findBoldText().props('message')).toContain( + 'the source branch must be rebased onto the target branch.', + ); }); }); - it('does render the "Rebase without pipeline" button', () => { + it('does render the "Rebase without pipeline" button', async () => { createWrapper({ - mr: { + handler: mockQueryHandler({ rebaseInProgress: false, - canPushToSourceBranch: false, + pushToSourceBranch: false, targetBranch: exampleTargetBranch, - }, - service: {}, + }), }); + await waitForPromises(); + expect(findRebaseWithoutCiButton().exists()).toBe(true); }); }); @@ -317,24 +365,27 @@ describe('Merge request widget rebase component', () => { it('checkRebaseStatus', async () => { jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); createWrapper({ - mr: {}, - service: { - rebase() { - return Promise.resolve(); - }, - poll() { - return Promise.resolve({ - data: { - rebase_in_progress: false, - should_be_rebased: false, - merge_error: null, - }, - }); + propsData: { + service: { + rebase() { + return Promise.resolve(); + }, + poll() { + return Promise.resolve({ + data: { + rebase_in_progress: false, + should_be_rebased: false, + merge_error: null, + }, + }); + }, }, }, }); - wrapper.vm.rebase(); + await waitForPromises(); + + findRebaseWithoutCiButton().vm.$emit('click'); // Wait for the rebase request await nextTick(); diff --git a/spec/frontend_integration/content_editor/content_editor_integration_spec.js b/spec/frontend_integration/content_editor/content_editor_integration_spec.js index a80c4db19b5..b3997fdb676 100644 --- a/spec/frontend_integration/content_editor/content_editor_integration_spec.js +++ b/spec/frontend_integration/content_editor/content_editor_integration_spec.js @@ -66,7 +66,7 @@ describe('content_editor', () => { expect(wrapper.findByTestId('content-editor-loading-indicator').exists()).toBe(false); }); - it('displays the initial content', async () => { + it('displays the initial content', () => { expect(wrapper.html()).toContain(initialContent); }); }); diff --git a/spec/frontend_integration/ide/user_opens_ide_spec.js b/spec/frontend_integration/ide/user_opens_ide_spec.js index d4656b1098e..2f89b3c0612 100644 --- a/spec/frontend_integration/ide/user_opens_ide_spec.js +++ b/spec/frontend_integration/ide/user_opens_ide_spec.js @@ -23,7 +23,7 @@ describe('IDE: User opens IDE', () => { resetHTMLFixture(); }); - it('shows loading indicator while the IDE is loading', async () => { + it('shows loading indicator while the IDE is loading', () => { vm = startWebIDE(container); expect(container.querySelectorAll('.multi-file-loading-container')).toHaveLength(3); @@ -52,7 +52,7 @@ describe('IDE: User opens IDE', () => { await screen.findByText('README'); // wait for file tree to load }); - it('shows a list of files in the left sidebar', async () => { + it('shows a list of files in the left sidebar', () => { expect(ideHelper.getFilesList()).toEqual( expect.arrayContaining(['README', 'LICENSE', 'CONTRIBUTING.md']), ); diff --git a/spec/frontend_integration/snippets/snippets_notes_spec.js b/spec/frontend_integration/snippets/snippets_notes_spec.js index bfda86a48a2..27be7793ce6 100644 --- a/spec/frontend_integration/snippets/snippets_notes_spec.js +++ b/spec/frontend_integration/snippets/snippets_notes_spec.js @@ -6,7 +6,7 @@ import initDeprecatedNotes from '~/init_deprecated_notes'; import { setHTMLFixture } from 'helpers/fixtures'; describe('Integration Snippets notes', () => { - beforeEach(async () => { + beforeEach(() => { setHTMLFixture(htmlSnippetsShow); // Check if we have to Load GFM Input diff --git a/spec/lib/api/entities/clusters/agents/authorizations/ci_access_spec.rb b/spec/lib/api/entities/clusters/agents/authorizations/ci_access_spec.rb index 5f41ae6af4b..4dd20f26dc9 100644 --- a/spec/lib/api/entities/clusters/agents/authorizations/ci_access_spec.rb +++ b/spec/lib/api/entities/clusters/agents/authorizations/ci_access_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Entities::Clusters::Agents::Authorizations::CiAccess, feature_category: :kubernetes_management do +RSpec.describe API::Entities::Clusters::Agents::Authorizations::CiAccess, feature_category: :deployment_management do subject { described_class.new(authorization).as_json } shared_examples 'generic authorization' do diff --git a/spec/lib/gitlab/kas/user_access_spec.rb b/spec/lib/gitlab/kas/user_access_spec.rb index 8795ad565d0..a8296d23a18 100644 --- a/spec/lib/gitlab/kas/user_access_spec.rb +++ b/spec/lib/gitlab/kas/user_access_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Kas::UserAccess, feature_category: :kubernetes_management do +RSpec.describe Gitlab::Kas::UserAccess, feature_category: :deployment_management do describe '.enabled?' do subject { described_class.enabled? } diff --git a/spec/lib/gitlab/resource_events/assignment_event_recorder_spec.rb b/spec/lib/gitlab/resource_events/assignment_event_recorder_spec.rb new file mode 100644 index 00000000000..b15f95dbd9c --- /dev/null +++ b/spec/lib/gitlab/resource_events/assignment_event_recorder_spec.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::ResourceEvents::AssignmentEventRecorder, feature_category: :value_stream_management do + using RSpec::Parameterized::TableSyntax + + let_it_be(:user1) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:user3) { create(:user) } + + let_it_be_with_refind(:issue_with_two_assignees) { create(:issue, assignees: [user1, user2]) } + let_it_be_with_refind(:mr_with_no_assignees) { create(:merge_request) } + let_it_be_with_refind(:mr_with_one_assignee) { create(:merge_request, assignee: [user3]) } + + let(:parent_records) do + { + issue_with_two_assignees: issue_with_two_assignees, + mr_with_no_assignees: mr_with_no_assignees, + mr_with_one_assignee: mr_with_one_assignee + } + end + + let(:user_records) do + { + user1: user1, + user2: user2, + user3: user3 + } + end + + where(:parent, :new_assignees, :assignee_history) do + :issue_with_two_assignees | [:user1, :user2, :user3] | [[:user3, :add]] + :issue_with_two_assignees | [:user1, :user3] | [[:user2, :remove], [:user3, :add]] + :issue_with_two_assignees | [:user1] | [[:user2, :remove]] + :issue_with_two_assignees | [] | [[:user1, :remove], [:user2, :remove]] + :mr_with_no_assignees | [:user1] | [[:user1, :add]] + :mr_with_no_assignees | [] | [] + :mr_with_one_assignee | [:user3] | [] + :mr_with_one_assignee | [:user1] | [[:user3, :remove], [:user1, :add]] + end + + with_them do + it 'records the assignment history corrently' do + parent_record = parent_records[parent] + old_assignees = parent_record.assignees.to_a + parent_record.assignees = new_assignees.map { |user_variable_name| user_records[user_variable_name] } + + described_class.new(parent: parent_record, old_assignees: old_assignees).record + + expected_records = assignee_history.map do |user_variable_name, action| + have_attributes({ + user_id: user_records[user_variable_name].id, + action: action.to_s + }) + end + + expect(parent_record.assignment_events).to match_array(expected_records) + end + end + + context 'when batching' do + it 'invokes multiple insert queries' do + stub_const('Gitlab::ResourceEvents::AssignmentEventRecorder::BATCH_SIZE', 1) + + expect(ResourceEvents::MergeRequestAssignmentEvent).to receive(:insert_all).twice + + described_class.new(parent: mr_with_one_assignee, old_assignees: [user1]).record # 1 assignment, 1 unassignment + end + end + + context 'when duplicated old assignees were given' do + it 'deduplicates the records' do + expect do + described_class.new(parent: mr_with_one_assignee, old_assignees: [user3, user2, user2]).record + end.to change { ResourceEvents::MergeRequestAssignmentEvent.count }.by(1) + end + end + + context 'when the record_issue_and_mr_assignee_events FF is off' do + before do + stub_feature_flags(record_issue_and_mr_assignee_events: false) + end + + it 'does nothing' do + expect do + described_class.new(parent: mr_with_one_assignee, old_assignees: [user2, user3]).record + end.not_to change { mr_with_one_assignee.assignment_events.count } + end + end +end diff --git a/spec/lib/gitlab/utils/strong_memoize_spec.rb b/spec/lib/gitlab/utils/strong_memoize_spec.rb index 44da0aad6fa..ea8083e7d7f 100644 --- a/spec/lib/gitlab/utils/strong_memoize_spec.rb +++ b/spec/lib/gitlab/utils/strong_memoize_spec.rb @@ -262,19 +262,21 @@ RSpec.describe Gitlab::Utils::StrongMemoize, feature_category: :shared do describe '.strong_memoize_attr' do [nil, false, true, 'value', 0, [0]].each do |value| - let(:value) { value } + context "with value '#{value}'" do + let(:value) { value } - context "memoized after method definition with value #{value}" do - let(:method_name) { :method_name_attr } + context 'memoized after method definition' do + let(:method_name) { :method_name_attr } - it_behaves_like 'caching the value' + it_behaves_like 'caching the value' - it 'calls the existing .method_added' do - expect(klass.method_added_list).to include(:method_name_attr) - end + it 'calls the existing .method_added' do + expect(klass.method_added_list).to include(:method_name_attr) + end - it 'retains method arity' do - expect(klass.instance_method(method_name).arity).to eq(0) + it 'retains method arity' do + expect(klass.instance_method(method_name).arity).to eq(0) + end end end end diff --git a/spec/migrations/bulk_insert_cluster_enabled_grants_spec.rb b/spec/migrations/bulk_insert_cluster_enabled_grants_spec.rb index e85489198ee..71ffdd66d62 100644 --- a/spec/migrations/bulk_insert_cluster_enabled_grants_spec.rb +++ b/spec/migrations/bulk_insert_cluster_enabled_grants_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe BulkInsertClusterEnabledGrants, :migration, feature_category: :kubernetes_management do +RSpec.describe BulkInsertClusterEnabledGrants, :migration, feature_category: :deployment_management do let(:migration) { described_class.new } let(:cluster_enabled_grants) { table(:cluster_enabled_grants) } diff --git a/spec/models/clusters/agents/authorizations/ci_access/group_authorization_spec.rb b/spec/models/clusters/agents/authorizations/ci_access/group_authorization_spec.rb index 2864d6583bd..deabebde760 100644 --- a/spec/models/clusters/agents/authorizations/ci_access/group_authorization_spec.rb +++ b/spec/models/clusters/agents/authorizations/ci_access/group_authorization_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::GroupAuthorization, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::GroupAuthorization, feature_category: :deployment_management do it { is_expected.to belong_to(:agent).class_name('Clusters::Agent').required } it { is_expected.to belong_to(:group).class_name('::Group').required } diff --git a/spec/models/clusters/agents/authorizations/ci_access/implicit_authorization_spec.rb b/spec/models/clusters/agents/authorizations/ci_access/implicit_authorization_spec.rb index 9a4f0c28687..427858c7529 100644 --- a/spec/models/clusters/agents/authorizations/ci_access/implicit_authorization_spec.rb +++ b/spec/models/clusters/agents/authorizations/ci_access/implicit_authorization_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::ImplicitAuthorization, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::ImplicitAuthorization, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } subject { described_class.new(agent: agent) } diff --git a/spec/models/clusters/agents/authorizations/ci_access/project_authorization_spec.rb b/spec/models/clusters/agents/authorizations/ci_access/project_authorization_spec.rb index 9e2b25e415e..fe5f3cb10ea 100644 --- a/spec/models/clusters/agents/authorizations/ci_access/project_authorization_spec.rb +++ b/spec/models/clusters/agents/authorizations/ci_access/project_authorization_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::ProjectAuthorization, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::ProjectAuthorization, feature_category: :deployment_management do it { is_expected.to belong_to(:agent).class_name('Clusters::Agent').required } it { is_expected.to belong_to(:project).class_name('Project').required } diff --git a/spec/models/clusters/agents/authorizations/user_access/group_authorization_spec.rb b/spec/models/clusters/agents/authorizations/user_access/group_authorization_spec.rb index d7b4ea2388f..9ed4da474c0 100644 --- a/spec/models/clusters/agents/authorizations/user_access/group_authorization_spec.rb +++ b/spec/models/clusters/agents/authorizations/user_access/group_authorization_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::UserAccess::GroupAuthorization, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::UserAccess::GroupAuthorization, feature_category: :deployment_management do it { is_expected.to belong_to(:agent).class_name('Clusters::Agent').required } it { is_expected.to belong_to(:group).class_name('::Group').required } diff --git a/spec/models/clusters/agents/authorizations/user_access/project_authorization_spec.rb b/spec/models/clusters/agents/authorizations/user_access/project_authorization_spec.rb index a51be15a9d7..79b039684ad 100644 --- a/spec/models/clusters/agents/authorizations/user_access/project_authorization_spec.rb +++ b/spec/models/clusters/agents/authorizations/user_access/project_authorization_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::UserAccess::ProjectAuthorization, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::UserAccess::ProjectAuthorization, feature_category: :deployment_management do it { is_expected.to belong_to(:agent).class_name('Clusters::Agent').required } it { is_expected.to belong_to(:project).class_name('Project').required } diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index b038eb7c03e..189affa3c88 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching, -feature_category: :kubernetes_management do +feature_category: :deployment_management do include ReactiveCachingHelpers include KubernetesHelpers diff --git a/spec/models/concerns/clusters/agents/authorizations/ci_access/config_scopes_spec.rb b/spec/models/concerns/clusters/agents/authorizations/ci_access/config_scopes_spec.rb index c632c639273..5c69ede11fc 100644 --- a/spec/models/concerns/clusters/agents/authorizations/ci_access/config_scopes_spec.rb +++ b/spec/models/concerns/clusters/agents/authorizations/ci_access/config_scopes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::ConfigScopes, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::ConfigScopes, feature_category: :deployment_management do describe '.with_available_ci_access_fields' do let(:project) { create(:project) } diff --git a/spec/models/onboarding/completion_spec.rb b/spec/models/onboarding/completion_spec.rb index 0639762b76c..dd7648f7799 100644 --- a/spec/models/onboarding/completion_spec.rb +++ b/spec/models/onboarding/completion_spec.rb @@ -37,26 +37,6 @@ RSpec.describe Onboarding::Completion, feature_category: :onboarding do it { is_expected.to eq(100) } end - - context 'with security_actions_continuous_onboarding experiment' do - let(:completed_actions) { Hash[tracked_action_columns.first, Time.current] } - - context 'when control' do - before do - stub_experiments(security_actions_continuous_onboarding: :control) - end - - it { is_expected.to eq(10) } - end - - context 'when candidate' do - before do - stub_experiments(security_actions_continuous_onboarding: :candidate) - end - - it { is_expected.to eq(8) } - end - end end describe '#completed?' do @@ -84,18 +64,18 @@ RSpec.describe Onboarding::Completion, feature_category: :onboarding do end end - context 'when security_scan_enabled' do - let(:column) { :security_scan_enabled_at } - let(:completed_actions) { { security_scan_enabled_at: security_scan_enabled_at } } + context 'when secure_dast_run' do + let(:column) { :secure_dast_run_at } + let(:completed_actions) { { secure_dast_run_at: secure_dast_run_at } } context 'when is completed' do - let(:security_scan_enabled_at) { Time.current } + let(:secure_dast_run_at) { Time.current } it { is_expected.to eq(true) } end context 'when is not completed' do - let(:security_scan_enabled_at) { nil } + let(:secure_dast_run_at) { nil } it { is_expected.to eq(false) } end diff --git a/spec/models/onboarding/progress_spec.rb b/spec/models/onboarding/progress_spec.rb index 9d91af2487a..7d169464462 100644 --- a/spec/models/onboarding/progress_spec.rb +++ b/spec/models/onboarding/progress_spec.rb @@ -187,7 +187,7 @@ RSpec.describe Onboarding::Progress do end context 'for multiple actions' do - let(:action1) { :security_scan_enabled } + let(:action1) { :secure_dast_run } let(:action2) { :secure_dependency_scanning_run } let(:actions) { [action1, action2] } @@ -206,11 +206,11 @@ RSpec.describe Onboarding::Progress do it 'does not override timestamp', :aggregate_failures do described_class.register(namespace, [action1]) - expect(described_class.find_by_namespace_id(namespace.id).security_scan_enabled_at).not_to be_nil + expect(described_class.find_by_namespace_id(namespace.id).secure_dast_run_at).not_to be_nil expect(described_class.find_by_namespace_id(namespace.id).secure_dependency_scanning_run_at).to be_nil expect { described_class.register(namespace, [action1, action2]) }.not_to change { - described_class.find_by_namespace_id(namespace.id).security_scan_enabled_at + described_class.find_by_namespace_id(namespace.id).secure_dast_run_at } expect(described_class.find_by_namespace_id(namespace.id).secure_dependency_scanning_run_at).not_to be_nil end diff --git a/spec/requests/api/admin/instance_clusters_spec.rb b/spec/requests/api/admin/instance_clusters_spec.rb index 0a72f404e89..f2e62533b78 100644 --- a/spec/requests/api/admin/instance_clusters_spec.rb +++ b/spec/requests/api/admin/instance_clusters_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::API::Admin::InstanceClusters, feature_category: :kubernetes_management do +RSpec.describe ::API::Admin::InstanceClusters, feature_category: :deployment_management do include KubernetesHelpers let_it_be(:admin_user) { create(:admin) } diff --git a/spec/requests/api/clusters/agent_tokens_spec.rb b/spec/requests/api/clusters/agent_tokens_spec.rb index b2d996e8002..a1dd6e84492 100644 --- a/spec/requests/api/clusters/agent_tokens_spec.rb +++ b/spec/requests/api/clusters/agent_tokens_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Clusters::AgentTokens, feature_category: :kubernetes_management do +RSpec.describe API::Clusters::AgentTokens, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } let_it_be(:agent_token_one) { create(:cluster_agent_token, agent: agent) } let_it_be(:revoked_agent_token) { create(:cluster_agent_token, :revoked, agent: agent) } diff --git a/spec/requests/api/clusters/agents_spec.rb b/spec/requests/api/clusters/agents_spec.rb index a09713bd6e7..12056567e9d 100644 --- a/spec/requests/api/clusters/agents_spec.rb +++ b/spec/requests/api/clusters/agents_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Clusters::Agents, feature_category: :kubernetes_management do +RSpec.describe API::Clusters::Agents, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } let(:user) { agent.created_by_user } diff --git a/spec/requests/api/graphql/mutations/clusters/agent_tokens/agent_tokens/create_spec.rb b/spec/requests/api/graphql/mutations/clusters/agent_tokens/agent_tokens/create_spec.rb index f544cef8864..ef0d44395bf 100644 --- a/spec/requests/api/graphql/mutations/clusters/agent_tokens/agent_tokens/create_spec.rb +++ b/spec/requests/api/graphql/mutations/clusters/agent_tokens/agent_tokens/create_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Create a new cluster agent token', feature_category: :kubernetes_management do +RSpec.describe 'Create a new cluster agent token', feature_category: :deployment_management do include GraphqlHelpers let_it_be(:cluster_agent) { create(:cluster_agent) } diff --git a/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb b/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb index 66e6c5cc629..1d1e72dcff9 100644 --- a/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb +++ b/spec/requests/api/graphql/mutations/clusters/agents/create_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Create a new cluster agent', feature_category: :kubernetes_management do +RSpec.describe 'Create a new cluster agent', feature_category: :deployment_management do include GraphqlHelpers let(:project) { create(:project, :public, :repository) } diff --git a/spec/requests/api/graphql/mutations/clusters/agents/delete_spec.rb b/spec/requests/api/graphql/mutations/clusters/agents/delete_spec.rb index 27a566dfb8c..b70a6282a7a 100644 --- a/spec/requests/api/graphql/mutations/clusters/agents/delete_spec.rb +++ b/spec/requests/api/graphql/mutations/clusters/agents/delete_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Delete a cluster agent', feature_category: :kubernetes_management do +RSpec.describe 'Delete a cluster agent', feature_category: :deployment_management do include GraphqlHelpers let(:cluster_agent) { create(:cluster_agent) } diff --git a/spec/requests/api/graphql/project/cluster_agents_spec.rb b/spec/requests/api/graphql/project/cluster_agents_spec.rb index 0881eb9cdc3..a50b176cdac 100644 --- a/spec/requests/api/graphql/project/cluster_agents_spec.rb +++ b/spec/requests/api/graphql/project/cluster_agents_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project.cluster_agents', feature_category: :kubernetes_management do +RSpec.describe 'Project.cluster_agents', feature_category: :deployment_management do include GraphqlHelpers let_it_be(:project) { create(:project, :public) } diff --git a/spec/requests/api/group_clusters_spec.rb b/spec/requests/api/group_clusters_spec.rb index 68c3af01e56..58d0e6a1eb5 100644 --- a/spec/requests/api/group_clusters_spec.rb +++ b/spec/requests/api/group_clusters_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::GroupClusters, feature_category: :kubernetes_management do +RSpec.describe API::GroupClusters, feature_category: :deployment_management do include KubernetesHelpers let(:current_user) { create(:user) } diff --git a/spec/requests/api/internal/kubernetes_spec.rb b/spec/requests/api/internal/kubernetes_spec.rb index 54e34d6952b..6d7f2657e1e 100644 --- a/spec/requests/api/internal/kubernetes_spec.rb +++ b/spec/requests/api/internal/kubernetes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Internal::Kubernetes, feature_category: :kubernetes_management do +RSpec.describe API::Internal::Kubernetes, feature_category: :deployment_management do let(:jwt_auth_headers) do jwt_token = JWT.encode({ 'iss' => Gitlab::Kas::JWT_ISSUER }, Gitlab::Kas.secret, 'HS256') diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb index 895192252da..c52948a4cb0 100644 --- a/spec/requests/api/project_clusters_spec.rb +++ b/spec/requests/api/project_clusters_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::ProjectClusters, feature_category: :kubernetes_management do +RSpec.describe API::ProjectClusters, feature_category: :deployment_management do include KubernetesHelpers let_it_be(:maintainer_user) { create(:user) } diff --git a/spec/requests/projects/cluster_agents_controller_spec.rb b/spec/requests/projects/cluster_agents_controller_spec.rb index d7c791fa0c1..643160ad9f3 100644 --- a/spec/requests/projects/cluster_agents_controller_spec.rb +++ b/spec/requests/projects/cluster_agents_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::ClusterAgentsController, feature_category: :kubernetes_management do +RSpec.describe Projects::ClusterAgentsController, feature_category: :deployment_management do let_it_be(:cluster_agent) { create(:cluster_agent) } let(:project) { cluster_agent.project } diff --git a/spec/requests/projects/google_cloud/configuration_controller_spec.rb b/spec/requests/projects/google_cloud/configuration_controller_spec.rb index 1aa44d1a49a..b807ff7930e 100644 --- a/spec/requests/projects/google_cloud/configuration_controller_spec.rb +++ b/spec/requests/projects/google_cloud/configuration_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::ConfigurationController, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::ConfigurationController, feature_category: :deployment_management do let_it_be(:project) { create(:project, :public) } let_it_be(:url) { project_google_cloud_configuration_path(project) } diff --git a/spec/requests/projects/google_cloud/databases_controller_spec.rb b/spec/requests/projects/google_cloud/databases_controller_spec.rb index 98e83610600..fa978a3921f 100644 --- a/spec/requests/projects/google_cloud/databases_controller_spec.rb +++ b/spec/requests/projects/google_cloud/databases_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::DatabasesController, :snowplow, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::DatabasesController, :snowplow, feature_category: :deployment_management do shared_examples 'shared examples for database controller endpoints' do include_examples 'requires `admin_project_google_cloud` role' diff --git a/spec/requests/projects/google_cloud/deployments_controller_spec.rb b/spec/requests/projects/google_cloud/deployments_controller_spec.rb index 14214b8fdfb..e9eac1e7ecd 100644 --- a/spec/requests/projects/google_cloud/deployments_controller_spec.rb +++ b/spec/requests/projects/google_cloud/deployments_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::DeploymentsController, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::DeploymentsController, feature_category: :deployment_management do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:repository) { project.repository } diff --git a/spec/requests/projects/google_cloud/gcp_regions_controller_spec.rb b/spec/requests/projects/google_cloud/gcp_regions_controller_spec.rb index de4b96a2e01..da000ec00c0 100644 --- a/spec/requests/projects/google_cloud/gcp_regions_controller_spec.rb +++ b/spec/requests/projects/google_cloud/gcp_regions_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::GcpRegionsController, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::GcpRegionsController, feature_category: :deployment_management do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:repository) { project.repository } diff --git a/spec/requests/projects/google_cloud/revoke_oauth_controller_spec.rb b/spec/requests/projects/google_cloud/revoke_oauth_controller_spec.rb index 5965953cf6f..427eff8cd76 100644 --- a/spec/requests/projects/google_cloud/revoke_oauth_controller_spec.rb +++ b/spec/requests/projects/google_cloud/revoke_oauth_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::RevokeOauthController, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::RevokeOauthController, feature_category: :deployment_management do include SessionHelpers describe 'POST #create', :snowplow, :clean_gitlab_redis_sessions, :aggregate_failures do diff --git a/spec/requests/projects/google_cloud/service_accounts_controller_spec.rb b/spec/requests/projects/google_cloud/service_accounts_controller_spec.rb index 9b048f814ef..29d4154329f 100644 --- a/spec/requests/projects/google_cloud/service_accounts_controller_spec.rb +++ b/spec/requests/projects/google_cloud/service_accounts_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::GoogleCloud::ServiceAccountsController, feature_category: :kubernetes_management do +RSpec.describe Projects::GoogleCloud::ServiceAccountsController, feature_category: :deployment_management do let_it_be(:project) { create(:project, :public) } describe 'GET index', :snowplow do diff --git a/spec/rubocop/cop/rspec/invalid_feature_category_spec.rb b/spec/rubocop/cop/rspec/invalid_feature_category_spec.rb index 0d2fd029a13..e5287f7105e 100644 --- a/spec/rubocop/cop/rspec/invalid_feature_category_spec.rb +++ b/spec/rubocop/cop/rspec/invalid_feature_category_spec.rb @@ -17,7 +17,7 @@ RSpec.describe RuboCop::Cop::RSpec::InvalidFeatureCategory, feature_category: :t it 'flags invalid feature category in nested context' do expect_offense(<<~RUBY, valid: valid_category, invalid: invalid_category) - RSpec.describe 'foo', feature_category: :%{valid} do + RSpec.describe 'foo', feature_category: :"%{valid}" do context 'bar', foo: :bar, feature_category: :%{invalid} do ^^{invalid} Please use a valid feature category. See https://docs.gitlab.com/ee/development/feature_categorization/#rspec-examples. end @@ -27,7 +27,7 @@ RSpec.describe RuboCop::Cop::RSpec::InvalidFeatureCategory, feature_category: :t it 'flags invalid feature category in examples' do expect_offense(<<~RUBY, valid: valid_category, invalid: invalid_category) - RSpec.describe 'foo', feature_category: :%{valid} do + RSpec.describe 'foo', feature_category: :"%{valid}" do it 'bar', feature_category: :%{invalid} do ^^{invalid} Please use a valid feature category. See https://docs.gitlab.com/ee/development/feature_categorization/#rspec-examples. end @@ -37,9 +37,9 @@ RSpec.describe RuboCop::Cop::RSpec::InvalidFeatureCategory, feature_category: :t it 'does not flag if feature category is valid' do expect_no_offenses(<<~RUBY) - RSpec.describe 'foo', feature_category: :#{valid_category} do - context 'bar', feature_category: :#{valid_category} do - it 'baz', feature_category: :#{valid_category} do + RSpec.describe 'foo', feature_category: :"#{valid_category}" do + context 'bar', feature_category: :"#{valid_category}" do + it 'baz', feature_category: :"#{valid_category}" do end end end @@ -50,8 +50,8 @@ RSpec.describe RuboCop::Cop::RSpec::InvalidFeatureCategory, feature_category: :t mistyped = make_typo(valid_category) expect_offense(<<~RUBY, invalid: mistyped, valid: valid_category) - RSpec.describe 'foo', feature_category: :%{invalid} do - ^^{invalid} Please use a valid feature category. Did you mean `:%{valid}`? See [...] + RSpec.describe 'foo', feature_category: :"%{invalid}" do + ^^^^{invalid} Please use a valid feature category. Did you mean `:%{valid}`? See [...] end RUBY end diff --git a/spec/services/ci/generate_kubeconfig_service_spec.rb b/spec/services/ci/generate_kubeconfig_service_spec.rb index 913aaf11d7d..a03c6ef0c9d 100644 --- a/spec/services/ci/generate_kubeconfig_service_spec.rb +++ b/spec/services/ci/generate_kubeconfig_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Ci::GenerateKubeconfigService, feature_category: :kubernetes_management do +RSpec.describe Ci::GenerateKubeconfigService, feature_category: :deployment_management do describe '#execute' do let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, group: group) } diff --git a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb index d59d8e24af6..d0496acc6fe 100644 --- a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb +++ b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb @@ -33,25 +33,6 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService, feature_category end end - context 'when the FF ci_simplify_dag_status_calculation_for_processing is disabled' do - before do - stub_feature_flags(ci_simplify_dag_status_calculation_for_processing: false) - end - - # This is duplicate of the one above but it is temporary - it 'follows transitions' do - expect(pipeline).to be_persisted - Sidekiq::Worker.drain_all # ensure that all async jobs are executed - check_expectation(test_file.dig('init', 'expect'), "init") - - test_file['transitions'].each_with_index do |transition, idx| - process_events(transition) - Sidekiq::Worker.drain_all # ensure that all async jobs are executed - check_expectation(transition['expect'], "transition:#{idx}") - end - end - end - private def check_expectation(expectation, message) diff --git a/spec/services/clusters/agent_tokens/create_service_spec.rb b/spec/services/clusters/agent_tokens/create_service_spec.rb index 519a3ba7ce5..803bd947629 100644 --- a/spec/services/clusters/agent_tokens/create_service_spec.rb +++ b/spec/services/clusters/agent_tokens/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::AgentTokens::CreateService, feature_category: :kubernetes_management do +RSpec.describe Clusters::AgentTokens::CreateService, feature_category: :deployment_management do subject(:service) { described_class.new(agent: cluster_agent, current_user: user, params: params) } let_it_be(:user) { create(:user) } diff --git a/spec/services/clusters/agent_tokens/revoke_service_spec.rb b/spec/services/clusters/agent_tokens/revoke_service_spec.rb index 9e511de0a13..a1537658723 100644 --- a/spec/services/clusters/agent_tokens/revoke_service_spec.rb +++ b/spec/services/clusters/agent_tokens/revoke_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::AgentTokens::RevokeService, feature_category: :kubernetes_management do +RSpec.describe Clusters::AgentTokens::RevokeService, feature_category: :deployment_management do describe '#execute' do subject { described_class.new(token: agent_token, current_user: user).execute } diff --git a/spec/services/clusters/agent_tokens/track_usage_service_spec.rb b/spec/services/clusters/agent_tokens/track_usage_service_spec.rb index e9e1a5f7ad9..6bea8afcc80 100644 --- a/spec/services/clusters/agent_tokens/track_usage_service_spec.rb +++ b/spec/services/clusters/agent_tokens/track_usage_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::AgentTokens::TrackUsageService, feature_category: :kubernetes_management do +RSpec.describe Clusters::AgentTokens::TrackUsageService, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } describe '#execute', :clean_gitlab_redis_cache do diff --git a/spec/services/clusters/agents/authorizations/ci_access/refresh_service_spec.rb b/spec/services/clusters/agents/authorizations/ci_access/refresh_service_spec.rb index dc803c94ccb..c12592cc071 100644 --- a/spec/services/clusters/agents/authorizations/ci_access/refresh_service_spec.rb +++ b/spec/services/clusters/agents/authorizations/ci_access/refresh_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::CiAccess::RefreshService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::CiAccess::RefreshService, feature_category: :deployment_management do describe '#execute' do let_it_be(:root_ancestor) { create(:group) } diff --git a/spec/services/clusters/agents/authorizations/user_access/refresh_service_spec.rb b/spec/services/clusters/agents/authorizations/user_access/refresh_service_spec.rb index bc0f4ea2846..da546ca44a9 100644 --- a/spec/services/clusters/agents/authorizations/user_access/refresh_service_spec.rb +++ b/spec/services/clusters/agents/authorizations/user_access/refresh_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::Authorizations::UserAccess::RefreshService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::Authorizations::UserAccess::RefreshService, feature_category: :deployment_management do describe '#execute' do let_it_be(:root_ancestor) { create(:group) } let_it_be(:agent_management_project) { create(:project, namespace: root_ancestor) } diff --git a/spec/services/clusters/agents/authorize_proxy_user_service_spec.rb b/spec/services/clusters/agents/authorize_proxy_user_service_spec.rb index c099d87f6eb..28c36e3aa36 100644 --- a/spec/services/clusters/agents/authorize_proxy_user_service_spec.rb +++ b/spec/services/clusters/agents/authorize_proxy_user_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::AuthorizeProxyUserService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::AuthorizeProxyUserService, feature_category: :deployment_management do subject(:service_response) { service.execute } let(:service) { described_class.new(user, agent) } diff --git a/spec/services/clusters/agents/create_activity_event_service_spec.rb b/spec/services/clusters/agents/create_activity_event_service_spec.rb index 3da8ecddb8d..0d784bb69c7 100644 --- a/spec/services/clusters/agents/create_activity_event_service_spec.rb +++ b/spec/services/clusters/agents/create_activity_event_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::CreateActivityEventService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::CreateActivityEventService, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } let_it_be(:token) { create(:cluster_agent_token, agent: agent) } let_it_be(:user) { create(:user) } diff --git a/spec/services/clusters/agents/create_service_spec.rb b/spec/services/clusters/agents/create_service_spec.rb index dc69dfb5e27..85607fcdf3a 100644 --- a/spec/services/clusters/agents/create_service_spec.rb +++ b/spec/services/clusters/agents/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::CreateService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::CreateService, feature_category: :deployment_management do subject(:service) { described_class.new(project, user) } let(:project) { create(:project, :public, :repository) } diff --git a/spec/services/clusters/agents/delete_expired_events_service_spec.rb b/spec/services/clusters/agents/delete_expired_events_service_spec.rb index 892cd5a70ea..7dc9c280ab4 100644 --- a/spec/services/clusters/agents/delete_expired_events_service_spec.rb +++ b/spec/services/clusters/agents/delete_expired_events_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::DeleteExpiredEventsService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::DeleteExpiredEventsService, feature_category: :deployment_management do let_it_be(:agent) { create(:cluster_agent) } describe '#execute' do diff --git a/spec/services/clusters/agents/delete_service_spec.rb b/spec/services/clusters/agents/delete_service_spec.rb index da97cdee4ca..febbb7ba5c8 100644 --- a/spec/services/clusters/agents/delete_service_spec.rb +++ b/spec/services/clusters/agents/delete_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::DeleteService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::DeleteService, feature_category: :deployment_management do subject(:service) { described_class.new(container: project, current_user: user) } let(:cluster_agent) { create(:cluster_agent) } diff --git a/spec/services/clusters/build_kubernetes_namespace_service_spec.rb b/spec/services/clusters/build_kubernetes_namespace_service_spec.rb index b1be3eb4199..fea17495914 100644 --- a/spec/services/clusters/build_kubernetes_namespace_service_spec.rb +++ b/spec/services/clusters/build_kubernetes_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::BuildKubernetesNamespaceService, feature_category: :kubernetes_management do +RSpec.describe Clusters::BuildKubernetesNamespaceService, feature_category: :deployment_management do let(:cluster) { create(:cluster, :project, :provided_by_gcp) } let(:environment) { create(:environment) } let(:project) { environment.project } diff --git a/spec/services/clusters/build_service_spec.rb b/spec/services/clusters/build_service_spec.rb index 9e71b7a8115..909d3f58c48 100644 --- a/spec/services/clusters/build_service_spec.rb +++ b/spec/services/clusters/build_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::BuildService, feature_category: :kubernetes_management do +RSpec.describe Clusters::BuildService, feature_category: :deployment_management do describe '#execute' do subject { described_class.new(cluster_subject).execute } diff --git a/spec/services/clusters/cleanup/project_namespace_service_spec.rb b/spec/services/clusters/cleanup/project_namespace_service_spec.rb index 366e4fa9c03..34311d6e830 100644 --- a/spec/services/clusters/cleanup/project_namespace_service_spec.rb +++ b/spec/services/clusters/cleanup/project_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Cleanup::ProjectNamespaceService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Cleanup::ProjectNamespaceService, feature_category: :deployment_management do describe '#execute' do subject { service.execute } diff --git a/spec/services/clusters/cleanup/service_account_service_spec.rb b/spec/services/clusters/cleanup/service_account_service_spec.rb index 881ec85b3d5..d6b5d1a5d5c 100644 --- a/spec/services/clusters/cleanup/service_account_service_spec.rb +++ b/spec/services/clusters/cleanup/service_account_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Cleanup::ServiceAccountService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Cleanup::ServiceAccountService, feature_category: :deployment_management do describe '#execute' do subject { service.execute } diff --git a/spec/services/clusters/create_service_spec.rb b/spec/services/clusters/create_service_spec.rb index 0d170f66f4a..f14cd772545 100644 --- a/spec/services/clusters/create_service_spec.rb +++ b/spec/services/clusters/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::CreateService, feature_category: :kubernetes_management do +RSpec.describe Clusters::CreateService, feature_category: :deployment_management do let(:access_token) { 'xxx' } let(:project) { create(:project) } let(:user) { create(:user) } diff --git a/spec/services/clusters/destroy_service_spec.rb b/spec/services/clusters/destroy_service_spec.rb index 2bc0099ff04..dd3e24d0e12 100644 --- a/spec/services/clusters/destroy_service_spec.rb +++ b/spec/services/clusters/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::DestroyService, feature_category: :kubernetes_management do +RSpec.describe Clusters::DestroyService, feature_category: :deployment_management do describe '#execute' do subject { described_class.new(cluster.user, params).execute(cluster) } diff --git a/spec/services/clusters/integrations/create_service_spec.rb b/spec/services/clusters/integrations/create_service_spec.rb index fa47811dc6b..b716e4f4651 100644 --- a/spec/services/clusters/integrations/create_service_spec.rb +++ b/spec/services/clusters/integrations/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Integrations::CreateService, '#execute', feature_category: :kubernetes_management do +RSpec.describe Clusters::Integrations::CreateService, '#execute', feature_category: :deployment_management do let_it_be(:project) { create(:project) } let_it_be_with_reload(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } diff --git a/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb b/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb index 2d527bb0872..9390d4b368b 100644 --- a/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb +++ b/spec/services/clusters/integrations/prometheus_health_check_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Integrations::PrometheusHealthCheckService, '#execute', feature_category: :kubernetes_management do +RSpec.describe Clusters::Integrations::PrometheusHealthCheckService, '#execute', feature_category: :deployment_management do let(:service) { described_class.new(cluster) } subject { service.execute } diff --git a/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb b/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb index 8ae34e4f9ab..7e61d690ddd 100644 --- a/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb +++ b/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Kubernetes::CreateOrUpdateNamespaceService, '#execute', feature_category: :kubernetes_management do +RSpec.describe Clusters::Kubernetes::CreateOrUpdateNamespaceService, '#execute', feature_category: :deployment_management do include KubernetesHelpers let(:cluster) { create(:cluster, :project, :provided_by_gcp) } diff --git a/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb b/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb index bdf46c19e36..ab0c5691b06 100644 --- a/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb +++ b/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService, feature_category: :deployment_management do include KubernetesHelpers let(:api_url) { 'http://111.111.111.111' } diff --git a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb index 2b77df1eb6d..439dc37e684 100644 --- a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb +++ b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Kubernetes::FetchKubernetesTokenService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Kubernetes::FetchKubernetesTokenService, feature_category: :deployment_management do include KubernetesHelpers describe '#execute' do diff --git a/spec/services/clusters/kubernetes_spec.rb b/spec/services/clusters/kubernetes_spec.rb index 7e22c2f95df..cd430f81a65 100644 --- a/spec/services/clusters/kubernetes_spec.rb +++ b/spec/services/clusters/kubernetes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Kubernetes, feature_category: :kubernetes_management do +RSpec.describe Clusters::Kubernetes, feature_category: :deployment_management do it { is_expected.to be_const_defined(:GITLAB_SERVICE_ACCOUNT_NAME) } it { is_expected.to be_const_defined(:GITLAB_SERVICE_ACCOUNT_NAMESPACE) } it { is_expected.to be_const_defined(:GITLAB_ADMIN_TOKEN_NAME) } diff --git a/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb b/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb index 8a49d90aa48..46032de600d 100644 --- a/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb +++ b/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Management::ValidateManagementProjectPermissionsService, feature_category: :kubernetes_management do +RSpec.describe Clusters::Management::ValidateManagementProjectPermissionsService, feature_category: :deployment_management do describe '#execute' do subject { described_class.new(user).execute(cluster, management_project_id) } diff --git a/spec/services/clusters/update_service_spec.rb b/spec/services/clusters/update_service_spec.rb index 31661d30f41..cc759407376 100644 --- a/spec/services/clusters/update_service_spec.rb +++ b/spec/services/clusters/update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::UpdateService, feature_category: :kubernetes_management do +RSpec.describe Clusters::UpdateService, feature_category: :deployment_management do include KubernetesHelpers describe '#execute' do diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 88dcc870ee7..46c2f03dadc 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -381,6 +381,13 @@ RSpec.describe Issues::CreateService, feature_category: :team_planning do expect(assignee.assigned_open_issues_count).to eq 1 end + + it 'records the assignee assignment event' do + result = described_class.new(container: project, current_user: user, params: opts, spam_params: spam_params).execute + + issue = result.payload[:issue] + expect(issue.assignment_events).to match([have_attributes(user_id: assignee.id, action: 'add')]) + end end context 'when duplicate label titles are given' do diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 167bff2a492..14b0a8b1cc1 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1159,6 +1159,39 @@ RSpec.describe Issues::UpdateService, :mailer, feature_category: :team_planning end end end + + it 'tracks the assignment events' do + original_assignee = issue.assignees.first! + + update_issue(assignee_ids: [user2.id]) + update_issue(assignee_ids: []) + update_issue(assignee_ids: [user3.id]) + + expected_events = [ + have_attributes({ + issue_id: issue.id, + user_id: original_assignee.id, + action: 'remove' + }), + have_attributes({ + issue_id: issue.id, + user_id: user2.id, + action: 'add' + }), + have_attributes({ + issue_id: issue.id, + user_id: user2.id, + action: 'remove' + }), + have_attributes({ + issue_id: issue.id, + user_id: user3.id, + action: 'add' + }) + ] + + expect(issue.assignment_events).to match_array(expected_events) + end end context 'updating mentions' do diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index af77abf252c..efbd693fc82 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -445,13 +445,21 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state, f } end - it 'invalidates open merge request counter for assignees when merge request is assigned' do + before do project.add_maintainer(user2) + end + it 'invalidates open merge request counter for assignees when merge request is assigned' do described_class.new(project: project, current_user: user, params: opts).execute expect(user2.assigned_open_merge_requests_count).to eq 1 end + + it 'records the assignee assignment event', :sidekiq_inline do + mr = described_class.new(project: project, current_user: user, params: opts).execute.reload + + expect(mr.assignment_events).to match([have_attributes(user_id: user2.id, action: 'add')]) + end end context "when issuable feature is private" do diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index e20ebf18e7c..000c85fd1f8 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -782,6 +782,27 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re expect(user3.assigned_open_merge_requests_count).to eq 0 expect(user2.assigned_open_merge_requests_count).to eq 1 end + + it 'records the assignment history', :sidekiq_inline do + original_assignee = merge_request.assignees.first! + + update_merge_request(assignee_ids: [user2.id]) + + expected_events = [ + have_attributes({ + merge_request_id: merge_request.id, + user_id: original_assignee.id, + action: 'remove' + }), + have_attributes({ + merge_request_id: merge_request.id, + user_id: user2.id, + action: 'add' + }) + ] + + expect(merge_request.assignment_events).to match_array(expected_events) + end end context 'when the target branch changes' do diff --git a/spec/services/spam/spam_verdict_service_spec.rb b/spec/services/spam/spam_verdict_service_spec.rb index 42993491459..e6845517aa7 100644 --- a/spec/services/spam/spam_verdict_service_spec.rb +++ b/spec/services/spam/spam_verdict_service_spec.rb @@ -318,11 +318,13 @@ RSpec.describe Spam::SpamVerdictService, feature_category: :instance_resiliency ::Spam::SpamConstants::CONDITIONAL_ALLOW, ::Spam::SpamConstants::DISALLOW, ::Spam::SpamConstants::BLOCK_USER].each do |verdict_value| - let(:verdict) { verdict_value } - let(:expected) { [verdict_value, attribs] } + context "with verdict_value:#{verdict_value}" do + let(:verdict) { verdict_value } + let(:expected) { [verdict_value, attribs] } - it "returns expected spam constant" do - expect(subject).to eq(expected) + it "returns expected spam constant" do + expect(subject).to eq(expected) + end end end end diff --git a/spec/support/shared_examples/features/rss_shared_examples.rb b/spec/support/shared_examples/features/rss_shared_examples.rb index ad865b084e1..29ecbd0dc0e 100644 --- a/spec/support/shared_examples/features/rss_shared_examples.rb +++ b/spec/support/shared_examples/features/rss_shared_examples.rb @@ -13,6 +13,12 @@ RSpec.shared_examples "it has an RSS button with current_user's feed token" do end end +RSpec.shared_examples "it has an RSS link with current_user's feed token" do + it "shows the RSS link with current_user's feed token" do + expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/ + end +end + RSpec.shared_examples "an autodiscoverable RSS feed without a feed token" do it "has an RSS autodiscovery link tag without a feed token" do expect(page).to have_css("link[type*='atom+xml']:not([href*='feed_token'])", visible: false) @@ -26,6 +32,13 @@ RSpec.shared_examples "it has an RSS button without a feed token" do end end +RSpec.shared_examples "it has an RSS link without a feed token" do + it "shows the RSS link without a feed token" do + expect(page).to have_link 'Subscribe to RSS feed' + expect(page).not_to have_link 'Subscribe to RSS feed', href: /feed_token/ + end +end + RSpec.shared_examples "updates atom feed link" do |type| it "for #{type}" do sign_in(user) diff --git a/spec/tooling/danger/stable_branch_spec.rb b/spec/tooling/danger/stable_branch_spec.rb index b0a8ab3c132..fc644413a5a 100644 --- a/spec/tooling/danger/stable_branch_spec.rb +++ b/spec/tooling/danger/stable_branch_spec.rb @@ -351,4 +351,26 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do it { is_expected.to eq(result) } end end + + describe '#valid_stable_branch?' do + it "returns false when on the default branch" do + allow(fake_helper).to receive(:mr_target_branch).and_return('main') + + expect(stable_branch.valid_stable_branch?).to be(false) + end + + it "returns true when on a stable branch" do + allow(fake_helper).to receive(:mr_target_branch).and_return('15-1-stable-ee') + allow(fake_helper).to receive(:security_mr?).and_return(false) + + expect(stable_branch.valid_stable_branch?).to be(true) + end + + it "returns false when on a stable branch on a security MR" do + allow(fake_helper).to receive(:mr_target_branch).and_return('15-1-stable-ee') + allow(fake_helper).to receive(:security_mr?).and_return(true) + + expect(stable_branch.valid_stable_branch?).to be(false) + end + end end diff --git a/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb b/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb index b439df4e119..8f2bd189d5c 100644 --- a/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb +++ b/spec/workers/clusters/agents/delete_expired_events_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Agents::DeleteExpiredEventsWorker, feature_category: :kubernetes_management do +RSpec.describe Clusters::Agents::DeleteExpiredEventsWorker, feature_category: :deployment_management do let(:agent) { create(:cluster_agent) } describe '#perform' do diff --git a/spec/workers/clusters/applications/activate_integration_worker_spec.rb b/spec/workers/clusters/applications/activate_integration_worker_spec.rb index 40a774e1818..58b133aa6de 100644 --- a/spec/workers/clusters/applications/activate_integration_worker_spec.rb +++ b/spec/workers/clusters/applications/activate_integration_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Applications::ActivateIntegrationWorker, '#perform', feature_category: :kubernetes_management do +RSpec.describe Clusters::Applications::ActivateIntegrationWorker, '#perform', feature_category: :deployment_management do context 'when cluster exists' do describe 'prometheus integration' do let(:integration_name) { 'prometheus' } diff --git a/spec/workers/clusters/applications/deactivate_integration_worker_spec.rb b/spec/workers/clusters/applications/deactivate_integration_worker_spec.rb index f02ad18c7cc..5f7cd786ea3 100644 --- a/spec/workers/clusters/applications/deactivate_integration_worker_spec.rb +++ b/spec/workers/clusters/applications/deactivate_integration_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Applications::DeactivateIntegrationWorker, '#perform', feature_category: :kubernetes_management do +RSpec.describe Clusters::Applications::DeactivateIntegrationWorker, '#perform', feature_category: :deployment_management do context 'when cluster exists' do describe 'prometheus integration' do let(:integration_name) { 'prometheus' } diff --git a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb index 008ac5249da..7119664d706 100644 --- a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb +++ b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Cleanup::ProjectNamespaceWorker, feature_category: :kubernetes_management do +RSpec.describe Clusters::Cleanup::ProjectNamespaceWorker, feature_category: :deployment_management do describe '#perform' do context 'when cluster.cleanup_status is cleanup_removing_project_namespaces' do let!(:cluster) { create(:cluster, :with_environments, :cleanup_removing_project_namespaces) } diff --git a/spec/workers/clusters/cleanup/service_account_worker_spec.rb b/spec/workers/clusters/cleanup/service_account_worker_spec.rb index 0d4df795278..cc388841c91 100644 --- a/spec/workers/clusters/cleanup/service_account_worker_spec.rb +++ b/spec/workers/clusters/cleanup/service_account_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Clusters::Cleanup::ServiceAccountWorker, feature_category: :kubernetes_management do +RSpec.describe Clusters::Cleanup::ServiceAccountWorker, feature_category: :deployment_management do describe '#perform' do let!(:cluster) { create(:cluster, :cleanup_removing_service_account) } diff --git a/spec/workers/concerns/cluster_agent_queue_spec.rb b/spec/workers/concerns/cluster_agent_queue_spec.rb index c30616d04e1..77417601748 100644 --- a/spec/workers/concerns/cluster_agent_queue_spec.rb +++ b/spec/workers/concerns/cluster_agent_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ClusterAgentQueue, feature_category: :kubernetes_management do +RSpec.describe ClusterAgentQueue, feature_category: :deployment_management do let(:worker) do Class.new do def self.name @@ -14,5 +14,5 @@ RSpec.describe ClusterAgentQueue, feature_category: :kubernetes_management do end end - it { expect(worker.get_feature_category).to eq(:kubernetes_management) } + it { expect(worker.get_feature_category).to eq(:deployment_management) } end |