Commit 00941bb9 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '353350-display-mutation-errors-cadence-form' into 'master'

Display mutation errors on iteration cadence form

See merge request gitlab-org/gitlab!82641
parents 32445387 2a8cff87
......@@ -279,17 +279,11 @@ export default {
mutation: this.mutation,
variables: this.variables,
})
.then(({ data, errors: topLevelErrors = [] } = {}) => {
if (topLevelErrors.length > 0) {
this.errorMessage = topLevelErrors[0].message;
return null;
}
.then(({ data } = {}) => {
const { iterationCadence, errors } = data?.result || {};
if (errors?.length > 0) {
[this.errorMessage] = errors;
return null;
throw new Error(errors);
}
return getIdFromGraphQLId(iterationCadence.id);
......
......@@ -172,6 +172,24 @@ describe('Iteration cadence form', () => {
});
});
it('displays mutation errors on failure', async () => {
mutationMock = jest.fn().mockResolvedValue(createMutationFailure);
createComponent({ mutationMock });
setTitle(title);
setStartDate(startDate);
setDuration(durationInWeeks);
setRollOver(rollOver);
setFutureIterations(iterationsInAdvance);
clickSave();
await waitForPromises();
expect(findError().exists()).toBe(true);
expect(findError().text()).toContain('alas, your data is unchanged');
});
it('redirects to Iteration page on success', async () => {
setTitle(title);
setStartDate(startDate);
......
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