Commit 1a8c124f authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '223159-fix-dahsboard-warning-logic' into 'master'

Fix dashboard validation warning logic

Closes #223159

See merge request gitlab-org/gitlab!36577
parents 30b49932 23d555a5
...@@ -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