Commit 03f47a99 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '36262-monitor-cluster-health-charts-does-not-load' into 'master'

Fix broken cluster health dashboard

Closes #36262

See merge request gitlab-org/gitlab!20120
parents 081ac7fc edb46f87
...@@ -84,7 +84,10 @@ export const fetchDashboard = ({ state, dispatch }, params) => { ...@@ -84,7 +84,10 @@ export const fetchDashboard = ({ state, dispatch }, params) => {
return backOffRequest(() => axios.get(state.dashboardEndpoint, { params })) return backOffRequest(() => axios.get(state.dashboardEndpoint, { params }))
.then(resp => resp.data) .then(resp => resp.data)
.then(response => { .then(response => {
dispatch('receiveMetricsDashboardSuccess', { response, params }); dispatch('receiveMetricsDashboardSuccess', {
response,
params,
});
}) })
.catch(error => { .catch(error => {
dispatch('receiveMetricsDashboardFailure', error); dispatch('receiveMetricsDashboardFailure', error);
......
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
state.emptyState = 'noData'; state.emptyState = 'noData';
}, },
[types.SET_ALL_DASHBOARDS](state, dashboards) { [types.SET_ALL_DASHBOARDS](state, dashboards) {
state.allDashboards = dashboards; state.allDashboards = dashboards || [];
}, },
[types.SET_SHOW_ERROR_BANNER](state, enabled) { [types.SET_SHOW_ERROR_BANNER](state, enabled) {
state.showErrorBanner = enabled; state.showErrorBanner = enabled;
......
---
title: Fix broken monitor cluster health dashboard
merge_request: 20120
author:
type: fixed
...@@ -122,6 +122,32 @@ describe('Dashboard', () => { ...@@ -122,6 +122,32 @@ describe('Dashboard', () => {
}); });
}); });
describe('cluster health', () => {
let wrapper;
beforeEach(done => {
wrapper = shallowMount(DashboardComponent, {
localVue,
sync: false,
propsData: { ...propsData, hasMetrics: true },
store,
});
// all_dashboards is not defined in health dashboards
wrapper.vm.$store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, undefined);
wrapper.vm.$nextTick(done);
});
afterEach(() => {
wrapper.destroy();
});
it('renders correctly', () => {
expect(wrapper.isVueInstance()).toBe(true);
expect(wrapper.exists()).toBe(true);
});
});
describe('requests information to the server', () => { describe('requests information to the server', () => {
let spy; let spy;
beforeEach(() => { beforeEach(() => {
......
...@@ -144,7 +144,19 @@ describe('Monitoring mutations', () => { ...@@ -144,7 +144,19 @@ describe('Monitoring mutations', () => {
}); });
describe('SET_ALL_DASHBOARDS', () => { describe('SET_ALL_DASHBOARDS', () => {
it('stores the dashboards loaded from the git repository', () => { it('stores `undefined` dashboards as an empty array', () => {
mutations[types.SET_ALL_DASHBOARDS](stateCopy, undefined);
expect(stateCopy.allDashboards).toEqual([]);
});
it('stores `null` dashboards as an empty array', () => {
mutations[types.SET_ALL_DASHBOARDS](stateCopy, null);
expect(stateCopy.allDashboards).toEqual([]);
});
it('stores dashboards loaded from the git repository', () => {
mutations[types.SET_ALL_DASHBOARDS](stateCopy, dashboardGitResponse); mutations[types.SET_ALL_DASHBOARDS](stateCopy, dashboardGitResponse);
expect(stateCopy.allDashboards).toEqual(dashboardGitResponse); expect(stateCopy.allDashboards).toEqual(dashboardGitResponse);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment