Commit 176af357 authored by Dhiraj Bodicherla's avatar Dhiraj Bodicherla

Fix failing dashboard schema validation calls

Custom dashboard schema validation API hits
the BE with dashboard filename instead of the
file path. This MR fixes it
parent c7ae1e23
...@@ -360,14 +360,14 @@ export const receiveAnnotationsSuccess = ({ commit }, data) => ...@@ -360,14 +360,14 @@ export const receiveAnnotationsSuccess = ({ commit }, data) =>
commit(types.RECEIVE_ANNOTATIONS_SUCCESS, data); commit(types.RECEIVE_ANNOTATIONS_SUCCESS, data);
export const receiveAnnotationsFailure = ({ commit }) => commit(types.RECEIVE_ANNOTATIONS_FAILURE); export const receiveAnnotationsFailure = ({ commit }) => commit(types.RECEIVE_ANNOTATIONS_FAILURE);
export const fetchDashboardValidationWarnings = ({ state, dispatch }) => { export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) => {
/** /**
* Normally, the default dashboard won't throw any validation warnings. * Normally, the default dashboard won't throw any validation warnings.
* *
* However, if a bug sneaks into the default dashboard making it invalid, * However, if a bug sneaks into the default dashboard making it invalid,
* this might come handy for our clients * this might come handy for our clients
*/ */
const dashboardPath = state.currentDashboard || DEFAULT_DASHBOARD_PATH; const dashboardPath = getters.fullDashboardPath || DEFAULT_DASHBOARD_PATH;
return gqClient return gqClient
.mutate({ .mutate({
mutation: getDashboardValidationWarnings, mutation: getDashboardValidationWarnings,
......
---
title: Fix failing dashboard schema validation calls
merge_request: 37108
author:
type: fixed
...@@ -872,6 +872,11 @@ describe('Monitoring store actions', () => { ...@@ -872,6 +872,11 @@ describe('Monitoring store actions', () => {
state.projectPath = 'gitlab-org/gitlab-test'; state.projectPath = 'gitlab-org/gitlab-test';
state.currentEnvironmentName = 'production'; state.currentEnvironmentName = 'production';
state.currentDashboard = '.gitlab/dashboards/dashboard_with_warnings.yml'; state.currentDashboard = '.gitlab/dashboards/dashboard_with_warnings.yml';
// testAction doesn't have access to getters. The state is passed in as getters
// instead of the actual getters inside the testAction method implementation.
// All methods downstream that needs access to getters will throw and error.
// For that reason, the result of the getter is set as a state variable.
state.fullDashboardPath = store.getters['monitoringDashboard/fullDashboardPath'];
mockMutate = jest.spyOn(gqClient, 'mutate'); mockMutate = jest.spyOn(gqClient, 'mutate');
mutationVariables = { mutationVariables = {
...@@ -879,7 +884,7 @@ describe('Monitoring store actions', () => { ...@@ -879,7 +884,7 @@ describe('Monitoring store actions', () => {
variables: { variables: {
projectPath: state.projectPath, projectPath: state.projectPath,
environmentName: state.currentEnvironmentName, environmentName: state.currentEnvironmentName,
dashboardPath: state.currentDashboard, dashboardPath: state.fullDashboardPath,
}, },
}; };
}); });
......
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