Commit db34cfc7 authored by Donald Cook's avatar Donald Cook

Show graphql error on confidential mutation

Should have length 0

Added a test
parent 2a62b9da
......@@ -727,9 +727,13 @@ export const updateConfidentialityOnIssuable = (
})
.then(({ data }) => {
const {
issueSetConfidential: { issue },
issueSetConfidential: { issue, errors },
} = data;
setConfidentiality({ commit }, issue.confidential);
if (errors?.length) {
Flash(errors[0], 'alert');
} else {
setConfidentiality({ commit }, issue.confidential);
}
});
};
......@@ -1276,6 +1276,7 @@ describe('Actions Notes Store', () => {
return actions
.updateConfidentialityOnIssuable({ commit: commitSpy, state, getters }, actionArgs)
.then(() => {
expect(Flash).not.toHaveBeenCalled();
expect(commitSpy).toHaveBeenCalledWith(
mutationTypes.SET_ISSUE_CONFIDENTIAL,
confidential,
......@@ -1283,6 +1284,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`
......
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