summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring/store
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 12:09:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 12:09:26 +0000
commit2e4c4055181eec9186458dd5dd3219c937032ec7 (patch)
treeeee59e7124ffcf093f1b53369436c69cfe4d9cc5 /spec/frontend/monitoring/store
parent97f0ae7454597105a27df65ffb772949d9d4f3cb (diff)
downloadgitlab-ce-2e4c4055181eec9186458dd5dd3219c937032ec7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/monitoring/store')
-rw-r--r--spec/frontend/monitoring/store/actions_spec.js12
-rw-r--r--spec/frontend/monitoring/store/mutations_spec.js5
-rw-r--r--spec/frontend/monitoring/store/utils_spec.js6
3 files changed, 12 insertions, 11 deletions
diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js
index b37c10791bf..d6faec29b65 100644
--- a/spec/frontend/monitoring/store/actions_spec.js
+++ b/spec/frontend/monitoring/store/actions_spec.js
@@ -15,7 +15,7 @@ import {
receiveMetricsDashboardSuccess,
fetchDeploymentsData,
fetchEnvironmentsData,
- fetchPrometheusMetrics,
+ fetchDashboardData,
fetchPrometheusMetric,
setInitialState,
filterEnvironments,
@@ -375,7 +375,7 @@ describe('Monitoring store actions', () => {
metricsDashboardResponse.dashboard,
);
- expect(dispatch).toHaveBeenCalledWith('fetchPrometheusMetrics');
+ expect(dispatch).toHaveBeenCalledWith('fetchDashboardData');
});
it('sets the dashboards loaded from the repository', () => {
const params = {};
@@ -395,7 +395,7 @@ describe('Monitoring store actions', () => {
expect(commit).toHaveBeenCalledWith(types.SET_ALL_DASHBOARDS, dashboardGitResponse);
});
});
- describe('fetchPrometheusMetrics', () => {
+ describe('fetchDashboardData', () => {
let commit;
let dispatch;
let state;
@@ -413,7 +413,7 @@ describe('Monitoring store actions', () => {
const getters = {
metricsWithData: () => [],
};
- fetchPrometheusMetrics({ state, commit, dispatch, getters })
+ fetchDashboardData({ state, commit, dispatch, getters })
.then(() => {
expect(Tracking.event).toHaveBeenCalledWith(
document.body.dataset.page,
@@ -442,7 +442,7 @@ describe('Monitoring store actions', () => {
metricsWithData: () => [metric.id],
};
- fetchPrometheusMetrics({ state, commit, dispatch, getters })
+ fetchDashboardData({ state, commit, dispatch, getters })
.then(() => {
expect(dispatch).toHaveBeenCalledWith('fetchPrometheusMetric', {
metric,
@@ -478,7 +478,7 @@ describe('Monitoring store actions', () => {
dispatch.mockRejectedValueOnce(new Error('Error fetching this metric'));
dispatch.mockResolvedValue();
- fetchPrometheusMetrics({ state, commit, dispatch })
+ fetchDashboardData({ state, commit, dispatch })
.then(() => {
expect(dispatch).toHaveBeenCalledTimes(10); // one per metric plus 1 for deployments
expect(dispatch).toHaveBeenCalledWith('fetchDeploymentsData');
diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js
index 21a27a443af..34d224e13b0 100644
--- a/spec/frontend/monitoring/store/mutations_spec.js
+++ b/spec/frontend/monitoring/store/mutations_spec.js
@@ -202,15 +202,12 @@ describe('Monitoring mutations', () => {
mutations[types.REQUEST_METRIC_RESULT](stateCopy, {
metricId,
- result,
});
expect(stateCopy.showEmptyState).toBe(true);
expect(getMetric()).toEqual(
expect.objectContaining({
loading: true,
- result: null,
- state: metricStates.LOADING,
}),
);
});
@@ -232,7 +229,7 @@ describe('Monitoring mutations', () => {
});
it('adds results to the store', () => {
- expect(getMetric().result).toBe(undefined);
+ expect(getMetric().result).toBe(null);
mutations[types.RECEIVE_METRIC_RESULT_SUCCESS](stateCopy, {
metricId,
diff --git a/spec/frontend/monitoring/store/utils_spec.js b/spec/frontend/monitoring/store/utils_spec.js
index fcc5614850b..f46409e8e32 100644
--- a/spec/frontend/monitoring/store/utils_spec.js
+++ b/spec/frontend/monitoring/store/utils_spec.js
@@ -5,6 +5,7 @@ import {
removeLeadingSlash,
mapToDashboardViewModel,
} from '~/monitoring/stores/utils';
+import { NOT_IN_DB_PREFIX } from '~/monitoring/constants';
const projectPath = 'gitlab-org/gitlab-test';
@@ -256,6 +257,9 @@ describe('mapToDashboardViewModel', () => {
expect(getMappedMetric(dashboard)).toEqual({
label: expect.any(String),
metricId: expect.any(String),
+ loading: false,
+ result: null,
+ state: null,
});
});
@@ -307,7 +311,7 @@ describe('mapToDashboardViewModel', () => {
describe('uniqMetricsId', () => {
[
- { input: { id: 1 }, expected: 'NO_DB_1' },
+ { input: { id: 1 }, expected: `${NOT_IN_DB_PREFIX}_1` },
{ input: { metric_id: 2 }, expected: '2_undefined' },
{ input: { metric_id: 2, id: 21 }, expected: '2_21' },
{ input: { metric_id: 22, id: 1 }, expected: '22_1' },