diff options
Diffstat (limited to 'spec/frontend')
38 files changed, 172 insertions, 82 deletions
diff --git a/spec/frontend/admin/broadcast_messages/components/base_spec.js b/spec/frontend/admin/broadcast_messages/components/base_spec.js index 79bde54286e..d69bf4a22bf 100644 --- a/spec/frontend/admin/broadcast_messages/components/base_spec.js +++ b/spec/frontend/admin/broadcast_messages/components/base_spec.js @@ -6,7 +6,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { redirectTo } from '~/lib/utils/url_utility'; import BroadcastMessagesBase from '~/admin/broadcast_messages/components/base.vue'; import MessagesTable from '~/admin/broadcast_messages/components/messages_table.vue'; @@ -71,7 +71,7 @@ describe('BroadcastMessagesBase', () => { it('does not remove a deleted message if the request fails', async () => { createComponent(); const { id, delete_path } = MOCK_MESSAGES[0]; - axiosMock.onDelete(delete_path).replyOnce(500); + axiosMock.onDelete(delete_path).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); findTable().vm.$emit('delete-message', id); await waitForPromises(); diff --git a/spec/frontend/admin/statistics_panel/store/actions_spec.js b/spec/frontend/admin/statistics_panel/store/actions_spec.js index e7cdb5feb6a..bf97699b1fc 100644 --- a/spec/frontend/admin/statistics_panel/store/actions_spec.js +++ b/spec/frontend/admin/statistics_panel/store/actions_spec.js @@ -5,6 +5,7 @@ import * as actions from '~/admin/statistics_panel/store/actions'; import * as types from '~/admin/statistics_panel/store/mutation_types'; import getInitialState from '~/admin/statistics_panel/store/state'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import mockStatistics from '../mock_data'; describe('Admin statistics panel actions', () => { @@ -43,7 +44,9 @@ describe('Admin statistics panel actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(/api\/(.*)\/application\/statistics/).replyOnce(500); + mock + .onGet(/api\/(.*)\/application\/statistics/) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches error', () => { @@ -99,12 +102,12 @@ describe('Admin statistics panel actions', () => { it('should commit error', () => { return testAction( actions.receiveStatisticsError, - 500, + HTTP_STATUS_INTERNAL_SERVER_ERROR, state, [ { type: types.RECEIVE_STATISTICS_ERROR, - payload: 500, + payload: HTTP_STATUS_INTERNAL_SERVER_ERROR, }, ], [], diff --git a/spec/frontend/admin/statistics_panel/store/mutations_spec.js b/spec/frontend/admin/statistics_panel/store/mutations_spec.js index 0a3dad09c9a..70c1e723f08 100644 --- a/spec/frontend/admin/statistics_panel/store/mutations_spec.js +++ b/spec/frontend/admin/statistics_panel/store/mutations_spec.js @@ -1,6 +1,7 @@ import * as types from '~/admin/statistics_panel/store/mutation_types'; import mutations from '~/admin/statistics_panel/store/mutations'; import getInitialState from '~/admin/statistics_panel/store/state'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import mockStatistics from '../mock_data'; describe('Admin statistics panel mutations', () => { @@ -30,11 +31,10 @@ describe('Admin statistics panel mutations', () => { describe(`${types.RECEIVE_STATISTICS_ERROR}`, () => { it('sets error and clears data', () => { - const error = 500; - mutations[types.RECEIVE_STATISTICS_ERROR](state, error); + mutations[types.RECEIVE_STATISTICS_ERROR](state, HTTP_STATUS_INTERNAL_SERVER_ERROR); expect(state.isLoading).toBe(false); - expect(state.error).toBe(error); + expect(state.error).toBe(HTTP_STATUS_INTERNAL_SERVER_ERROR); expect(state.statistics).toEqual(null); }); }); diff --git a/spec/frontend/badges/store/actions_spec.js b/spec/frontend/badges/store/actions_spec.js index b799273ff63..4e8d7aaaca9 100644 --- a/spec/frontend/badges/store/actions_spec.js +++ b/spec/frontend/badges/store/actions_spec.js @@ -5,6 +5,7 @@ import actions, { transformBackendBadge } from '~/badges/store/actions'; import mutationTypes from '~/badges/store/mutation_types'; import createState from '~/badges/store/state'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { createDummyBadge, createDummyBadgeResponse } from '../dummy_badge'; describe('Badges store actions', () => { @@ -119,7 +120,7 @@ describe('Badges store actions', () => { expect(dispatch.mock.calls).toEqual([['requestNewBadge']]); dispatch.mockClear(); - return [500, '']; + return [HTTP_STATUS_INTERNAL_SERVER_ERROR, '']; }); await expect(actions.addBadge({ state, dispatch })).rejects.toThrow(); @@ -187,7 +188,7 @@ describe('Badges store actions', () => { endpointMock.replyOnce(() => { expect(dispatch.mock.calls).toEqual([['requestDeleteBadge', badgeId]]); dispatch.mockClear(); - return [500, '']; + return [HTTP_STATUS_INTERNAL_SERVER_ERROR, '']; }); await expect(actions.deleteBadge({ state, dispatch }, { id: badgeId })).rejects.toThrow(); @@ -279,7 +280,7 @@ describe('Badges store actions', () => { endpointMock.replyOnce(() => { expect(dispatch.mock.calls).toEqual([['requestLoadBadges', dummyData]]); dispatch.mockClear(); - return [500, '']; + return [HTTP_STATUS_INTERNAL_SERVER_ERROR, '']; }); await expect(actions.loadBadges({ state, dispatch }, dummyData)).rejects.toThrow(); @@ -393,7 +394,7 @@ describe('Badges store actions', () => { endpointMock.replyOnce(() => { expect(dispatch.mock.calls).toEqual([['requestRenderedBadge']]); dispatch.mockClear(); - return [500, '']; + return [HTTP_STATUS_INTERNAL_SERVER_ERROR, '']; }); await expect(actions.renderBadge({ state, dispatch })).rejects.toThrow(); @@ -487,7 +488,7 @@ describe('Badges store actions', () => { expect(dispatch.mock.calls).toEqual([['requestUpdatedBadge']]); dispatch.mockClear(); - return [500, '']; + return [HTTP_STATUS_INTERNAL_SERVER_ERROR, '']; }); await expect(actions.saveBadge({ state, dispatch })).rejects.toThrow(); diff --git a/spec/frontend/blob/notebook/notebook_viever_spec.js b/spec/frontend/blob/notebook/notebook_viever_spec.js index ea4badc03fb..e6480c8d874 100644 --- a/spec/frontend/blob/notebook/notebook_viever_spec.js +++ b/spec/frontend/blob/notebook/notebook_viever_spec.js @@ -4,6 +4,7 @@ import MockAdapter from 'axios-mock-adapter'; import waitForPromises from 'helpers/wait_for_promises'; import component from '~/blob/notebook/notebook_viewer.vue'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import NotebookLab from '~/notebook/index.vue'; describe('iPython notebook renderer', () => { @@ -90,7 +91,7 @@ describe('iPython notebook renderer', () => { describe('error getting file', () => { beforeEach(() => { - mock.onGet(endpoint).reply(500, ''); + mock.onGet(endpoint).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, ''); mountComponent(); return waitForPromises(); diff --git a/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js b/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js index 2246d0bbf7e..a103acb33bc 100644 --- a/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js +++ b/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js @@ -5,6 +5,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import setWindowLocation from 'helpers/set_window_location_helper'; import waitForPromises from 'helpers/wait_for_promises'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { objectToQuery, redirectTo } from '~/lib/utils/url_utility'; import { resolvers } from '~/ci/pipeline_editor/graphql/resolvers'; import PipelineEditorTabs from '~/ci/pipeline_editor/components/pipeline_editor_tabs.vue'; @@ -343,7 +344,7 @@ describe('Pipeline editor app component', () => { describe('when the lint query returns a 500 error', () => { beforeEach(async () => { - mockCiConfigData.mockRejectedValueOnce(new Error(500)); + mockCiConfigData.mockRejectedValueOnce(new Error(HTTP_STATUS_INTERNAL_SERVER_ERROR)); await createComponentWithApollo({ stubs: { PipelineEditorHome, PipelineEditorHeader, ValidationSegment }, }); diff --git a/spec/frontend/code_navigation/store/actions_spec.js b/spec/frontend/code_navigation/store/actions_spec.js index 8eee61d1342..3cedb2fe232 100644 --- a/spec/frontend/code_navigation/store/actions_spec.js +++ b/spec/frontend/code_navigation/store/actions_spec.js @@ -4,6 +4,7 @@ import testAction from 'helpers/vuex_action_helper'; import actions from '~/code_navigation/store/actions'; import { setCurrentHoverElement, addInteractionClass } from '~/code_navigation/utils'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; jest.mock('~/code_navigation/utils'); @@ -124,7 +125,7 @@ describe('Code navigation actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(codeNavigationPath).replyOnce(500); + mock.onGet(codeNavigationPath).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches requestDataError', () => { diff --git a/spec/frontend/commit/pipelines/pipelines_table_spec.js b/spec/frontend/commit/pipelines/pipelines_table_spec.js index 6865b721441..6ad1c308b01 100644 --- a/spec/frontend/commit/pipelines/pipelines_table_spec.js +++ b/spec/frontend/commit/pipelines/pipelines_table_spec.js @@ -337,7 +337,7 @@ describe('Pipelines table in Commits and Merge requests', () => { describe('unsuccessfull request', () => { beforeEach(async () => { - mock.onGet('endpoint.json').reply(500, []); + mock.onGet('endpoint.json').reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, []); createComponent(); diff --git a/spec/frontend/deploy_tokens/components/new_deploy_token_spec.js b/spec/frontend/deploy_tokens/components/new_deploy_token_spec.js index 0bf69acd251..0b82cb32dc4 100644 --- a/spec/frontend/deploy_tokens/components/new_deploy_token_spec.js +++ b/spec/frontend/deploy_tokens/components/new_deploy_token_spec.js @@ -3,6 +3,7 @@ import { nextTick } from 'vue'; import { GlButton, GlFormCheckbox, GlFormInput, GlFormInputGroup, GlDatepicker } from '@gitlab/ui'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { TEST_HOST } from 'helpers/test_constants'; import NewDeployToken from '~/deploy_tokens/components/new_deploy_token.vue'; import waitForPromises from 'helpers/wait_for_promises'; @@ -131,7 +132,7 @@ describe('New Deploy Token', () => { write_package_registry: true, }, }) - .replyOnce(500, { message: expectedErrorMessage }); + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, { message: expectedErrorMessage }); wrapper.findAllComponents(GlButton).at(0).vm.$emit('click'); diff --git a/spec/frontend/environments/folder/environments_folder_view_spec.js b/spec/frontend/environments/folder/environments_folder_view_spec.js index f8b8465cf6f..9c1f463ec3f 100644 --- a/spec/frontend/environments/folder/environments_folder_view_spec.js +++ b/spec/frontend/environments/folder/environments_folder_view_spec.js @@ -5,6 +5,7 @@ import { removeBreakLine, removeWhitespace } from 'helpers/text_helper'; import EnvironmentTable from '~/environments/components/environments_table.vue'; import EnvironmentsFolderViewComponent from '~/environments/folder/environments_folder_view.vue'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { environmentsList } from '../mock_data'; describe('Environments Folder View', () => { @@ -120,7 +121,7 @@ describe('Environments Folder View', () => { describe('unsuccessfull request', () => { beforeEach(() => { - mock.onGet(mockData.endpoint).reply(500, { environments: [] }); + mock.onGet(mockData.endpoint).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, { environments: [] }); createWrapper(); return axios.waitForAll(); }); diff --git a/spec/frontend/feature_flags/components/feature_flags_spec.js b/spec/frontend/feature_flags/components/feature_flags_spec.js index d27b23c5cd1..4ed17234971 100644 --- a/spec/frontend/feature_flags/components/feature_flags_spec.js +++ b/spec/frontend/feature_flags/components/feature_flags_spec.js @@ -11,6 +11,7 @@ import FeatureFlagsComponent from '~/feature_flags/components/feature_flags.vue' import FeatureFlagsTable from '~/feature_flags/components/feature_flags_table.vue'; import createStore from '~/feature_flags/store/index'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue'; import { getRequestData } from '../mock_data'; @@ -271,7 +272,9 @@ describe('Feature flags', () => { describe('unsuccessful request', () => { beforeEach(() => { - mock.onGet(mockState.endpoint, { params: { page: '1' } }).replyOnce(500, {}); + mock + .onGet(mockState.endpoint, { params: { page: '1' } }) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); factory(); return waitForPromises(); diff --git a/spec/frontend/feature_flags/store/edit/actions_spec.js b/spec/frontend/feature_flags/store/edit/actions_spec.js index bcacfa9fda9..8b9b42f4eb1 100644 --- a/spec/frontend/feature_flags/store/edit/actions_spec.js +++ b/spec/frontend/feature_flags/store/edit/actions_spec.js @@ -17,7 +17,7 @@ import * as types from '~/feature_flags/store/edit/mutation_types'; import state from '~/feature_flags/store/edit/state'; import { mapStrategiesToRails } from '~/feature_flags/store/helpers'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; jest.mock('~/lib/utils/url_utility'); @@ -79,7 +79,9 @@ describe('Feature flags Edit Module actions', () => { describe('error', () => { it('dispatches requestUpdateFeatureFlag and receiveUpdateFeatureFlagError', () => { - mock.onPut(`${TEST_HOST}/endpoint.json`).replyOnce(500, { message: [] }); + mock + .onPut(`${TEST_HOST}/endpoint.json`) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, { message: [] }); return testAction( updateFeatureFlag, @@ -180,7 +182,9 @@ describe('Feature flags Edit Module actions', () => { describe('error', () => { it('dispatches requestFeatureFlag and receiveUpdateFeatureFlagError', () => { - mock.onGet(`${TEST_HOST}/endpoint.json`, {}).replyOnce(500, {}); + mock + .onGet(`${TEST_HOST}/endpoint.json`, {}) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); return testAction( fetchFeatureFlag, diff --git a/spec/frontend/feature_flags/store/index/actions_spec.js b/spec/frontend/feature_flags/store/index/actions_spec.js index 96a7d868316..a7a8793c82c 100644 --- a/spec/frontend/feature_flags/store/index/actions_spec.js +++ b/spec/frontend/feature_flags/store/index/actions_spec.js @@ -20,6 +20,7 @@ import { import * as types from '~/feature_flags/store/index/mutation_types'; import state from '~/feature_flags/store/index/state'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { getRequestData, rotateData, featureFlag } from '../../mock_data'; jest.mock('~/api.js'); @@ -79,7 +80,9 @@ describe('Feature flags actions', () => { describe('error', () => { it('dispatches requestFeatureFlags and receiveFeatureFlagsError', () => { - mock.onGet(`${TEST_HOST}/endpoint.json`, {}).replyOnce(500, {}); + mock + .onGet(`${TEST_HOST}/endpoint.json`, {}) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); return testAction( fetchFeatureFlags, @@ -176,7 +179,9 @@ describe('Feature flags actions', () => { describe('error', () => { it('dispatches requestRotateInstanceId and receiveRotateInstanceIdError', () => { - mock.onGet(`${TEST_HOST}/endpoint.json`, {}).replyOnce(500, {}); + mock + .onGet(`${TEST_HOST}/endpoint.json`, {}) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); return testAction( rotateInstanceId, @@ -275,7 +280,7 @@ describe('Feature flags actions', () => { describe('error', () => { it('dispatches updateFeatureFlag and receiveUpdateFeatureFlagSuccess', () => { - mock.onPut(featureFlag.update_path).replyOnce(500); + mock.onPut(featureFlag.update_path).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); return testAction( toggleFeatureFlag, diff --git a/spec/frontend/feature_flags/store/new/actions_spec.js b/spec/frontend/feature_flags/store/new/actions_spec.js index c8bf05e4dbd..01b6ab4d5ed 100644 --- a/spec/frontend/feature_flags/store/new/actions_spec.js +++ b/spec/frontend/feature_flags/store/new/actions_spec.js @@ -11,7 +11,7 @@ import { import * as types from '~/feature_flags/store/new/mutation_types'; import state from '~/feature_flags/store/new/state'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; jest.mock('~/lib/utils/url_utility'); @@ -88,7 +88,7 @@ describe('Feature flags New Module Actions', () => { }; mock .onPost(mockedState.endpoint, mapStrategiesToRails(actionParams)) - .replyOnce(500, { message: [] }); + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, { message: [] }); return testAction( createFeatureFlag, diff --git a/spec/frontend/frequent_items/store/actions_spec.js b/spec/frontend/frequent_items/store/actions_spec.js index 4f998cc26da..15905d71a21 100644 --- a/spec/frontend/frequent_items/store/actions_spec.js +++ b/spec/frontend/frequent_items/store/actions_spec.js @@ -5,6 +5,7 @@ import * as types from '~/frequent_items/store/mutation_types'; import state from '~/frequent_items/store/state'; import AccessorUtilities from '~/lib/utils/accessor'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; import { mockNamespace, @@ -192,7 +193,7 @@ describe('Frequent Items Dropdown Store Actions', () => { it('should dispatch `receiveSearchedItemsError`', () => { gon.api_version = 'v4'; - mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(500); + mock.onGet(/\/api\/v4\/projects.json(.*)$/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); return testAction( actions.fetchSearchedItems, diff --git a/spec/frontend/groups/components/app_spec.js b/spec/frontend/groups/components/app_spec.js index fea3b547977..eca56325366 100644 --- a/spec/frontend/groups/components/app_spec.js +++ b/spec/frontend/groups/components/app_spec.js @@ -11,7 +11,11 @@ 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_BAD_REQUEST, HTTP_STATUS_FORBIDDEN } from '~/lib/utils/http_status'; +import { + HTTP_STATUS_BAD_REQUEST, + HTTP_STATUS_FORBIDDEN, + HTTP_STATUS_INTERNAL_SERVER_ERROR, +} from '~/lib/utils/http_status'; import * as urlUtilities from '~/lib/utils/url_utility'; import setWindowLocation from 'helpers/set_window_location_helper'; @@ -322,7 +326,9 @@ describe('AppComponent', () => { it('should show error flash message if request failed to leave group', () => { const message = 'An error occurred. Please try again.'; - jest.spyOn(vm.service, 'leaveGroup').mockRejectedValue({ status: 500 }); + jest + .spyOn(vm.service, 'leaveGroup') + .mockRejectedValue({ status: HTTP_STATUS_INTERNAL_SERVER_ERROR }); jest.spyOn(vm.store, 'removeGroup'); vm.leaveGroup(); diff --git a/spec/frontend/ide/lib/mirror_spec.js b/spec/frontend/ide/lib/mirror_spec.js index 8f417ea54dc..33dd0fefc6c 100644 --- a/spec/frontend/ide/lib/mirror_spec.js +++ b/spec/frontend/ide/lib/mirror_spec.js @@ -7,6 +7,7 @@ import { MSG_CONNECTION_ERROR, SERVICE_DELAY, } from '~/ide/lib/mirror'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { getWebSocketUrl } from '~/lib/utils/url_utility'; jest.mock('~/ide/lib/create_diff', () => jest.fn()); @@ -26,7 +27,7 @@ const TEST_ERROR_RESPONSE = { const TEST_ERROR_PAYLOAD_RESPONSE = { data: JSON.stringify({ error: { code: 0 }, - payload: { status_code: 500, error_message: TEST_ERROR }, + payload: { status_code: HTTP_STATUS_INTERNAL_SERVER_ERROR, error_message: TEST_ERROR }, }), }; diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js index 6e8a03b47ad..4551a7a21f1 100644 --- a/spec/frontend/ide/stores/actions/tree_spec.js +++ b/spec/frontend/ide/stores/actions/tree_spec.js @@ -8,6 +8,7 @@ import { createStore } from '~/ide/stores'; import { showTreeEntry, getFiles, setDirectoryData } from '~/ide/stores/actions/tree'; import * as types from '~/ide/stores/mutation_types'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { file, createEntriesFromPaths } from '../../helpers'; describe('Multi-file store tree actions', () => { @@ -98,7 +99,7 @@ describe('Multi-file store tree actions', () => { findBranch: () => store.state.projects['abc/def'].branches['main-testing'], }; - mock.onGet(/(.*)/).replyOnce(500); + mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); await expect( getFiles( diff --git a/spec/frontend/ide/stores/modules/branches/actions_spec.js b/spec/frontend/ide/stores/modules/branches/actions_spec.js index 306330e3ba2..38a2e1ac12f 100644 --- a/spec/frontend/ide/stores/modules/branches/actions_spec.js +++ b/spec/frontend/ide/stores/modules/branches/actions_spec.js @@ -10,6 +10,7 @@ import { import * as types from '~/ide/stores/modules/branches/mutation_types'; import state from '~/ide/stores/modules/branches/state'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { branches, projectData } from '../../../mock_data'; describe('IDE branches actions', () => { @@ -124,7 +125,9 @@ describe('IDE branches actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/).replyOnce(500); + mock + .onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches error', () => { diff --git a/spec/frontend/ide/stores/modules/file_templates/actions_spec.js b/spec/frontend/ide/stores/modules/file_templates/actions_spec.js index 1080a30d2d8..0a99496a147 100644 --- a/spec/frontend/ide/stores/modules/file_templates/actions_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/actions_spec.js @@ -4,6 +4,7 @@ import * as actions from '~/ide/stores/modules/file_templates/actions'; import * as types from '~/ide/stores/modules/file_templates/mutation_types'; import createState from '~/ide/stores/modules/file_templates/state'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; describe('IDE file templates actions', () => { let state; @@ -108,7 +109,7 @@ describe('IDE file templates actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(/api\/(.*)\/templates\/licenses/).replyOnce(500); + mock.onGet(/api\/(.*)\/templates\/licenses/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches actions', () => { @@ -248,7 +249,9 @@ describe('IDE file templates actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(/api\/(.*)\/templates\/licenses\/mit/).replyOnce(500); + mock + .onGet(/api\/(.*)\/templates\/licenses\/mit/) + .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches error', () => { diff --git a/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js b/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js index 344fe3a41c3..5d3bf063ac8 100644 --- a/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js +++ b/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js @@ -10,6 +10,7 @@ import { import * as types from '~/ide/stores/modules/merge_requests/mutation_types'; import state from '~/ide/stores/modules/merge_requests/state'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { mergeRequests } from '../../../mock_data'; describe('IDE merge requests actions', () => { @@ -169,7 +170,7 @@ describe('IDE merge requests actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(/\/api\/v4\/merge_requests(.*)$/).replyOnce(500); + mock.onGet(/\/api\/v4\/merge_requests(.*)$/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); }); it('dispatches error', () => { 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 bf57373dd03..f541e579810 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js @@ -13,6 +13,7 @@ import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_FORBIDDEN, + HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY, } from '~/lib/utils/http_status'; @@ -277,7 +278,9 @@ describe('IDE store terminal check actions', () => { }); it('dispatches request and receive, when error', () => { - mock.onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } }).reply(500, []); + mock + .onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } }) + .reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, []); return testAction( actions.fetchRunnersCheck, diff --git a/spec/frontend/labels/components/promote_label_modal_spec.js b/spec/frontend/labels/components/promote_label_modal_spec.js index 8953e3cbcd8..9dd6f1ca64c 100644 --- a/spec/frontend/labels/components/promote_label_modal_spec.js +++ b/spec/frontend/labels/components/promote_label_modal_spec.js @@ -6,6 +6,7 @@ import { TEST_HOST } from 'helpers/test_constants'; import { stubComponent } from 'helpers/stub_component'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import PromoteLabelModal from '~/labels/components/promote_label_modal.vue'; import eventHub from '~/labels/event_hub'; @@ -85,8 +86,10 @@ describe('Promote label modal', () => { it('displays an error if promoting a label failed', async () => { const dummyError = new Error('promoting label failed'); - dummyError.response = { status: 500 }; - axiosMock.onPost(labelMockData.url).reply(500, { error: dummyError }); + dummyError.response = { status: HTTP_STATUS_INTERNAL_SERVER_ERROR }; + axiosMock + .onPost(labelMockData.url) + .reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, { error: dummyError }); wrapper.findComponent(GlModal).vm.$emit('primary'); diff --git a/spec/frontend/lib/utils/favicon_ci_spec.js b/spec/frontend/lib/utils/favicon_ci_spec.js index e35b008b862..6385af952e7 100644 --- a/spec/frontend/lib/utils/favicon_ci_spec.js +++ b/spec/frontend/lib/utils/favicon_ci_spec.js @@ -2,6 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import { setFaviconOverlay, resetFavicon } from '~/lib/utils/favicon'; import { setCiStatusFavicon } from '~/lib/utils/favicon_ci'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; jest.mock('~/lib/utils/favicon'); @@ -41,7 +42,7 @@ describe('~/lib/utils/favicon_ci', () => { ); it('with error', async () => { - mock.onGet(TEST_URL).replyOnce(500); + mock.onGet(TEST_URL).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); await expect(setCiStatusFavicon(TEST_URL)).rejects.toEqual(expect.any(Error)); expect(resetFavicon).toHaveBeenCalled(); diff --git a/spec/frontend/lib/utils/poll_spec.js b/spec/frontend/lib/utils/poll_spec.js index 94a5f5385b7..0e6c08bf033 100644 --- a/spec/frontend/lib/utils/poll_spec.js +++ b/spec/frontend/lib/utils/poll_spec.js @@ -1,5 +1,5 @@ import waitForPromises from 'helpers/wait_for_promises'; -import { successCodes } from '~/lib/utils/http_status'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, successCodes } from '~/lib/utils/http_status'; import Poll from '~/lib/utils/poll'; describe('Poll', () => { @@ -61,7 +61,7 @@ describe('Poll', () => { }); it('calls the error callback when the http request returns an error', () => { - mockServiceCall({ status: 500 }, true); + mockServiceCall({ status: HTTP_STATUS_INTERNAL_SERVER_ERROR }, true); setup(); return waitForAllCallsToFinish(1, () => { diff --git a/spec/frontend/milestones/components/milestone_combobox_spec.js b/spec/frontend/milestones/components/milestone_combobox_spec.js index c20c51db75e..27485f3d51d 100644 --- a/spec/frontend/milestones/components/milestone_combobox_spec.js +++ b/spec/frontend/milestones/components/milestone_combobox_spec.js @@ -4,6 +4,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { ENTER_KEY } from '~/lib/utils/keys'; import MilestoneCombobox from '~/milestones/components/milestone_combobox.vue'; import createStore from '~/milestones/stores/'; @@ -314,8 +315,10 @@ describe('Milestone combobox component', () => { describe('when the project milestones search returns an error', () => { beforeEach(() => { - projectMilestonesApiCallSpy = jest.fn().mockReturnValue([500]); - searchApiCallSpy = jest.fn().mockReturnValue([500]); + projectMilestonesApiCallSpy = jest + .fn() + .mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); + searchApiCallSpy = jest.fn().mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); createComponent({ value: [] }); @@ -441,8 +444,10 @@ describe('Milestone combobox component', () => { describe('when the group milestones search returns an error', () => { beforeEach(() => { - groupMilestonesApiCallSpy = jest.fn().mockReturnValue([500]); - searchApiCallSpy = jest.fn().mockReturnValue([500]); + groupMilestonesApiCallSpy = jest + .fn() + .mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); + searchApiCallSpy = jest.fn().mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); createComponent({ value: [] }); diff --git a/spec/frontend/milestones/components/promote_milestone_modal_spec.js b/spec/frontend/milestones/components/promote_milestone_modal_spec.js index 60657fbc9b8..d7ad3d29d0a 100644 --- a/spec/frontend/milestones/components/promote_milestone_modal_spec.js +++ b/spec/frontend/milestones/components/promote_milestone_modal_spec.js @@ -5,6 +5,7 @@ import { TEST_HOST } from 'helpers/test_constants'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import * as urlUtils from '~/lib/utils/url_utility'; import PromoteMilestoneModal from '~/milestones/components/promote_milestone_modal.vue'; @@ -94,7 +95,7 @@ describe('Promote milestone modal', () => { it('displays an error if promoting a milestone failed', async () => { const dummyError = new Error('promoting milestone failed'); - dummyError.response = { status: 500 }; + dummyError.response = { status: HTTP_STATUS_INTERNAL_SERVER_ERROR }; jest.spyOn(axios, 'post').mockImplementation((url) => { expect(url).toBe(milestoneMockData.url); return Promise.reject(dummyError); diff --git a/spec/frontend/pipelines/pipeline_multi_actions_spec.js b/spec/frontend/pipelines/pipeline_multi_actions_spec.js index f0dae8ebcbe..544a33b10db 100644 --- a/spec/frontend/pipelines/pipeline_multi_actions_spec.js +++ b/spec/frontend/pipelines/pipeline_multi_actions_spec.js @@ -5,6 +5,7 @@ import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import PipelineMultiActions, { i18n, } from '~/pipelines/components/pipelines_list/pipeline_multi_actions.vue'; @@ -140,7 +141,7 @@ describe('Pipeline Multi Actions Dropdown', () => { describe('with a failing request', () => { it('should render an error message', async () => { const endpoint = artifactsEndpoint.replace(artifactsEndpointPlaceholder, pipelineId); - mockAxios.onGet(endpoint).replyOnce(500); + mockAxios.onGet(endpoint).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); createComponent(); findDropdown().vm.$emit('show'); await waitForPromises(); diff --git a/spec/frontend/pipelines/pipelines_spec.js b/spec/frontend/pipelines/pipelines_spec.js index 351572fc83a..17ff0969b30 100644 --- a/spec/frontend/pipelines/pipelines_spec.js +++ b/spec/frontend/pipelines/pipelines_spec.js @@ -13,6 +13,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import Api from '~/api'; import { createAlert, VARIANT_WARNING } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import NavigationControls from '~/pipelines/components/pipelines_list/nav_controls.vue'; import PipelinesComponent from '~/pipelines/components/pipelines_list/pipelines.vue'; import PipelinesCiTemplates from '~/pipelines/components/pipelines_list/empty_state/pipelines_ci_templates.vue'; @@ -702,7 +703,7 @@ describe('Pipelines', () => { describe('when pipelines cannot be loaded', () => { beforeEach(async () => { - mock.onGet(mockPipelinesEndpoint).reply(500, {}); + mock.onGet(mockPipelinesEndpoint).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); }); describe('when user has no permissions', () => { diff --git a/spec/frontend/projects/commit_box/info/load_branches_spec.js b/spec/frontend/projects/commit_box/info/load_branches_spec.js index 9456e6ef5f5..50e305dea7f 100644 --- a/spec/frontend/projects/commit_box/info/load_branches_spec.js +++ b/spec/frontend/projects/commit_box/info/load_branches_spec.js @@ -2,6 +2,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { setHTMLFixture } from 'helpers/fixtures'; import waitForPromises from 'helpers/wait_for_promises'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { loadBranches } from '~/projects/commit_box/info/load_branches'; const mockCommitPath = '/commit/abcd/branches'; @@ -60,7 +61,7 @@ describe('~/projects/commit_box/info/load_branches', () => { describe('when branches request fails', () => { beforeEach(() => { - mock.onGet(mockCommitPath).reply(500, 'Error!'); + mock.onGet(mockCommitPath).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, 'Error!'); }); it('attempts to load and renders an error', async () => { diff --git a/spec/frontend/projects/commits/store/actions_spec.js b/spec/frontend/projects/commits/store/actions_spec.js index 930b801af71..64eba056c6f 100644 --- a/spec/frontend/projects/commits/store/actions_spec.js +++ b/spec/frontend/projects/commits/store/actions_spec.js @@ -2,6 +2,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { createAlert } from '~/flash'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import actions from '~/projects/commits/store/actions'; import * as types from '~/projects/commits/store/mutation_types'; import createState from '~/projects/commits/store/state'; @@ -63,7 +64,7 @@ describe('Project commits actions', () => { it('dispatches request/receive on error', () => { const path = '/-/autocomplete/users.json'; - mock.onGet(path).replyOnce(500); + mock.onGet(path).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); testAction(actions.fetchAuthors, null, state, [], [{ type: 'receiveAuthorsError' }]); }); diff --git a/spec/frontend/protected_branches/protected_branch_edit_spec.js b/spec/frontend/protected_branches/protected_branch_edit_spec.js index 0aec4fbc037..8e1a09500c7 100644 --- a/spec/frontend/protected_branches/protected_branch_edit_spec.js +++ b/spec/frontend/protected_branches/protected_branch_edit_spec.js @@ -4,6 +4,7 @@ import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import { TEST_HOST } from 'helpers/test_constants'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import ProtectedBranchEdit from '~/protected_branches/protected_branch_edit'; jest.mock('~/flash'); @@ -142,7 +143,7 @@ describe('ProtectedBranchEdit', () => { describe('when clicked and BE error', () => { beforeEach(() => { - mock.onPatch(TEST_URL).replyOnce(500); + mock.onPatch(TEST_URL).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); toggle.click(); }); diff --git a/spec/frontend/ref/components/ref_selector_spec.js b/spec/frontend/ref/components/ref_selector_spec.js index ac588248f15..e12659a0eff 100644 --- a/spec/frontend/ref/components/ref_selector_spec.js +++ b/spec/frontend/ref/components/ref_selector_spec.js @@ -9,7 +9,7 @@ import commit from 'test_fixtures/api/commits/commit.json'; import branches from 'test_fixtures/api/branches/branches.json'; import tags from 'test_fixtures/api/tags/tags.json'; import { trimText } from 'helpers/text_helper'; -import { HTTP_STATUS_NOT_FOUND } from '~/lib/utils/http_status'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_NOT_FOUND } from '~/lib/utils/http_status'; import { ENTER_KEY } from '~/lib/utils/keys'; import { sprintf } from '~/locale'; import RefSelector from '~/ref/components/ref_selector.vue'; @@ -400,7 +400,7 @@ describe('Ref selector component', () => { describe('when the branches search returns an error', () => { beforeEach(() => { - branchesApiCallSpy = jest.fn().mockReturnValue([500]); + branchesApiCallSpy = jest.fn().mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); createComponent(); @@ -465,7 +465,7 @@ describe('Ref selector component', () => { describe('when the tags search returns an error', () => { beforeEach(() => { - tagsApiCallSpy = jest.fn().mockReturnValue([500]); + tagsApiCallSpy = jest.fn().mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); createComponent(); @@ -531,7 +531,7 @@ describe('Ref selector component', () => { describe('when the commit search returns an error (other than a 404)', () => { beforeEach(() => { - commitApiCallSpy = jest.fn().mockReturnValue([500]); + commitApiCallSpy = jest.fn().mockReturnValue([HTTP_STATUS_INTERNAL_SERVER_ERROR]); createComponent(); diff --git a/spec/frontend/repository/components/fork_info_spec.js b/spec/frontend/repository/components/fork_info_spec.js index c23d5ae5823..f327a8cfae7 100644 --- a/spec/frontend/repository/components/fork_info_spec.js +++ b/spec/frontend/repository/components/fork_info_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; -import { GlSkeletonLoader, GlIcon, GlLink } from '@gitlab/ui'; +import { GlSkeletonLoader, GlIcon, GlLink, GlSprintf } from '@gitlab/ui'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; @@ -16,13 +16,14 @@ describe('ForkInfo component', () => { let wrapper; let mockResolver; const forkInfoError = new Error('Something went wrong'); + const projectId = 'gid://gitlab/Project/1'; Vue.use(VueApollo); const createCommitData = ({ ahead = 3, behind = 7 }) => { return { data: { - project: { id: '1', forkDetails: { ahead, behind, __typename: 'ForkDetails' } }, + project: { id: projectId, forkDetails: { ahead, behind, __typename: 'ForkDetails' } }, }, }; }; @@ -35,6 +36,7 @@ describe('ForkInfo component', () => { wrapper = shallowMountExtended(ForkInfo, { apolloProvider: createMockApollo([[forkDetailsQuery, mockResolver]]), propsData: { ...propsForkInfo, ...props }, + stubs: { GlSprintf }, }); return waitForPromises(); }; @@ -42,8 +44,10 @@ describe('ForkInfo component', () => { const findLink = () => wrapper.findComponent(GlLink); const findSkeleton = () => wrapper.findComponent(GlSkeletonLoader); const findIcon = () => wrapper.findComponent(GlIcon); - const findDivergenceMessage = () => wrapper.find('.gl-text-secondary'); + const findDivergenceMessage = () => wrapper.findByTestId('divergence-message'); const findInaccessibleMessage = () => wrapper.findByTestId('inaccessible-project'); + const findCompareLinks = () => findDivergenceMessage().findAllComponents(GlLink); + it('displays a skeleton while loading data', async () => { createComponent(); expect(findSkeleton().exists()).toBe(true); @@ -88,28 +92,54 @@ describe('ForkInfo component', () => { expect(findDivergenceMessage().text()).toBe(i18n.unknown); }); - it('shows correct divergence message when data is present', async () => { - await createComponent(); - expect(findDivergenceMessage().text()).toMatchInterpolatedText( - '7 commits behind, 3 commits ahead of the upstream repository.', - ); - }); - it('renders up to date message when divergence is unknown', async () => { await createComponent({}, { ahead: 0, behind: 0 }); expect(findDivergenceMessage().text()).toBe(i18n.upToDate); }); - it('renders commits ahead message', async () => { - await createComponent({}, { behind: 0 }); - expect(findDivergenceMessage().text()).toBe('3 commits ahead of the upstream repository.'); - }); - - it('renders commits behind message', async () => { - await createComponent({}, { ahead: 0 }); - - expect(findDivergenceMessage().text()).toBe('7 commits behind the upstream repository.'); - }); + describe.each([ + { + ahead: 7, + behind: 3, + message: '3 commits behind, 7 commits ahead of the upstream repository.', + firstLink: propsForkInfo.behindComparePath, + secondLink: propsForkInfo.aheadComparePath, + }, + { + ahead: 7, + behind: 0, + message: '7 commits ahead of the upstream repository.', + firstLink: propsForkInfo.aheadComparePath, + secondLink: '', + }, + { + ahead: 0, + behind: 3, + message: '3 commits behind the upstream repository.', + firstLink: propsForkInfo.behindComparePath, + secondLink: '', + }, + ])( + 'renders correct divergence message for ahead: $ahead, behind: $behind divergence commits', + ({ ahead, behind, message, firstLink, secondLink }) => { + beforeEach(async () => { + await createComponent({}, { ahead, behind }); + }); + + it('displays correct text', () => { + expect(findDivergenceMessage().text()).toBe(message); + }); + + it('adds correct links', () => { + const links = findCompareLinks(); + expect(links.at(0).attributes('href')).toBe(firstLink); + + if (secondLink) { + expect(links.at(1).attributes('href')).toBe(secondLink); + } + }); + }, + ); it('renders alert with error message when request fails', async () => { await createComponent({}, {}, true); diff --git a/spec/frontend/repository/mock_data.js b/spec/frontend/repository/mock_data.js index d85434a9148..04ffe52bc3f 100644 --- a/spec/frontend/repository/mock_data.js +++ b/spec/frontend/repository/mock_data.js @@ -120,7 +120,9 @@ export const graphQLErrors = [ export const propsForkInfo = { projectPath: 'nataliia/myGitLab', - selectedRef: 'main', + selectedBranch: 'main', sourceName: 'gitLab', sourcePath: 'gitlab-org/gitlab', + aheadComparePath: '/nataliia/myGitLab/-/compare/main...ref?from_project_id=1', + behindComparePath: 'gitlab-org/gitlab/-/compare/ref...main?from_project_id=2', }; diff --git a/spec/frontend/sidebar/components/labels/labels_select_vue/store/actions_spec.js b/spec/frontend/sidebar/components/labels/labels_select_vue/store/actions_spec.js index 0e0024aa6c2..56d516bf589 100644 --- a/spec/frontend/sidebar/components/labels/labels_select_vue/store/actions_spec.js +++ b/spec/frontend/sidebar/components/labels/labels_select_vue/store/actions_spec.js @@ -3,6 +3,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_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import * as actions from '~/sidebar/components/labels/labels_select_vue/store/actions'; import * as types from '~/sidebar/components/labels/labels_select_vue/store/mutation_types'; import defaultState from '~/sidebar/components/labels/labels_select_vue/store/state'; @@ -135,7 +136,7 @@ describe('LabelsSelect Actions', () => { describe('on failure', () => { it('dispatches `requestLabels` & `receiveLabelsFailure` actions', () => { - mock.onGet(/labels.json/).replyOnce(500, {}); + mock.onGet(/labels.json/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); return testAction( actions.fetchLabels, @@ -224,7 +225,7 @@ describe('LabelsSelect Actions', () => { describe('on failure', () => { it('dispatches `requestCreateLabel` & `receiveCreateLabelFailure` actions', () => { - mock.onPost(/labels.json/).replyOnce(500, {}); + mock.onPost(/labels.json/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}); return testAction( actions.createLabel, diff --git a/spec/frontend/snippets/components/snippet_blob_edit_spec.js b/spec/frontend/snippets/components/snippet_blob_edit_spec.js index 33b8e2be969..ad5fca760f4 100644 --- a/spec/frontend/snippets/components/snippet_blob_edit_spec.js +++ b/spec/frontend/snippets/components/snippet_blob_edit_spec.js @@ -6,6 +6,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import BlobHeaderEdit from '~/blob/components/blob_edit_header.vue'; import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import { joinPaths } from '~/lib/utils/url_utility'; import SnippetBlobEdit from '~/snippets/components/snippet_blob_edit.vue'; import SourceEditor from '~/vue_shared/components/source_editor.vue'; @@ -118,7 +119,7 @@ describe('Snippet Blob Edit component', () => { describe('with error', () => { beforeEach(() => { axiosMock.reset(); - axiosMock.onGet(TEST_FULL_PATH).replyOnce(500); + axiosMock.onGet(TEST_FULL_PATH).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR); createComponent(); }); diff --git a/spec/frontend/vue_merge_request_widget/components/artifacts_list_app_spec.js b/spec/frontend/vue_merge_request_widget/components/artifacts_list_app_spec.js index 73fa4b7b08f..f993b82026d 100644 --- a/spec/frontend/vue_merge_request_widget/components/artifacts_list_app_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/artifacts_list_app_spec.js @@ -5,6 +5,7 @@ import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { TEST_HOST as FAKE_ENDPOINT } from 'helpers/test_constants'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '~/lib/utils/http_status'; import ArtifactsListApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue'; import { getStoreConfig } from '~/vue_merge_request_widget/stores/artifacts_list'; import { artifacts } from '../mock_data'; @@ -109,7 +110,7 @@ describe('Merge Requests Artifacts list app', () => { describe('with error', () => { beforeEach(() => { createComponent(); - mock.onGet(FAKE_ENDPOINT).reply(500, {}, {}); + mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {}, {}); store.dispatch('receiveArtifactsError'); return nextTick(); }); |