summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/monitoring')
-rw-r--r--spec/frontend/monitoring/requests/index_spec.js20
-rw-r--r--spec/frontend/monitoring/store/actions_spec.js10
-rw-r--r--spec/frontend/monitoring/store/mutations_spec.js7
3 files changed, 21 insertions, 16 deletions
diff --git a/spec/frontend/monitoring/requests/index_spec.js b/spec/frontend/monitoring/requests/index_spec.js
index def4bfe9443..cf7df3dd9d5 100644
--- a/spec/frontend/monitoring/requests/index_spec.js
+++ b/spec/frontend/monitoring/requests/index_spec.js
@@ -2,8 +2,12 @@ import MockAdapter from 'axios-mock-adapter';
import { backoffMockImplementation } from 'helpers/backoff_helper';
import axios from '~/lib/utils/axios_utils';
import * as commonUtils from '~/lib/utils/common_utils';
-import statusCodes, {
+import {
+ HTTP_STATUS_BAD_REQUEST,
HTTP_STATUS_NO_CONTENT,
+ HTTP_STATUS_OK,
+ HTTP_STATUS_SERVICE_UNAVAILABLE,
+ HTTP_STATUS_UNAUTHORIZED,
HTTP_STATUS_UNPROCESSABLE_ENTITY,
} from '~/lib/utils/http_status';
import { getDashboard, getPrometheusQueryData } from '~/monitoring/requests';
@@ -32,7 +36,7 @@ describe('monitoring metrics_requests', () => {
};
it('returns a dashboard response', () => {
- mock.onGet(dashboardEndpoint).reply(statusCodes.OK, response);
+ mock.onGet(dashboardEndpoint).reply(HTTP_STATUS_OK, response);
return getDashboard(dashboardEndpoint, params).then((data) => {
expect(data).toEqual(metricsDashboardResponse);
@@ -42,7 +46,7 @@ describe('monitoring metrics_requests', () => {
it('returns a dashboard response after retrying twice', () => {
mock.onGet(dashboardEndpoint).replyOnce(HTTP_STATUS_NO_CONTENT);
mock.onGet(dashboardEndpoint).replyOnce(HTTP_STATUS_NO_CONTENT);
- mock.onGet(dashboardEndpoint).reply(statusCodes.OK, response);
+ mock.onGet(dashboardEndpoint).reply(HTTP_STATUS_OK, response);
return getDashboard(dashboardEndpoint, params).then((data) => {
expect(data).toEqual(metricsDashboardResponse);
@@ -75,7 +79,7 @@ describe('monitoring metrics_requests', () => {
};
it('returns a dashboard response', () => {
- mock.onGet(prometheusEndpoint).reply(statusCodes.OK, response);
+ mock.onGet(prometheusEndpoint).reply(HTTP_STATUS_OK, response);
return getPrometheusQueryData(prometheusEndpoint, params).then((data) => {
expect(data).toEqual(response.data);
@@ -86,7 +90,7 @@ describe('monitoring metrics_requests', () => {
// Mock multiple attempts while the cache is filling up
mock.onGet(prometheusEndpoint).replyOnce(HTTP_STATUS_NO_CONTENT);
mock.onGet(prometheusEndpoint).replyOnce(HTTP_STATUS_NO_CONTENT);
- mock.onGet(prometheusEndpoint).reply(statusCodes.OK, response); // 3rd attempt
+ mock.onGet(prometheusEndpoint).reply(HTTP_STATUS_OK, response); // 3rd attempt
return getPrometheusQueryData(prometheusEndpoint, params).then((data) => {
expect(data).toEqual(response.data);
@@ -107,7 +111,7 @@ describe('monitoring metrics_requests', () => {
it('rejects after retrying twice and getting an HTTP 401 error', () => {
// Mock multiple attempts while the cache is filling up and fails
- mock.onGet(prometheusEndpoint).reply(statusCodes.UNAUTHORIZED, {
+ mock.onGet(prometheusEndpoint).reply(HTTP_STATUS_UNAUTHORIZED, {
status: 'error',
error: 'An error occurred',
});
@@ -134,9 +138,9 @@ describe('monitoring metrics_requests', () => {
it.each`
code | reason
- ${statusCodes.BAD_REQUEST} | ${'Parameters are missing or incorrect'}
+ ${HTTP_STATUS_BAD_REQUEST} | ${'Parameters are missing or incorrect'}
${HTTP_STATUS_UNPROCESSABLE_ENTITY} | ${"Expression can't be executed"}
- ${statusCodes.SERVICE_UNAVAILABLE} | ${'Query timed out or aborted'}
+ ${HTTP_STATUS_SERVICE_UNAVAILABLE} | ${'Query timed out or aborted'}
`('rejects with details: "$reason" after getting an HTTP $code error', ({ code, reason }) => {
mock.onGet(prometheusEndpoint).reply(code, {
status: 'error',
diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js
index 93af6526c67..fbe030b1a7d 100644
--- a/spec/frontend/monitoring/store/actions_spec.js
+++ b/spec/frontend/monitoring/store/actions_spec.js
@@ -4,8 +4,10 @@ import testAction from 'helpers/vuex_action_helper';
import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils';
import * as commonUtils from '~/lib/utils/common_utils';
-import statusCodes, {
+import {
+ HTTP_STATUS_BAD_REQUEST,
HTTP_STATUS_CREATED,
+ HTTP_STATUS_OK,
HTTP_STATUS_UNPROCESSABLE_ENTITY,
} from '~/lib/utils/http_status';
import { ENVIRONMENT_AVAILABLE_STATE } from '~/monitoring/constants';
@@ -983,7 +985,7 @@ describe('Monitoring store actions', () => {
});
it('Failed POST request throws an error', async () => {
- mock.onPost(state.dashboardsEndpoint).reply(statusCodes.BAD_REQUEST);
+ mock.onPost(state.dashboardsEndpoint).reply(HTTP_STATUS_BAD_REQUEST);
await expect(testAction(duplicateSystemDashboard, {}, state, [], [])).rejects.toEqual(
'There was an error creating the dashboard.',
@@ -994,7 +996,7 @@ describe('Monitoring store actions', () => {
it('Failed POST request throws an error with a description', async () => {
const backendErrorMsg = 'This file already exists!';
- mock.onPost(state.dashboardsEndpoint).reply(statusCodes.BAD_REQUEST, {
+ mock.onPost(state.dashboardsEndpoint).reply(HTTP_STATUS_BAD_REQUEST, {
error: backendErrorMsg,
});
@@ -1116,7 +1118,7 @@ describe('Monitoring store actions', () => {
mock
.onPost(panelPreviewEndpoint, { panel_yaml: mockYmlContent })
- .reply(statusCodes.OK, mockPanel);
+ .reply(HTTP_STATUS_OK, mockPanel);
testAction(
fetchPanelPreview,
diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js
index 49e8ab9ebd4..3baef743f42 100644
--- a/spec/frontend/monitoring/store/mutations_spec.js
+++ b/spec/frontend/monitoring/store/mutations_spec.js
@@ -1,5 +1,4 @@
-import httpStatusCodes from '~/lib/utils/http_status';
-
+import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_SERVICE_UNAVAILABLE } from '~/lib/utils/http_status';
import { dashboardEmptyStates, metricStates } from '~/monitoring/constants';
import * as types from '~/monitoring/stores/mutation_types';
import mutations from '~/monitoring/stores/mutations';
@@ -318,7 +317,7 @@ describe('Monitoring mutations', () => {
metricId,
error: {
response: {
- status: httpStatusCodes.SERVICE_UNAVAILABLE,
+ status: HTTP_STATUS_SERVICE_UNAVAILABLE,
},
},
});
@@ -336,7 +335,7 @@ describe('Monitoring mutations', () => {
metricId,
error: {
response: {
- status: httpStatusCodes.BAD_REQUEST,
+ status: HTTP_STATUS_BAD_REQUEST,
},
},
});