diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 09:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 09:08:48 +0300 |
commit | c77b780ee080b978bd5a63f642f741e8892383dc (patch) | |
tree | 7c50ab6450a61d27485f9557b666af46ec5adfdd /spec | |
parent | 5e448ff06309854c838fb5eaa46fd05ebc5218ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 273 insertions, 264 deletions
diff --git a/spec/frontend/ci/artifacts/components/artifact_row_spec.js b/spec/frontend/ci/artifacts/components/artifact_row_spec.js index 96ddedc3a9d..8bf1138bc85 100644 --- a/spec/frontend/ci/artifacts/components/artifact_row_spec.js +++ b/spec/frontend/ci/artifacts/components/artifact_row_spec.js @@ -4,7 +4,7 @@ import { numberToHumanSize } from '~/lib/utils/number_utils'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import ArtifactRow from '~/ci/artifacts/components/artifact_row.vue'; -import { BULK_DELETE_FEATURE_FLAG, I18N_BULK_DELETE_MAX_SELECTED } from '~/ci/artifacts/constants'; +import { I18N_BULK_DELETE_MAX_SELECTED } from '~/ci/artifacts/constants'; describe('ArtifactRow component', () => { let wrapper; @@ -18,7 +18,7 @@ describe('ArtifactRow component', () => { const findDeleteButton = () => wrapper.findByTestId('job-artifact-row-delete-button'); const findCheckbox = () => wrapper.findComponent(GlFormCheckbox); - const createComponent = ({ canDestroyArtifacts = true, glFeatures = {}, props = {} } = {}) => { + const createComponent = ({ canDestroyArtifacts = true, props = {} } = {}) => { wrapper = shallowMountExtended(ArtifactRow, { propsData: { artifact, @@ -28,7 +28,7 @@ describe('ArtifactRow component', () => { isSelectedArtifactsLimitReached: false, ...props, }, - provide: { canDestroyArtifacts, glFeatures }, + provide: { canDestroyArtifacts }, stubs: { GlBadge, GlFriendlyWrap }, }); }; @@ -80,35 +80,31 @@ describe('ArtifactRow component', () => { }); describe('bulk delete checkbox', () => { - describe('with permission and feature flag enabled', () => { - it('emits selectArtifact when toggled', () => { - createComponent({ glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true } }); - - findCheckbox().vm.$emit('input', true); + it('emits selectArtifact when toggled', () => { + createComponent(); - expect(wrapper.emitted('selectArtifact')).toStrictEqual([[artifact, true]]); - }); + findCheckbox().vm.$emit('input', true); - describe('when the selected artifacts limit is reached', () => { - it('remains enabled if the artifact was selected', () => { - createComponent({ - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, - props: { isSelected: true, isSelectedArtifactsLimitReached: true }, - }); + expect(wrapper.emitted('selectArtifact')).toStrictEqual([[artifact, true]]); + }); - expect(findCheckbox().attributes('disabled')).toBeUndefined(); - expect(findCheckbox().attributes('title')).toBe(''); + describe('when the selected artifacts limit is reached', () => { + it('remains enabled if the artifact was selected', () => { + createComponent({ + props: { isSelected: true, isSelectedArtifactsLimitReached: true }, }); - it('is disabled if the artifact was not selected', () => { - createComponent({ - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, - props: { isSelected: false, isSelectedArtifactsLimitReached: true }, - }); + expect(findCheckbox().attributes('disabled')).toBeUndefined(); + expect(findCheckbox().attributes('title')).toBe(''); + }); - expect(findCheckbox().attributes('disabled')).toBeDefined(); - expect(findCheckbox().attributes('title')).toBe(I18N_BULK_DELETE_MAX_SELECTED); + it('is disabled if the artifact was not selected', () => { + createComponent({ + props: { isSelected: false, isSelectedArtifactsLimitReached: true }, }); + + expect(findCheckbox().attributes('disabled')).toBeDefined(); + expect(findCheckbox().attributes('title')).toBe(I18N_BULK_DELETE_MAX_SELECTED); }); }); @@ -117,11 +113,5 @@ describe('ArtifactRow component', () => { expect(findCheckbox().exists()).toBe(false); }); - - it('is not shown with feature flag disabled', () => { - createComponent(); - - expect(findCheckbox().exists()).toBe(false); - }); }); }); diff --git a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js index 9a16fac7406..e062140246b 100644 --- a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js +++ b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js @@ -30,7 +30,6 @@ import { JOBS_PER_PAGE, I18N_FETCH_ERROR, INITIAL_CURRENT_PAGE, - BULK_DELETE_FEATURE_FLAG, I18N_BULK_DELETE_ERROR, SELECTED_ARTIFACTS_MAX_COUNT, } from '~/ci/artifacts/constants'; @@ -152,7 +151,6 @@ describe('JobArtifactsTable component', () => { }, data = {}, canDestroyArtifacts = true, - glFeatures = {}, } = {}) => { requestHandlers = handlers; wrapper = mountExtended(JobArtifactsTable, { @@ -165,7 +163,6 @@ describe('JobArtifactsTable component', () => { projectId, canDestroyArtifacts, artifactsManagementFeedbackImagePath: 'banner/image/path', - glFeatures, }, mocks: { $toast: { @@ -332,6 +329,7 @@ describe('JobArtifactsTable component', () => { it('is disabled when there is no download path', async () => { const jobWithoutDownloadPath = { ...job, + hasArtifacts: true, archive: { downloadPath: null }, }; @@ -358,6 +356,7 @@ describe('JobArtifactsTable component', () => { it('is disabled when there is no browse path', async () => { const jobWithoutBrowsePath = { ...job, + hasArtifacts: true, browseArtifactsPath: null, }; @@ -407,75 +406,71 @@ describe('JobArtifactsTable component', () => { describe('delete button', () => { const artifactsFromJob = job.artifacts.nodes.map((node) => node.id); - describe('with delete permission and bulk delete feature flag enabled', () => { - beforeEach(async () => { - createComponent({ - canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, - }); - - await waitForPromises(); + beforeEach(async () => { + createComponent({ + canDestroyArtifacts: true, }); - it('opens the confirmation modal with the artifacts from the job', async () => { - await findDeleteButton().vm.$emit('click'); - - expect(findBulkDeleteModal().props()).toMatchObject({ - visible: true, - artifactsToDelete: artifactsFromJob, - }); - }); + await waitForPromises(); + }); - it('on confirm, deletes the artifacts from the job and shows a toast', async () => { - findDeleteButton().vm.$emit('click'); - findBulkDeleteModal().vm.$emit('primary'); + it('opens the confirmation modal with the artifacts from the job', async () => { + await findDeleteButton().vm.$emit('click'); - expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ - projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), - ids: artifactsFromJob, - }); + expect(findBulkDeleteModal().props()).toMatchObject({ + visible: true, + artifactsToDelete: artifactsFromJob, + }); + }); - await waitForPromises(); + it('on confirm, deletes the artifacts from the job and shows a toast', async () => { + findDeleteButton().vm.$emit('click'); + findBulkDeleteModal().vm.$emit('primary'); - expect(mockToastShow).toHaveBeenCalledWith( - `${artifactsFromJob.length} selected artifacts deleted`, - ); + expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ + projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), + ids: artifactsFromJob, }); - it('does not clear selected artifacts on success', async () => { - // select job 2 via checkbox - findJobCheckbox(2).vm.$emit('change', true); + await waitForPromises(); - // click delete button job 1 - findDeleteButton().vm.$emit('click'); + expect(mockToastShow).toHaveBeenCalledWith( + `${artifactsFromJob.length} selected artifacts deleted`, + ); + }); - // job 2's artifacts should still be selected - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual( - job2.artifacts.nodes.map((node) => node.id), - ); + it('does not clear selected artifacts on success', async () => { + // select job 2 via checkbox + findJobCheckbox(2).vm.$emit('change', true); - // confirm delete - findBulkDeleteModal().vm.$emit('primary'); + // click delete button job 1 + findDeleteButton().vm.$emit('click'); - // job 1's artifacts should be deleted - expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ - projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), - ids: artifactsFromJob, - }); + // job 2's artifacts should still be selected + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual( + job2.artifacts.nodes.map((node) => node.id), + ); - await waitForPromises(); + // confirm delete + findBulkDeleteModal().vm.$emit('primary'); - // job 2's artifacts should still be selected - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual( - job2.artifacts.nodes.map((node) => node.id), - ); + // job 1's artifacts should be deleted + expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ + projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), + ids: artifactsFromJob, }); + + await waitForPromises(); + + // job 2's artifacts should still be selected + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual( + job2.artifacts.nodes.map((node) => node.id), + ); }); it('shows an alert and does not clear selected artifacts on error', async () => { createComponent({ canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, handlers: { getJobArtifactsQuery: jest.fn().mockResolvedValue(getJobArtifactsResponse), bulkDestroyArtifactsMutation: jest.fn().mockRejectedValue(), @@ -505,21 +500,9 @@ describe('JobArtifactsTable component', () => { }); }); - it('is disabled when bulk delete feature flag is disabled', async () => { - createComponent({ - canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false }, - }); - - await waitForPromises(); - - expect(findDeleteButton().attributes('disabled')).toBeDefined(); - }); - it('is hidden when user does not have delete permission', async () => { createComponent({ canDestroyArtifacts: false, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false }, }); await waitForPromises(); @@ -531,175 +514,168 @@ describe('JobArtifactsTable component', () => { describe('bulk delete', () => { const selectedArtifacts = job.artifacts.nodes.map((node) => node.id); - describe('with permission and feature flag enabled', () => { - beforeEach(async () => { - createComponent({ - canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, - }); - - await waitForPromises(); + beforeEach(async () => { + createComponent({ + canDestroyArtifacts: true, }); - it('shows selected artifacts when a job is checked', async () => { - expect(findBulkDeleteContainer().exists()).toBe(false); - - await findJobCheckbox().vm.$emit('change', true); + await waitForPromises(); + }); - expect(findBulkDeleteContainer().exists()).toBe(true); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(selectedArtifacts); - }); + it('shows selected artifacts when a job is checked', async () => { + expect(findBulkDeleteContainer().exists()).toBe(false); - it('disappears when selected artifacts are cleared', async () => { - await findJobCheckbox().vm.$emit('change', true); + await findJobCheckbox().vm.$emit('change', true); - expect(findBulkDeleteContainer().exists()).toBe(true); + expect(findBulkDeleteContainer().exists()).toBe(true); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(selectedArtifacts); + }); - await findBulkDelete().vm.$emit('clearSelectedArtifacts'); + it('disappears when selected artifacts are cleared', async () => { + await findJobCheckbox().vm.$emit('change', true); - expect(findBulkDeleteContainer().exists()).toBe(false); - }); + expect(findBulkDeleteContainer().exists()).toBe(true); - it('shows a modal to confirm bulk delete', async () => { - findJobCheckbox().vm.$emit('change', true); - findBulkDelete().vm.$emit('showBulkDeleteModal'); + await findBulkDelete().vm.$emit('clearSelectedArtifacts'); - await nextTick(); + expect(findBulkDeleteContainer().exists()).toBe(false); + }); - expect(findBulkDeleteModal().props('visible')).toBe(true); - }); + it('shows a modal to confirm bulk delete', async () => { + findJobCheckbox().vm.$emit('change', true); + findBulkDelete().vm.$emit('showBulkDeleteModal'); - it('deletes the selected artifacts and shows a toast', async () => { - findJobCheckbox().vm.$emit('change', true); - findBulkDelete().vm.$emit('showBulkDeleteModal'); - findBulkDeleteModal().vm.$emit('primary'); + await nextTick(); - expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ - projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), - ids: selectedArtifacts, - }); + expect(findBulkDeleteModal().props('visible')).toBe(true); + }); - await waitForPromises(); + it('deletes the selected artifacts and shows a toast', async () => { + findJobCheckbox().vm.$emit('change', true); + findBulkDelete().vm.$emit('showBulkDeleteModal'); + findBulkDeleteModal().vm.$emit('primary'); - expect(mockToastShow).toHaveBeenCalledWith( - `${selectedArtifacts.length} selected artifacts deleted`, - ); + expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({ + projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId), + ids: selectedArtifacts, }); - it('clears selected artifacts on success', async () => { - findJobCheckbox().vm.$emit('change', true); - findBulkDelete().vm.$emit('showBulkDeleteModal'); - findBulkDeleteModal().vm.$emit('primary'); + await waitForPromises(); - await waitForPromises(); + expect(mockToastShow).toHaveBeenCalledWith( + `${selectedArtifacts.length} selected artifacts deleted`, + ); + }); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); - }); + it('clears selected artifacts on success', async () => { + findJobCheckbox().vm.$emit('change', true); + findBulkDelete().vm.$emit('showBulkDeleteModal'); + findBulkDeleteModal().vm.$emit('primary'); - describe('select all checkbox', () => { - describe('when no artifacts are selected', () => { - it('is not checked', () => { - expect(findSelectAllCheckboxChecked()).toBe(false); - expect(findSelectAllCheckboxIndeterminate()).toBe(false); - }); + await waitForPromises(); - it('selects all artifacts when toggled', async () => { - toggleSelectAllCheckbox(); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); + }); - await nextTick(); + describe('select all checkbox', () => { + describe('when no artifacts are selected', () => { + it('is not checked', () => { + expect(findSelectAllCheckboxChecked()).toBe(false); + expect(findSelectAllCheckboxIndeterminate()).toBe(false); + }); - expect(findSelectAllCheckboxChecked()).toBe(true); - expect(findSelectAllCheckboxIndeterminate()).toBe(false); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(allArtifacts); - }); + it('selects all artifacts when toggled', async () => { + toggleSelectAllCheckbox(); + + await nextTick(); + + expect(findSelectAllCheckboxChecked()).toBe(true); + expect(findSelectAllCheckboxIndeterminate()).toBe(false); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(allArtifacts); }); + }); - describe('when some artifacts are selected', () => { - beforeEach(async () => { - findJobCheckbox().vm.$emit('change', true); + describe('when some artifacts are selected', () => { + beforeEach(async () => { + findJobCheckbox().vm.$emit('change', true); - await nextTick(); - }); + await nextTick(); + }); - it('is indeterminate', () => { - expect(findSelectAllCheckboxChecked()).toBe(true); - expect(findSelectAllCheckboxIndeterminate()).toBe(true); - }); + it('is indeterminate', () => { + expect(findSelectAllCheckboxChecked()).toBe(true); + expect(findSelectAllCheckboxIndeterminate()).toBe(true); + }); - it('deselects all artifacts when toggled', async () => { - toggleSelectAllCheckbox(); + it('deselects all artifacts when toggled', async () => { + toggleSelectAllCheckbox(); - await nextTick(); + await nextTick(); - expect(findSelectAllCheckboxChecked()).toBe(false); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); - }); + expect(findSelectAllCheckboxChecked()).toBe(false); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); }); + }); - describe('when all artifacts are selected', () => { - beforeEach(async () => { - findJobCheckbox(1).vm.$emit('change', true); - findJobCheckbox(2).vm.$emit('change', true); + describe('when all artifacts are selected', () => { + beforeEach(async () => { + findJobCheckbox(1).vm.$emit('change', true); + findJobCheckbox(2).vm.$emit('change', true); - await nextTick(); - }); + await nextTick(); + }); - it('is checked', () => { - expect(findSelectAllCheckboxChecked()).toBe(true); - expect(findSelectAllCheckboxIndeterminate()).toBe(false); - }); + it('is checked', () => { + expect(findSelectAllCheckboxChecked()).toBe(true); + expect(findSelectAllCheckboxIndeterminate()).toBe(false); + }); - it('deselects all artifacts when toggled', async () => { - toggleSelectAllCheckbox(); + it('deselects all artifacts when toggled', async () => { + toggleSelectAllCheckbox(); - await nextTick(); + await nextTick(); - expect(findSelectAllCheckboxChecked()).toBe(false); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); - }); + expect(findSelectAllCheckboxChecked()).toBe(false); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]); }); + }); - describe('when an artifact is selected on another page', () => { - const otherPageArtifact = { id: 'gid://gitlab/Ci::JobArtifact/some/other/id' }; + describe('when an artifact is selected on another page', () => { + const otherPageArtifact = { id: 'gid://gitlab/Ci::JobArtifact/some/other/id' }; - beforeEach(async () => { - // expand the first job row to access the details component - findCount().trigger('click'); + beforeEach(async () => { + // expand the first job row to access the details component + findCount().trigger('click'); - await nextTick(); + await nextTick(); - // mock the selection of an artifact on another page by emitting a select event - findDetailsInRow(1).vm.$emit('selectArtifact', otherPageArtifact, true); - }); + // mock the selection of an artifact on another page by emitting a select event + findDetailsInRow(1).vm.$emit('selectArtifact', otherPageArtifact, true); + }); - it('is not checked even though an artifact is selected', () => { - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([ - otherPageArtifact.id, - ]); - expect(findSelectAllCheckboxChecked()).toBe(false); - expect(findSelectAllCheckboxIndeterminate()).toBe(false); - }); + it('is not checked even though an artifact is selected', () => { + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([otherPageArtifact.id]); + expect(findSelectAllCheckboxChecked()).toBe(false); + expect(findSelectAllCheckboxIndeterminate()).toBe(false); + }); - it('only toggles selection of visible artifacts, leaving the other artifact selected', async () => { - toggleSelectAllCheckbox(); + it('only toggles selection of visible artifacts, leaving the other artifact selected', async () => { + toggleSelectAllCheckbox(); - await nextTick(); + await nextTick(); - expect(findSelectAllCheckboxChecked()).toBe(true); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([ - otherPageArtifact.id, - ...allArtifacts, - ]); + expect(findSelectAllCheckboxChecked()).toBe(true); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([ + otherPageArtifact.id, + ...allArtifacts, + ]); - toggleSelectAllCheckbox(); + toggleSelectAllCheckbox(); - await nextTick(); + await nextTick(); - expect(findSelectAllCheckboxChecked()).toBe(false); - expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([ - otherPageArtifact.id, - ]); - }); + expect(findSelectAllCheckboxChecked()).toBe(false); + expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([otherPageArtifact.id]); }); }); }); @@ -711,7 +687,6 @@ describe('JobArtifactsTable component', () => { beforeEach(async () => { createComponent({ canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, data: { selectedArtifacts: new Array(selectedArtifactsLength).fill('artifact-id'), }, @@ -742,7 +717,6 @@ describe('JobArtifactsTable component', () => { beforeEach(async () => { createComponent({ canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, data: { selectedArtifacts: maxSelectedArtifacts }, }); @@ -775,7 +749,6 @@ describe('JobArtifactsTable component', () => { beforeEach(async () => { createComponent({ canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, data: { selectedArtifacts: maxSelectedArtifactsIncludingCurrentPage, }, @@ -811,7 +784,6 @@ describe('JobArtifactsTable component', () => { it('shows an alert and does not clear selected artifacts on error', async () => { createComponent({ canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, handlers: { getJobArtifactsQuery: jest.fn().mockResolvedValue(getJobArtifactsResponse), bulkDestroyArtifactsMutation: jest.fn().mockRejectedValue(), @@ -837,18 +809,6 @@ describe('JobArtifactsTable component', () => { it('shows no checkboxes without permission', async () => { createComponent({ canDestroyArtifacts: false, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true }, - }); - - await waitForPromises(); - - expect(findAnyCheckbox().exists()).toBe(false); - }); - - it('shows no checkboxes with feature flag disabled', async () => { - createComponent({ - canDestroyArtifacts: true, - glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false }, }); await waitForPromises(); diff --git a/spec/frontend/issues/dashboard/mock_data.js b/spec/frontend/issues/dashboard/mock_data.js index e789360d1d5..adcd4268449 100644 --- a/spec/frontend/issues/dashboard/mock_data.js +++ b/spec/frontend/issues/dashboard/mock_data.js @@ -3,6 +3,7 @@ export const issuesQueryResponse = { issues: { nodes: [ { + __persist: true, __typename: 'Issue', id: 'gid://gitlab/Issue/123456', iid: '789', @@ -27,6 +28,7 @@ export const issuesQueryResponse = { assignees: { nodes: [ { + __persist: true, __typename: 'UserCore', id: 'gid://gitlab/User/234', avatarUrl: 'avatar/url', @@ -37,6 +39,7 @@ export const issuesQueryResponse = { ], }, author: { + __persist: true, __typename: 'UserCore', id: 'gid://gitlab/User/456', avatarUrl: 'avatar/url', @@ -47,6 +50,7 @@ export const issuesQueryResponse = { labels: { nodes: [ { + __persist: true, id: 'gid://gitlab/ProjectLabel/456', color: '#333', title: 'Label title', diff --git a/spec/requests/api/graphql/mutations/ci/job_artifact/bulk_destroy_spec.rb b/spec/requests/api/graphql/mutations/ci/job_artifact/bulk_destroy_spec.rb index 4e25669a0ca..5cb48ec44a0 100644 --- a/spec/requests/api/graphql/mutations/ci/job_artifact/bulk_destroy_spec.rb +++ b/spec/requests/api/graphql/mutations/ci/job_artifact/bulk_destroy_spec.rb @@ -41,23 +41,6 @@ RSpec.describe 'BulkDestroy', feature_category: :build_artifacts do expect(first_artifact.reload).to be_persisted end - context 'when the `ci_job_artifact_bulk_destroy` feature flag is disabled' do - before do - stub_feature_flags(ci_job_artifact_bulk_destroy: false) - project.add_maintainer(maintainer) - end - - it 'returns a resource not available error' do - post_graphql_mutation(mutation, current_user: maintainer) - - expect(graphql_errors).to contain_exactly( - hash_including( - 'message' => '`ci_job_artifact_bulk_destroy` feature flag is disabled.' - ) - ) - end - end - context "when the user is a developer in a project" do before do project.add_developer(developer) diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb index 6ebf93730eb..9b2cfead684 100644 --- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb @@ -5,38 +5,110 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker, feature_category: :importers do let_it_be(:project) { create(:project) } let_it_be(:import_state) { create(:import_state, project: project) } + let(:options) { { state: 'all', sort: 'number', direction: 'desc', per_page: '1' } } let(:worker) { described_class.new } let(:importer) { double(:importer) } let(:client) { double(:client) } describe '#import' do - it 'imports all the pull requests' do - waiter = Gitlab::JobWaiter.new(2, '123') + context 'with pull requests' do + it 'imports all the pull requests and allocates internal iids' do + waiter = Gitlab::JobWaiter.new(2, '123') - expect(Gitlab::GithubImport::Importer::PullRequestsImporter) - .to receive(:new) - .with(project, client) - .and_return(importer) + expect(Gitlab::GithubImport::Importer::PullRequestsImporter) + .to receive(:new) + .with(project, client) + .and_return(importer) - expect(importer) - .to receive(:execute) - .and_return(waiter) + expect(importer) + .to receive(:execute) + .and_return(waiter) - expect(import_state) - .to receive(:refresh_jid_expiration) + expect(import_state) + .to receive(:refresh_jid_expiration) - expect(Gitlab::GithubImport::AdvanceStageWorker) - .to receive(:perform_async) - .with(project.id, { '123' => 2 }, :collaborators) + expect(InternalId).to receive(:exists?).and_return(false) - worker.import(client, project) + expect(client).to receive(:each_object).with( + :pulls, project.import_source, options + ).and_return([{ number: 4 }].each) + + expect(Gitlab::GithubImport::AdvanceStageWorker) + .to receive(:perform_async) + .with(project.id, { '123' => 2 }, :collaborators) + + expect(MergeRequest).to receive(:track_target_project_iid!) + + worker.import(client, project) + end + end + + context 'without pull requests' do + it 'does not allocate internal iids' do + waiter = Gitlab::JobWaiter.new(2, '123') + + expect(Gitlab::GithubImport::Importer::PullRequestsImporter) + .to receive(:new) + .with(project, client) + .and_return(importer) + + expect(importer) + .to receive(:execute) + .and_return(waiter) + + expect(import_state) + .to receive(:refresh_jid_expiration) + + expect(InternalId).to receive(:exists?).and_return(false) + + expect(client).to receive(:each_object).with( + :pulls, project.import_source, options + ).and_return([nil].each) + + expect(Gitlab::GithubImport::AdvanceStageWorker) + .to receive(:perform_async) + .with(project.id, { '123' => 2 }, :collaborators) + + expect(MergeRequest).not_to receive(:track_target_project_iid!) + + worker.import(client, project) + end + end + + context 'when retrying' do + it 'does not allocate internal iids' do + waiter = Gitlab::JobWaiter.new(2, '123') + + expect(Gitlab::GithubImport::Importer::PullRequestsImporter) + .to receive(:new) + .with(project, client) + .and_return(importer) + + expect(importer) + .to receive(:execute) + .and_return(waiter) + + expect(import_state) + .to receive(:refresh_jid_expiration) + + expect(InternalId).to receive(:exists?).and_return(true) + + expect(client).not_to receive(:each_object) + expect(MergeRequest).not_to receive(:track_target_project_iid!) + + worker.import(client, project) + end end end it 'raises an error' do exception = StandardError.new('_some_error_') + expect(client).to receive(:each_object).with( + :pulls, project.import_source, options + ).and_return([{ number: 4 }].each) + expect_next_instance_of(Gitlab::GithubImport::Importer::PullRequestsImporter) do |importer| expect(importer).to receive(:execute).and_raise(exception) end |