mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
feat: Adds bulk_invite api for onboarding view (#8931)
- New API for bulk email invite
This commit is contained in:
committed by
GitHub
parent
9c07b6dd46
commit
a902b49bc5
@@ -1,9 +1,17 @@
|
|||||||
|
/* global axios */
|
||||||
|
|
||||||
import ApiClient from './ApiClient';
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
class Agents extends ApiClient {
|
class Agents extends ApiClient {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('agents', { accountScoped: true });
|
super('agents', { accountScoped: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bulkInvite({ emails }) {
|
||||||
|
return axios.post(`${this.url}/bulk_create`, {
|
||||||
|
emails,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Agents();
|
export default new Agents();
|
||||||
|
|||||||
@@ -10,4 +10,29 @@ describe('#AgentAPI', () => {
|
|||||||
expect(agents).toHaveProperty('update');
|
expect(agents).toHaveProperty('update');
|
||||||
expect(agents).toHaveProperty('delete');
|
expect(agents).toHaveProperty('delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('API calls', () => {
|
||||||
|
const originalAxios = window.axios;
|
||||||
|
const axiosMock = {
|
||||||
|
post: jest.fn(() => Promise.resolve()),
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
window.axios = axiosMock;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
window.axios = originalAxios;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#bulkInvite', () => {
|
||||||
|
agents.bulkInvite({ emails: ['hello@hi.com'] });
|
||||||
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/agents/bulk_create',
|
||||||
|
{
|
||||||
|
emails: ['hello@hi.com'],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user