Bug: Fix error message when existing agent email is reused for a new agent (#538)
Co-authored-by: Pranav Raj S <pranavrajs@gmail.com>
This commit is contained in:
parent
6340eb3ae2
commit
67f4f69e8a
4 changed files with 10 additions and 3 deletions
|
@ -45,6 +45,7 @@
|
||||||
},
|
},
|
||||||
"API": {
|
"API": {
|
||||||
"SUCCESS_MESSAGE": "Agent added successfully",
|
"SUCCESS_MESSAGE": "Agent added successfully",
|
||||||
|
"EXIST_MESSAGE": "Agent email already in use, Please try another email address",
|
||||||
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -128,7 +128,11 @@ export default {
|
||||||
this.showAlert(this.$t('AGENT_MGMT.ADD.API.SUCCESS_MESSAGE'));
|
this.showAlert(this.$t('AGENT_MGMT.ADD.API.SUCCESS_MESSAGE'));
|
||||||
this.onClose();
|
this.onClose();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showAlert(this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE'));
|
if (error.response.status === 422) {
|
||||||
|
this.showAlert(this.$t('AGENT_MGMT.ADD.API.EXIST_MESSAGE'));
|
||||||
|
} else {
|
||||||
|
this.showAlert(this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,7 +43,7 @@ export const actions = {
|
||||||
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
||||||
throw new Error(error);
|
throw error;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: async ({ commit }, { id, ...agentParams }) => {
|
update: async ({ commit }, { id, ...agentParams }) => {
|
||||||
|
|
|
@ -40,7 +40,9 @@ describe('#actions', () => {
|
||||||
});
|
});
|
||||||
it('sends correct actions if API is error', async () => {
|
it('sends correct actions if API is error', async () => {
|
||||||
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
||||||
await expect(actions.create({ commit })).rejects.toThrow(Error);
|
await expect(actions.create({ commit })).rejects.toEqual({
|
||||||
|
message: 'Incorrect header',
|
||||||
|
});
|
||||||
expect(commit.mock.calls).toEqual([
|
expect(commit.mock.calls).toEqual([
|
||||||
[types.default.SET_AGENT_CREATING_STATUS, true],
|
[types.default.SET_AGENT_CREATING_STATUS, true],
|
||||||
[types.default.SET_AGENT_CREATING_STATUS, false],
|
[types.default.SET_AGENT_CREATING_STATUS, false],
|
||||||
|
|
Loading…
Reference in a new issue