Commit dc847b6a authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '300701-changing-issues-confidentiality-errors-are-not-taken-into-account-on-frontend' into 'master'

Show graphql error on confidential mutation

See merge request gitlab-org/gitlab!53106
parents 7be9b335 db34cfc7
...@@ -739,9 +739,13 @@ export const updateConfidentialityOnIssuable = ( ...@@ -739,9 +739,13 @@ export const updateConfidentialityOnIssuable = (
}) })
.then(({ data }) => { .then(({ data }) => {
const { const {
issueSetConfidential: { issue }, issueSetConfidential: { issue, errors },
} = data; } = data;
setConfidentiality({ commit }, issue.confidential); if (errors?.length) {
Flash(errors[0], 'alert');
} else {
setConfidentiality({ commit }, issue.confidential);
}
}); });
}; };
...@@ -1312,6 +1312,7 @@ describe('Actions Notes Store', () => { ...@@ -1312,6 +1312,7 @@ describe('Actions Notes Store', () => {
return actions return actions
.updateConfidentialityOnIssuable({ commit: commitSpy, state, getters }, actionArgs) .updateConfidentialityOnIssuable({ commit: commitSpy, state, getters }, actionArgs)
.then(() => { .then(() => {
expect(Flash).not.toHaveBeenCalled();
expect(commitSpy).toHaveBeenCalledWith( expect(commitSpy).toHaveBeenCalledWith(
mutationTypes.SET_ISSUE_CONFIDENTIAL, mutationTypes.SET_ISSUE_CONFIDENTIAL,
confidential, confidential,
...@@ -1319,6 +1320,22 @@ describe('Actions Notes Store', () => { ...@@ -1319,6 +1320,22 @@ describe('Actions Notes Store', () => {
}); });
}); });
}); });
describe('on user recoverable error', () => {
it('sends the error to Flash', () => {
const error = 'error';
jest
.spyOn(utils.gqClient, 'mutate')
.mockResolvedValue({ data: { issueSetConfidential: { errors: [error] } } });
return actions
.updateConfidentialityOnIssuable({ commit: () => {}, state, getters }, actionArgs)
.then(() => {
expect(Flash).toHaveBeenCalledWith(error, 'alert');
});
});
});
}); });
describe.each` describe.each`
......
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