Skip to content

Commit

Permalink
Bug: Fix error message when existing agent email is reused for a new …
Browse files Browse the repository at this point in the history
…agent (chatwoot#538)

Co-authored-by: Pranav Raj S <[email protected]>
  • Loading branch information
ghosteathuman and pranavrajs authored Feb 22, 2020
1 parent 6340eb3 commit 67f4f69
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/javascript/dashboard/i18n/locale/en/agentMgmt.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
},
"API": {
"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"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export default {
this.showAlert(this.$t('AGENT_MGMT.ADD.API.SUCCESS_MESSAGE'));
this.onClose();
} 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'));
}
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/dashboard/store/modules/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const actions = {
commit(types.default.SET_AGENT_CREATING_STATUS, false);
} catch (error) {
commit(types.default.SET_AGENT_CREATING_STATUS, false);
throw new Error(error);
throw error;
}
},
update: async ({ commit }, { id, ...agentParams }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ describe('#actions', () => {
});
it('sends correct actions if API is error', async () => {
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([
[types.default.SET_AGENT_CREATING_STATUS, true],
[types.default.SET_AGENT_CREATING_STATUS, false],
Expand Down

0 comments on commit 67f4f69

Please sign in to comment.