diff options
Diffstat (limited to 'spec/frontend')
16 files changed, 44 insertions, 26 deletions
diff --git a/spec/frontend/clusters_list/store/actions_spec.js b/spec/frontend/clusters_list/store/actions_spec.js index 1deebf8b75a..8e03f8105c2 100644 --- a/spec/frontend/clusters_list/store/actions_spec.js +++ b/spec/frontend/clusters_list/store/actions_spec.js @@ -7,6 +7,7 @@ import * as actions from '~/clusters_list/store/actions'; import * as types from '~/clusters_list/store/mutation_types'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import Poll from '~/lib/utils/poll'; import { apiData } from '../mock_data'; @@ -81,7 +82,7 @@ describe('Clusters store actions', () => { }); it('should show flash on API error', async () => { - mock.onGet().reply(400, 'Not Found'); + mock.onGet().reply(HTTP_STATUS_BAD_REQUEST, 'Not Found'); await testAction( actions.fetchClusters, diff --git a/spec/frontend/contributors/store/actions_spec.js b/spec/frontend/contributors/store/actions_spec.js index 865f683a91a..a4a78fc12ee 100644 --- a/spec/frontend/contributors/store/actions_spec.js +++ b/spec/frontend/contributors/store/actions_spec.js @@ -4,6 +4,7 @@ import * as actions from '~/contributors/stores/actions'; import * as types from '~/contributors/stores/mutation_types'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; jest.mock('~/flash.js'); @@ -38,7 +39,7 @@ describe('Contributors store actions', () => { }); it('should show flash on API error', async () => { - mock.onGet().reply(400, 'Not Found'); + mock.onGet().reply(HTTP_STATUS_BAD_REQUEST, 'Not Found'); await testAction( actions.fetchChartData, diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index 9cb7fa4fb4b..3e9d5363947 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -16,7 +16,11 @@ import * as treeWorkerUtils from '~/diffs/utils/tree_worker_utils'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; import * as commonUtils from '~/lib/utils/common_utils'; -import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_NOT_FOUND } from '~/lib/utils/http_status'; +import { + HTTP_STATUS_BAD_REQUEST, + HTTP_STATUS_INTERNAL_SERVER_ERROR, + HTTP_STATUS_NOT_FOUND, +} from '~/lib/utils/http_status'; import { mergeUrlParams } from '~/lib/utils/url_utility'; import eventHub from '~/notes/event_hub'; import { diffMetadata } from '../mock_data/diff_metadata'; @@ -261,7 +265,7 @@ describe('DiffsStoreActions', () => { }); it('should show flash on API error', async () => { - mock.onGet(endpointCoverage).reply(400); + mock.onGet(endpointCoverage).reply(HTTP_STATUS_BAD_REQUEST); await testAction(diffActions.fetchCoverageFiles, {}, { endpointCoverage }, [], []); expect(createAlert).toHaveBeenCalledTimes(1); diff --git a/spec/frontend/dropzone_input_spec.js b/spec/frontend/dropzone_input_spec.js index 0f7926ccbf9..fdd157dd09f 100644 --- a/spec/frontend/dropzone_input_spec.js +++ b/spec/frontend/dropzone_input_spec.js @@ -7,7 +7,7 @@ import { TEST_HOST } from 'spec/test_constants'; import PasteMarkdownTable from '~/behaviors/markdown/paste_markdown_table'; import dropzoneInput from '~/dropzone_input'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; const TEST_FILE = new File([], 'somefile.jpg'); TEST_FILE.upload = {}; @@ -161,7 +161,7 @@ describe('dropzone_input', () => { ${'text/plain'} | ${TEST_ERROR_MESSAGE} `('when AJAX fails with json', ({ responseType, responseBody }) => { mock.post(TEST_UPLOAD_PATH, { - status: 400, + status: HTTP_STATUS_BAD_REQUEST, body: responseBody, headers: { 'Content-Type': responseType }, }); diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js index 8f085282f80..6e6fc6f3351 100644 --- a/spec/frontend/error_tracking/store/actions_spec.js +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -4,6 +4,7 @@ import * as actions from '~/error_tracking/store/actions'; import * as types from '~/error_tracking/store/mutation_types'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import { visitUrl } from '~/lib/utils/url_utility'; jest.mock('~/flash.js'); @@ -46,7 +47,7 @@ describe('Sentry common store actions', () => { }); it('should handle unsuccessful status update', async () => { - mock.onPut().reply(400, {}); + mock.onPut().reply(HTTP_STATUS_BAD_REQUEST, {}); await testAction(actions.updateStatus, params, {}, [], []); expect(visitUrl).not.toHaveBeenCalled(); expect(createAlert).toHaveBeenCalledTimes(1); diff --git a/spec/frontend/error_tracking/store/details/actions_spec.js b/spec/frontend/error_tracking/store/details/actions_spec.js index 6248bef9dcd..27ab314564f 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -4,7 +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 { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status'; import Poll from '~/lib/utils/poll'; let mockedAdapter; @@ -45,7 +45,7 @@ describe('Sentry error details store actions', () => { }); it('should show flash on API error', async () => { - mockedAdapter.onGet().reply(400); + mockedAdapter.onGet().reply(HTTP_STATUS_BAD_REQUEST); await testAction( actions.startPollingStacktrace, diff --git a/spec/frontend/error_tracking_settings/store/actions_spec.js b/spec/frontend/error_tracking_settings/store/actions_spec.js index cb335bdbaf6..40f82b58fe5 100644 --- a/spec/frontend/error_tracking_settings/store/actions_spec.js +++ b/spec/frontend/error_tracking_settings/store/actions_spec.js @@ -6,7 +6,7 @@ import * as types from '~/error_tracking_settings/store/mutation_types'; import defaultState from '~/error_tracking_settings/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_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { projectList } from '../mock'; @@ -126,7 +126,7 @@ describe('error tracking settings actions', () => { }); it('should handle a server error', async () => { - mock.onPatch(TEST_HOST).reply(400); + mock.onPatch(TEST_HOST).reply(HTTP_STATUS_BAD_REQUEST); await testAction( actions.updateSettings, null, diff --git a/spec/frontend/groups/components/app_spec.js b/spec/frontend/groups/components/app_spec.js index 13c9f206033..fea3b547977 100644 --- a/spec/frontend/groups/components/app_spec.js +++ b/spec/frontend/groups/components/app_spec.js @@ -11,7 +11,7 @@ import eventHub from '~/groups/event_hub'; import GroupsService from '~/groups/service/groups_service'; import GroupsStore from '~/groups/store/groups_store'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_FORBIDDEN } from '~/lib/utils/http_status'; +import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_FORBIDDEN } from '~/lib/utils/http_status'; import * as urlUtilities from '~/lib/utils/url_utility'; import setWindowLocation from 'helpers/set_window_location_helper'; @@ -113,7 +113,7 @@ describe('AppComponent', () => { }); it('should show flash error when request fails', () => { - mock.onGet('/dashboard/groups.json').reply(400); + mock.onGet('/dashboard/groups.json').reply(HTTP_STATUS_BAD_REQUEST); jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); return vm.fetchGroups({}).then(() => { @@ -253,7 +253,7 @@ describe('AppComponent', () => { }); it('should set `isChildrenLoading` back to `false` if load request fails', () => { - mock.onGet('/dashboard/groups.json').reply(400); + mock.onGet('/dashboard/groups.json').reply(HTTP_STATUS_BAD_REQUEST); vm.toggleChildren(groupItem); diff --git a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js index 09be1e333b3..bf57373dd03 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js @@ -11,6 +11,7 @@ import * as messages from '~/ide/stores/modules/terminal/messages'; import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types'; import axios from '~/lib/utils/axios_utils'; import { + HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_FORBIDDEN, HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY, @@ -144,7 +145,7 @@ describe('IDE store terminal check actions', () => { }); it('when error, dispatches request and receive', () => { - mock.onPost(/.*\/ide_terminals\/check_config/).reply(400, {}); + mock.onPost(/.*\/ide_terminals\/check_config/).reply(HTTP_STATUS_BAD_REQUEST, {}); return testAction( actions.fetchConfigCheck, diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js index 9fd5f1a38d7..3bc51e5840c 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js @@ -6,7 +6,11 @@ import { STARTING, PENDING, STOPPING, STOPPED } from '~/ide/stores/modules/termi import * as messages from '~/ide/stores/modules/terminal/messages'; import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; +import { + HTTP_STATUS_BAD_REQUEST, + HTTP_STATUS_NOT_FOUND, + HTTP_STATUS_UNPROCESSABLE_ENTITY, +} from '~/lib/utils/http_status'; jest.mock('~/flash'); @@ -126,7 +130,7 @@ describe('IDE store terminal session controls actions', () => { }); it('dispatches request and receive on error', () => { - mock.onPost(/.*\/ide_terminals/).reply(400); + mock.onPost(/.*\/ide_terminals/).reply(HTTP_STATUS_BAD_REQUEST); return testAction( actions.startSession, @@ -191,7 +195,7 @@ describe('IDE store terminal session controls actions', () => { }); it('dispatches request and receive on error', () => { - mock.onPost(TEST_SESSION.cancel_path).reply(400); + mock.onPost(TEST_SESSION.cancel_path).reply(HTTP_STATUS_BAD_REQUEST); const state = { session: { cancelPath: TEST_SESSION.cancel_path }, @@ -271,7 +275,7 @@ describe('IDE store terminal session controls actions', () => { it('dispatches request and receive on error', () => { mock .onPost(state.session.retryPath, { branch: rootState.currentBranchId, format: 'json' }) - .reply(400); + .reply(HTTP_STATUS_BAD_REQUEST); return testAction( actions.restartSession, diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js index fe2328f25c2..3928f209e96 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js @@ -6,6 +6,7 @@ import { PENDING, RUNNING, STOPPING, STOPPED } from '~/ide/stores/modules/termin import * as messages from '~/ide/stores/modules/terminal/messages'; import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; jest.mock('~/flash'); @@ -157,7 +158,7 @@ describe('IDE store terminal session controls actions', () => { }); it('dispatches error on error', () => { - mock.onGet(state.session.showPath).reply(400); + mock.onGet(state.session.showPath).reply(HTTP_STATUS_BAD_REQUEST); return testAction( actions.fetchSessionStatus, diff --git a/spec/frontend/issues/related_merge_requests/store/actions_spec.js b/spec/frontend/issues/related_merge_requests/store/actions_spec.js index d3ec6c3bc9d..ecadcb1a13f 100644 --- a/spec/frontend/issues/related_merge_requests/store/actions_spec.js +++ b/spec/frontend/issues/related_merge_requests/store/actions_spec.js @@ -2,6 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import * as actions from '~/issues/related_merge_requests/store/actions'; import * as types from '~/issues/related_merge_requests/store/mutation_types'; @@ -86,7 +87,7 @@ describe('RelatedMergeRequest store actions', () => { describe('for a failing request', () => { it('should dispatch error action', async () => { - mock.onGet(`${state.apiEndpoint}?per_page=100`).replyOnce(400); + mock.onGet(`${state.apiEndpoint}?per_page=100`).replyOnce(HTTP_STATUS_BAD_REQUEST); await testAction( actions.fetchMergeRequests, diff --git a/spec/frontend/lib/utils/axios_startup_calls_spec.js b/spec/frontend/lib/utils/axios_startup_calls_spec.js index e12bf725560..fc5bd3b811c 100644 --- a/spec/frontend/lib/utils/axios_startup_calls_spec.js +++ b/spec/frontend/lib/utils/axios_startup_calls_spec.js @@ -1,6 +1,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import setupAxiosStartupCalls from '~/lib/utils/axios_startup_calls'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; describe('setupAxiosStartupCalls', () => { const AXIOS_RESPONSE = { text: 'AXIOS_RESPONSE' }; @@ -55,7 +56,7 @@ describe('setupAxiosStartupCalls', () => { fetchCall: mockFetchCall(200), }, '/startup-failing': { - fetchCall: mockFetchCall(400), + fetchCall: mockFetchCall(HTTP_STATUS_BAD_REQUEST), }, }; setupAxiosStartupCalls(axios); diff --git a/spec/frontend/merge_conflicts/store/actions_spec.js b/spec/frontend/merge_conflicts/store/actions_spec.js index 50eac982e20..4399436b2c5 100644 --- a/spec/frontend/merge_conflicts/store/actions_spec.js +++ b/spec/frontend/merge_conflicts/store/actions_spec.js @@ -1,6 +1,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import Cookies from '~/lib/utils/cookies'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import testAction from 'helpers/vuex_action_helper'; import { createAlert } from '~/flash'; @@ -64,7 +65,7 @@ describe('merge conflicts actions', () => { }); it('when request fails', () => { - mock.onGet(conflictsPath).reply(400); + mock.onGet(conflictsPath).reply(HTTP_STATUS_BAD_REQUEST); return testAction( actions.fetchConflictsData, conflictsPath, @@ -114,7 +115,7 @@ describe('merge conflicts actions', () => { }); it('on errors shows flash', async () => { - mock.onPost(resolveConflictsPath).reply(400); + mock.onPost(resolveConflictsPath).reply(HTTP_STATUS_BAD_REQUEST); await testAction( actions.submitResolvedConflicts, resolveConflictsPath, diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js index 36417eaf793..7152c237420 100644 --- a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js @@ -3,6 +3,7 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import Api from '~/api'; import { createAlert } from '~/flash'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import { MISSING_DELETE_PATH_ERROR } from '~/packages_and_registries/infrastructure_registry/list/constants'; import * as actions from '~/packages_and_registries/infrastructure_registry/list/stores/actions'; import * as types from '~/packages_and_registries/infrastructure_registry/list/stores/mutation_types'; @@ -198,7 +199,7 @@ describe('Actions Package list store', () => { }); it('should stop the loading and call create flash on api error', async () => { - mock.onDelete(payload._links.delete_api_path).replyOnce(400); + mock.onDelete(payload._links.delete_api_path).replyOnce(HTTP_STATUS_BAD_REQUEST); await testAction( actions.requestDeletePackage, payload, diff --git a/spec/frontend/single_file_diff_spec.js b/spec/frontend/single_file_diff_spec.js index 6f42ec47458..a6e532922c8 100644 --- a/spec/frontend/single_file_diff_spec.js +++ b/spec/frontend/single_file_diff_spec.js @@ -2,6 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import $ from 'jquery'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status'; import SingleFileDiff from '~/single_file_diff'; describe('SingleFileDiff', () => { @@ -54,7 +55,7 @@ describe('SingleFileDiff', () => { expect(diff.isOpen).toBe(false); expect(diff.content).not.toBeNull(); - mock.onGet(blobDiffPath).replyOnce(400, ''); + mock.onGet(blobDiffPath).replyOnce(HTTP_STATUS_BAD_REQUEST, ''); // Opening again await diff.toggleDiff($(document.querySelector('.js-file-title'))); |
