feat: Add Reports for teams (#3116)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Fayaz Ahmed
2021-10-06 23:53:51 +05:30
committed by GitHub
parent 3e99088fe3
commit 1c6a539c0a
15 changed files with 240 additions and 59 deletions

View File

@@ -78,4 +78,25 @@ describe('#actions', () => {
expect(mockInboxDownloadElement.download).toEqual(param.fileName);
});
});
describe('#downloadTeamReports', () => {
it('open CSV download prompt if API is success', async () => {
axios.get.mockResolvedValue({
data: `Team name,Conversations count,Avg first response time (Minutes),Avg resolution time (Minutes)
sales team,0,0,0
Reporting period 2021-09-23 to 2021-09-29`,
});
const param = {
from: 1631039400,
to: 1635013800,
fileName: 'inbox-report-24-10-2021.csv',
};
const mockInboxDownloadElement = createElementSpy();
await actions.downloadInboxReports(1, param);
expect(mockInboxDownloadElement.href).toEqual(
'data:text/csv;charset=utf-8,Team%20name,Conversations%20count,Avg%20first%20response%20time%20(Minutes),Avg%20resolution%20time%20(Minutes)%0A%20%20%20%20%20%20%20%20sales%20team,0,0,0%0A%20%20%20%20%20%20%20%20Reporting%20period%202021-09-23%20to%202021-09-29'
);
expect(mockInboxDownloadElement.download).toEqual(param.fileName);
});
});
});