diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-03 00:07:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-03 00:07:46 +0300 |
commit | 9579eee8954e0405c2dadb19c2a73c9597ce37ea (patch) | |
tree | d90223b7e449d8d25eef60ad16084ce0d2ca2b1b /spec/frontend/vue_merge_request_widget | |
parent | 0a9b6b99a9bdcacea434501320f1a8d131a33827 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_merge_request_widget')
6 files changed, 35 insertions, 21 deletions
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 f993b82026d..52e2393bf05 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,7 +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 { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } 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'; @@ -79,10 +79,10 @@ describe('Merge Requests Artifacts list app', () => { describe('with results', () => { beforeEach(() => { createComponent(); - mock.onGet(FAKE_ENDPOINT).reply(200, artifacts, {}); + mock.onGet(FAKE_ENDPOINT).reply(HTTP_STATUS_OK, artifacts, {}); store.dispatch('receiveArtifactsSuccess', { data: artifacts, - status: 200, + status: HTTP_STATUS_OK, }); return nextTick(); }); diff --git a/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_container_spec.js b/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_container_spec.js index c3f6331e560..13beb43e10b 100644 --- a/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_container_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_container_spec.js @@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import ArtifactsApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue'; import DeploymentList from '~/vue_merge_request_widget/components/deployment/deployment_list.vue'; import MrWidgetPipeline from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue'; @@ -25,7 +26,7 @@ describe('MrWidgetPipelineContainer', () => { beforeEach(() => { mock = new MockAdapter(axios); - mock.onGet().reply(200, {}); + mock.onGet().reply(HTTP_STATUS_OK, {}); }); afterEach(() => { diff --git a/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_spec.js b/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_spec.js index 144e176b0f0..9c348fc9d58 100644 --- a/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/mr_widget_pipeline_spec.js @@ -4,6 +4,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { trimText } from 'helpers/text_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import MRWidgetPipelineComponent from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue'; import PipelineMiniGraph from '~/pipelines/components/pipeline_mini_graph/pipeline_mini_graph.vue'; import { SUCCESS } from '~/vue_merge_request_widget/constants'; @@ -39,7 +40,7 @@ describe('MRWidgetPipeline', () => { const findMonitoringPipelineMessage = () => wrapper.findByTestId('monitoring-pipeline-message'); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); - const mockArtifactsRequest = () => new MockAdapter(axios).onGet().reply(200, []); + const mockArtifactsRequest = () => new MockAdapter(axios).onGet().reply(HTTP_STATUS_OK, []); const createWrapper = (props = {}, mountFn = shallowMount) => { wrapper = extendedWrapper( diff --git a/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js b/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js index 170c28c3624..c0cd5503cfc 100644 --- a/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/widget/widget_spec.js @@ -8,6 +8,7 @@ import ActionButtons from '~/vue_merge_request_widget/components/widget/action_b import Widget from '~/vue_merge_request_widget/components/widget/widget.vue'; import WidgetContentRow from '~/vue_merge_request_widget/components/widget/widget_content_row.vue'; import * as logger from '~/lib/logger'; +import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; jest.mock('~/vue_merge_request_widget/components/extensions/telemetry', () => ({ createTelemetryHub: jest.fn().mockReturnValue({ @@ -33,7 +34,7 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { isCollapsible: false, loadingText: 'Loading widget', widgetName: 'WidgetTest', - fetchCollapsedData: () => Promise.resolve({ headers: {}, status: 200 }), + fetchCollapsedData: () => Promise.resolve({ headers: {}, status: HTTP_STATUS_OK }), value: { collapsed: null, expanded: null, @@ -57,7 +58,7 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { it('fetches collapsed', async () => { const fetchCollapsedData = jest .fn() - .mockReturnValue(Promise.resolve({ headers: {}, status: 200, data: {} })); + .mockReturnValue(Promise.resolve({ headers: {}, status: HTTP_STATUS_OK, data: {} })); createComponent({ propsData: { fetchCollapsedData } }); await waitForPromises(); @@ -84,7 +85,7 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { it('displays loading icon until request is made and then displays status icon when the request is complete', async () => { const fetchCollapsedData = jest .fn() - .mockReturnValue(Promise.resolve({ headers: {}, status: 200, data: {} })); + .mockReturnValue(Promise.resolve({ headers: {}, status: HTTP_STATUS_OK, data: {} })); createComponent({ propsData: { fetchCollapsedData, statusIconName: 'warning' } }); @@ -123,15 +124,23 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { describe('fetch', () => { it('sets the data.collapsed property after a successfull call - multiPolling: false', async () => { - const mockData = { headers: {}, status: 200, data: { vulnerabilities: [] } }; + const mockData = { headers: {}, status: HTTP_STATUS_OK, data: { vulnerabilities: [] } }; createComponent({ propsData: { fetchCollapsedData: async () => mockData } }); await waitForPromises(); expect(wrapper.emitted('input')[0][0]).toEqual({ collapsed: mockData.data, expanded: null }); }); it('sets the data.collapsed property after a successfull call - multiPolling: true', async () => { - const mockData1 = { headers: {}, status: 200, data: { vulnerabilities: [{ vuln: 1 }] } }; - const mockData2 = { headers: {}, status: 200, data: { vulnerabilities: [{ vuln: 2 }] } }; + const mockData1 = { + headers: {}, + status: HTTP_STATUS_OK, + data: { vulnerabilities: [{ vuln: 1 }] }, + }; + const mockData2 = { + headers: {}, + status: HTTP_STATUS_OK, + data: { vulnerabilities: [{ vuln: 2 }] }, + }; createComponent({ propsData: { @@ -295,13 +304,13 @@ describe('~/vue_merge_request_widget/components/widget/widget.vue', () => { it('fetches expanded data when clicked for the first time', async () => { const mockDataCollapsed = { headers: {}, - status: 200, + status: HTTP_STATUS_OK, data: { vulnerabilities: [{ vuln: 1 }] }, }; const mockDataExpanded = { headers: {}, - status: 200, + status: HTTP_STATUS_OK, data: { vulnerabilities: [{ vuln: 2 }] }, }; 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 824d0d012fb..f37276ad594 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 @@ -75,8 +75,10 @@ describe('MrWidgetOptions', () => { gon.features = { asyncMrWidget: true }; mock = new MockAdapter(axios); - mock.onGet(mockData.merge_request_widget_path).reply(() => [200, { ...mockData }]); - mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [200, { ...mockData }]); + mock.onGet(mockData.merge_request_widget_path).reply(() => [HTTP_STATUS_OK, { ...mockData }]); + mock + .onGet(mockData.merge_request_cached_widget_path) + .reply(() => [HTTP_STATUS_OK, { ...mockData }]); }); afterEach(() => { @@ -806,8 +808,8 @@ describe('MrWidgetOptions', () => { // Override top-level mocked requests, which always use a fresh copy of // mockData, which always includes the full pipeline object. - mock.onGet(mockData.merge_request_widget_path).reply(() => [200, mrData]); - mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [200, mrData]); + mock.onGet(mockData.merge_request_widget_path).reply(() => [HTTP_STATUS_OK, mrData]); + mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [HTTP_STATUS_OK, mrData]); return createComponent(mrData, { apolloMock: [ @@ -987,12 +989,12 @@ describe('MrWidgetOptions', () => { () => Promise.resolve({ headers: { 'poll-interval': 0 }, - status: 200, + status: HTTP_STATUS_OK, data: { reports: 'parsed' }, }), () => Promise.resolve({ - status: 200, + status: HTTP_STATUS_OK, data: { reports: 'parsed' }, }), ]), @@ -1014,7 +1016,7 @@ describe('MrWidgetOptions', () => { }), () => Promise.resolve({ - status: 200, + status: HTTP_STATUS_OK, data: { reports: 'parsed' }, }), ]), diff --git a/spec/frontend/vue_merge_request_widget/test_extensions.js b/spec/frontend/vue_merge_request_widget/test_extensions.js index 1977f550577..ff2dc38442f 100644 --- a/spec/frontend/vue_merge_request_widget/test_extensions.js +++ b/spec/frontend/vue_merge_request_widget/test_extensions.js @@ -1,3 +1,4 @@ +import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants'; export const workingExtension = (shouldCollapse = true) => ({ @@ -120,7 +121,7 @@ export const pollingFullDataExtension = { return Promise.resolve([ { headers: { 'poll-interval': 0 }, - status: 200, + status: HTTP_STATUS_OK, data: { id: 1, text: 'Hello world', |