Commit 23d555a5 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska Committed by Nicolò Maria Mezzopera

Fix dashboard validation warning logic

parent 1eee0c41
...@@ -375,7 +375,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch }) => { ...@@ -375,7 +375,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch }) => {
}) })
.then(resp => resp.data?.project?.environments?.nodes?.[0]?.metricsDashboard) .then(resp => resp.data?.project?.environments?.nodes?.[0]?.metricsDashboard)
.then(({ schemaValidationWarnings } = {}) => { .then(({ schemaValidationWarnings } = {}) => {
const hasWarnings = schemaValidationWarnings?.length !== 0; const hasWarnings = schemaValidationWarnings && schemaValidationWarnings.length !== 0;
/** /**
* The payload of the dispatch is a boolean, because at the moment a standard * The payload of the dispatch is a boolean, because at the moment a standard
* warning message is shown instead of the warnings the BE returns * warning message is shown instead of the warnings the BE returns
......
---
title: Fix dashboard schema validation issue
merge_request: 36577
author:
type: fixed
...@@ -948,6 +948,25 @@ describe('Monitoring store actions', () => { ...@@ -948,6 +948,25 @@ describe('Monitoring store actions', () => {
); );
}); });
it('dispatches receiveDashboardValidationWarningsSuccess with false payload when the response is empty ', () => {
mockMutate.mockResolvedValue({
data: {
project: null,
},
});
return testAction(
fetchDashboardValidationWarnings,
null,
state,
[],
[{ type: 'receiveDashboardValidationWarningsSuccess', payload: false }],
() => {
expect(mockMutate).toHaveBeenCalledWith(mutationVariables);
},
);
});
it('dispatches receiveDashboardValidationWarningsFailure if the warnings API call fails', () => { it('dispatches receiveDashboardValidationWarningsFailure if the warnings API call fails', () => {
mockMutate.mockRejectedValue({}); mockMutate.mockRejectedValue({});
......
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