diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-19 15:07:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-19 15:07:31 +0000 |
commit | 30cd626f8c1028ba096e84349580e0772a34b1af (patch) | |
tree | e304b473a86427bc2c7f8992cab8a1479fc8e6c2 /spec | |
parent | 9320083e480a8a1f2584af4e3d9a4538ab14cf1e (diff) | |
download | gitlab-ce-30cd626f8c1028ba096e84349580e0772a34b1af.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
14 files changed, 47 insertions, 28 deletions
diff --git a/spec/frontend/add_context_commits_modal/store/actions_spec.js b/spec/frontend/add_context_commits_modal/store/actions_spec.js index 4b58a69c2b8..77666e922ff 100644 --- a/spec/frontend/add_context_commits_modal/store/actions_spec.js +++ b/spec/frontend/add_context_commits_modal/store/actions_spec.js @@ -16,6 +16,7 @@ import { } from '~/add_context_commits_modal/store/actions'; import * as types from '~/add_context_commits_modal/store/mutation_types'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; describe('AddContextCommitsModalStoreActions', () => { const contextCommitEndpoint = @@ -156,7 +157,7 @@ describe('AddContextCommitsModalStoreActions', () => { beforeEach(() => { mock .onDelete('/api/v4/projects/gitlab-org%2Fgitlab/merge_requests/1/context_commits') - .reply(204); + .reply(HTTP_STATUS_NO_CONTENT); }); it('calls API to remove context commits', () => { return testAction( diff --git a/spec/frontend/api/alert_management_alerts_api_spec.js b/spec/frontend/api/alert_management_alerts_api_spec.js index aac14e64286..c8da867e573 100644 --- a/spec/frontend/api/alert_management_alerts_api_spec.js +++ b/spec/frontend/api/alert_management_alerts_api_spec.js @@ -1,6 +1,7 @@ import MockAdapter from 'axios-mock-adapter'; import * as alertManagementAlertsApi from '~/api/alert_management_alerts_api'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_CREATED, HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; describe('~/api/alert_management_alerts_api.js', () => { let mock; @@ -60,7 +61,7 @@ describe('~/api/alert_management_alerts_api.js', () => { expectedFormData.append('url', url); expectedFormData.append('url_text', urlText); - mock.onPost(expectedUrl).reply(201, { data: expectedData }); + mock.onPost(expectedUrl).reply(HTTP_STATUS_CREATED, { data: expectedData }); return alertManagementAlertsApi .uploadAlertMetricImage({ @@ -123,7 +124,7 @@ describe('~/api/alert_management_alerts_api.js', () => { const expectedUrl = `/api/v4/projects/${projectId}/alert_management_alerts/${alertIid}/metric_images/${imageIid}`; const expectedData = [imageData]; - mock.onDelete(expectedUrl).reply(204, { data: expectedData }); + mock.onDelete(expectedUrl).reply(HTTP_STATUS_NO_CONTENT, { data: expectedData }); return alertManagementAlertsApi .deleteAlertMetricImage({ diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js index 39fbe02480d..f382a407c67 100644 --- a/spec/frontend/api_spec.js +++ b/spec/frontend/api_spec.js @@ -1004,7 +1004,7 @@ describe('Api', () => { jest.spyOn(axios, 'delete'); - mock.onDelete(expectedUrl).replyOnce(204); + mock.onDelete(expectedUrl).replyOnce(HTTP_STATUS_NO_CONTENT); return Api.removeContextCommits(projectPath, mergeRequestId, expectedData).then(() => { expect(axios.delete).toHaveBeenCalledWith(expectedUrl, { data: expectedData }); diff --git a/spec/frontend/ci/reports/codequality_report/store/actions_spec.js b/spec/frontend/ci/reports/codequality_report/store/actions_spec.js index 88628210793..5d55cddb559 100644 --- a/spec/frontend/ci/reports/codequality_report/store/actions_spec.js +++ b/spec/frontend/ci/reports/codequality_report/store/actions_spec.js @@ -2,6 +2,11 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; import axios from '~/lib/utils/axios_utils'; +import { + HTTP_STATUS_INTERNAL_SERVER_ERROR, + HTTP_STATUS_NO_CONTENT, + HTTP_STATUS_OK, +} from '~/lib/utils/http_status'; import createStore from '~/ci/reports/codequality_report/store'; import * as actions from '~/ci/reports/codequality_report/store/actions'; import * as types from '~/ci/reports/codequality_report/store/mutation_types'; @@ -105,9 +110,9 @@ describe('Codequality Reports actions', () => { it('continues polling until it receives data', () => { mock .onGet(endpoint) - .replyOnce(204, undefined, pollIntervalHeader) + .replyOnce(HTTP_STATUS_NO_CONTENT, undefined, pollIntervalHeader) .onGet(endpoint) - .reply(200, reportIssues); + .reply(HTTP_STATUS_OK, reportIssues); return Promise.all([ testAction( @@ -134,9 +139,9 @@ describe('Codequality Reports actions', () => { it('continues polling until it receives an error', () => { mock .onGet(endpoint) - .replyOnce(204, undefined, pollIntervalHeader) + .replyOnce(HTTP_STATUS_NO_CONTENT, undefined, pollIntervalHeader) .onGet(endpoint) - .reply(500); + .reply(HTTP_STATUS_INTERNAL_SERVER_ERROR); return Promise.all([ testAction( diff --git a/spec/frontend/error_tracking/store/details/actions_spec.js b/spec/frontend/error_tracking/store/details/actions_spec.js index 1893d226270..6248bef9dcd 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -4,6 +4,7 @@ import * as actions from '~/error_tracking/store/details/actions'; import * as types from '~/error_tracking/store/details/mutation_types'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; import Poll from '~/lib/utils/poll'; let mockedAdapter; @@ -58,7 +59,7 @@ describe('Sentry error details store actions', () => { it('should not restart polling when receiving an empty 204 response', async () => { mockedRestart = jest.spyOn(Poll.prototype, 'restart'); - mockedAdapter.onGet().reply(204); + mockedAdapter.onGet().reply(HTTP_STATUS_NO_CONTENT); await testAction(actions.startPollingStacktrace, { endpoint }, {}, [], []); mockedRestart = jest.spyOn(Poll.prototype, 'restart'); diff --git a/spec/frontend/import_entities/import_projects/store/actions_spec.js b/spec/frontend/import_entities/import_projects/store/actions_spec.js index 5607eee9f43..53de714c9e2 100644 --- a/spec/frontend/import_entities/import_projects/store/actions_spec.js +++ b/spec/frontend/import_entities/import_projects/store/actions_spec.js @@ -21,7 +21,7 @@ import { import state from '~/import_entities/import_projects/store/state'; import axios from '~/lib/utils/axios_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_OK, HTTP_STATUS_TOO_MANY_REQUESTS } from '~/lib/utils/http_status'; jest.mock('~/flash'); @@ -216,7 +216,7 @@ describe('import_projects store actions', () => { describe('when rate limited', () => { it('commits RECEIVE_REPOS_ERROR and shows rate limited error message', async () => { - mock.onGet(`${TEST_HOST}/endpoint.json?filter=filter`).reply(429); + mock.onGet(`${TEST_HOST}/endpoint.json?filter=filter`).reply(HTTP_STATUS_TOO_MANY_REQUESTS); await testAction( fetchRepos, diff --git a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js index bedf8bcaf34..313bc464f11 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js @@ -9,6 +9,7 @@ import { } from 'jest/issuable/components/related_issuable_mock_data'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_CONFLICT, HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; import { linkedIssueTypesMap } from '~/related_issues/constants'; import RelatedIssuesBlock from '~/related_issues/components/related_issues_block.vue'; import RelatedIssuesRoot from '~/related_issues/components/related_issues_root.vue'; @@ -68,7 +69,7 @@ describe('RelatedIssuesRoot', () => { }); it('does not remove related issue on API error', async () => { - mock.onDelete(issuable1.referencePath).reply(422, {}); + mock.onDelete(issuable1.referencePath).reply(HTTP_STATUS_UNPROCESSABLE_ENTITY, {}); findRelatedIssuesBlock().vm.$emit('relatedIssueRemoveRequest', issuable1.id); await axios.waitForAll(); @@ -204,7 +205,7 @@ describe('RelatedIssuesRoot', () => { it('passes an error message from the backend upon error', async () => { const input = '#123'; const message = 'error'; - mock.onPost(defaultProps.endpoint).reply(409, { message }); + mock.onPost(defaultProps.endpoint).reply(HTTP_STATUS_CONFLICT, { message }); wrapper.vm.store.setPendingReferences([issuable1.reference, issuable2.reference]); expect(findRelatedIssuesBlock().props('hasError')).toBe(false); diff --git a/spec/frontend/merge_request_spec.js b/spec/frontend/merge_request_spec.js index 16e3e49a297..7333ce345eb 100644 --- a/spec/frontend/merge_request_spec.js +++ b/spec/frontend/merge_request_spec.js @@ -5,6 +5,7 @@ import { TEST_HOST } from 'spec/test_constants'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_CONFLICT } from '~/lib/utils/http_status'; import MergeRequest from '~/merge_request'; jest.mock('~/flash'); @@ -89,7 +90,7 @@ describe('MergeRequest', () => { it('shows an error notification when tasklist update failed', async () => { mock .onPatch(`${TEST_HOST}/frontend-fixtures/merge-requests-project/-/merge_requests/1.json`) - .reply(409, {}); + .reply(HTTP_STATUS_CONFLICT, {}); $('.js-task-list-field').trigger({ type: 'tasklist:changed', diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js index e13985ef469..dfb05c85fc8 100644 --- a/spec/frontend/notes/components/comment_form_spec.js +++ b/spec/frontend/notes/components/comment_form_spec.js @@ -10,6 +10,7 @@ import batchComments from '~/batch_comments/stores/modules/batch_comments'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; import CommentForm from '~/notes/components/comment_form.vue'; import CommentTypeDropdown from '~/notes/components/comment_type_dropdown.vue'; import * as constants from '~/notes/constants'; @@ -162,11 +163,11 @@ describe('issue_comment_form component', () => { }); it.each` - httpStatus | errors - ${400} | ${[COMMENT_FORM.GENERIC_UNSUBMITTABLE_NETWORK]} - ${422} | ${['error 1']} - ${422} | ${['error 1', 'error 2']} - ${422} | ${['error 1', 'error 2', 'error 3']} + httpStatus | errors + ${400} | ${[COMMENT_FORM.GENERIC_UNSUBMITTABLE_NETWORK]} + ${HTTP_STATUS_UNPROCESSABLE_ENTITY} | ${['error 1']} + ${HTTP_STATUS_UNPROCESSABLE_ENTITY} | ${['error 1', 'error 2']} + ${HTTP_STATUS_UNPROCESSABLE_ENTITY} | ${['error 1', 'error 2', 'error 3']} `( 'displays the correct errors ($errors) for a $httpStatus network response', async ({ errors, httpStatus }) => { @@ -198,7 +199,10 @@ describe('issue_comment_form component', () => { store = createStore({ actions: { saveNote: jest.fn().mockRejectedValue({ - response: { status: 422, data: { errors: { commands_only: [...commandErrors] } } }, + response: { + status: HTTP_STATUS_UNPROCESSABLE_ENTITY, + data: { errors: { commands_only: [...commandErrors] } }, + }, }), }, }); diff --git a/spec/frontend/notes/stores/actions_spec.js b/spec/frontend/notes/stores/actions_spec.js index 0b2623f3d77..425facd1406 100644 --- a/spec/frontend/notes/stores/actions_spec.js +++ b/spec/frontend/notes/stores/actions_spec.js @@ -7,6 +7,7 @@ import { createAlert } from '~/flash'; import toast from '~/vue_shared/plugins/global_toast'; import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_SERVICE_UNAVAILABLE } from '~/lib/utils/http_status'; import * as notesConstants from '~/notes/constants'; import createStore from '~/notes/stores'; import * as actions from '~/notes/stores/actions'; @@ -1208,7 +1209,7 @@ describe('Actions Notes Store', () => { describe('if response contains errors', () => { const errorMessage = 'Request failed with status code 503'; it('dispatches receiveDeleteDescriptionVersionError and throws an error', async () => { - axiosMock.onDelete(endpoint).replyOnce(503); + axiosMock.onDelete(endpoint).replyOnce(HTTP_STATUS_SERVICE_UNAVAILABLE); await expect( testAction( actions.softDeleteDescriptionVersion, diff --git a/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js b/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js index 329cc15df97..601f8abd34d 100644 --- a/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js +++ b/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js @@ -17,6 +17,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { GRAPHQL_PAGE_SIZE } from '~/packages_and_registries/dependency_proxy/constants'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_ACCEPTED } from '~/lib/utils/http_status'; import DependencyProxyApp from '~/packages_and_registries/dependency_proxy/app.vue'; import TitleArea from '~/vue_shared/components/registry/title_area.vue'; @@ -92,7 +93,7 @@ describe('DependencyProxyApp', () => { window.gon = { ...dummyGon }; mock = new MockAdapter(axios); - mock.onDelete(expectedUrl).reply(202, {}); + mock.onDelete(expectedUrl).reply(HTTP_STATUS_ACCEPTED, {}); }); afterEach(() => { diff --git a/spec/frontend/projects/settings/components/shared_runners_toggle_spec.js b/spec/frontend/projects/settings/components/shared_runners_toggle_spec.js index dfaa1944cbe..f82ad80135e 100644 --- a/spec/frontend/projects/settings/components/shared_runners_toggle_spec.js +++ b/spec/frontend/projects/settings/components/shared_runners_toggle_spec.js @@ -4,7 +4,7 @@ import MockAxiosAdapter from 'axios-mock-adapter'; import { nextTick } from 'vue'; import waitForPromises from 'helpers/wait_for_promises'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_OK, HTTP_STATUS_UNAUTHORIZED } from '~/lib/utils/http_status'; import SharedRunnersToggleComponent from '~/projects/settings/components/shared_runners_toggle.vue'; const TEST_UPDATE_PATH = '/test/update_shared_runners'; @@ -133,7 +133,9 @@ describe('projects/settings/components/shared_runners', () => { describe('when request encounters an error', () => { it('should show custom error message from API if it exists', async () => { - mockAxios.onPost(TEST_UPDATE_PATH).reply(401, { error: 'Custom API Error message' }); + mockAxios + .onPost(TEST_UPDATE_PATH) + .reply(HTTP_STATUS_UNAUTHORIZED, { error: 'Custom API Error message' }); createComponent(); expect(getToggleValue()).toBe(false); @@ -145,7 +147,7 @@ describe('projects/settings/components/shared_runners', () => { }); it('should show default error message if API does not return a custom error message', async () => { - mockAxios.onPost(TEST_UPDATE_PATH).reply(401); + mockAxios.onPost(TEST_UPDATE_PATH).reply(HTTP_STATUS_UNAUTHORIZED); createComponent(); expect(getToggleValue()).toBe(false); diff --git a/spec/frontend/vue_merge_request_widget/mr_widget_options_spec.js b/spec/frontend/vue_merge_request_widget/mr_widget_options_spec.js index a2d7f373c66..824d0d012fb 100644 --- a/spec/frontend/vue_merge_request_widget/mr_widget_options_spec.js +++ b/spec/frontend/vue_merge_request_widget/mr_widget_options_spec.js @@ -11,7 +11,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import { securityReportMergeRequestDownloadPathsQueryResponse } from 'jest/vue_shared/security_reports/mock_data'; import api from '~/api'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_OK, HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; import Poll from '~/lib/utils/poll'; import { setFaviconOverlay } from '~/lib/utils/favicon'; import notify from '~/lib/utils/notify'; @@ -1010,7 +1010,7 @@ describe('MrWidgetOptions', () => { () => Promise.resolve({ headers: { 'poll-interval': 1 }, - status: 204, + status: HTTP_STATUS_NO_CONTENT, }), () => Promise.resolve({ diff --git a/spec/frontend/vue_merge_request_widget/stores/artifacts_list/actions_spec.js b/spec/frontend/vue_merge_request_widget/stores/artifacts_list/actions_spec.js index 1a109aad911..c77c1a1347d 100644 --- a/spec/frontend/vue_merge_request_widget/stores/artifacts_list/actions_spec.js +++ b/spec/frontend/vue_merge_request_widget/stores/artifacts_list/actions_spec.js @@ -2,6 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import { TEST_HOST } from 'helpers/test_constants'; import testAction from 'helpers/vuex_action_helper'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; import { setEndpoint, requestArtifacts, @@ -136,7 +137,7 @@ describe('Artifacts App Store Actions', () => { it('should not commit RECEIVE_ARTIFACTS_SUCCESS mutation with 204', () => { return testAction( receiveArtifactsSuccess, - { data: { summary: {} }, status: 204 }, + { data: { summary: {} }, status: HTTP_STATUS_NO_CONTENT }, mockedState, [], [], |