feat - Add filter for reports by agent, label and inboxes (#3084)

* Adds filter for agents, labels and inboxes

* Added Inboxes Reports Feature

* Fixed populating of filter dropdown issue

* If applied, fixes code climate style-lint warnings

* Fixes codeclimate warnings

* if applied, Refactors sidebar file to fix codclimate warnings

* if applied, fixes the download reports button for filtered report-data

* If applied, replaces native img tag with thumbnail component

* If applied, replaces hardcoded color string with variable

* If applied, adds a11y labels to multiselect dropdowns

* If applied, Renames reports methods to generic names

* If applied, Adds test cases for Labels and Inboxes

* If applied, write a test spec for fileDownload helper

* if applied, Moves fileDownload method to a utils folder

* If applied, Fixes the report file name type

* Test Spec for Reports Store module

* Fix specs - add restoreAllMocks

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Fayaz Ahmed
2021-09-30 13:13:45 +05:30
committed by GitHub
parent 57abdc4d5f
commit a1563917ba
21 changed files with 1215 additions and 283 deletions

View File

@@ -6,15 +6,15 @@ class ReportsAPI extends ApiClient {
super('reports', { accountScoped: true, apiVersion: 'v2' });
}
getAccountReports(metric, since, until) {
getReports(metric, since, until, type = 'account', id) {
return axios.get(`${this.url}`, {
params: { metric, since, until, type: 'account' },
params: { metric, since, until, type, id },
});
}
getAccountSummary(since, until) {
getSummary(since, until, type = 'account', id) {
return axios.get(`${this.url}/summary`, {
params: { since, until, type: 'account' },
params: { since, until, type, id },
});
}
@@ -23,6 +23,18 @@ class ReportsAPI extends ApiClient {
params: { since, until },
});
}
getLabelReports(since, until) {
return axios.get(`${this.url}/labels`, {
params: { since, until },
});
}
getInboxReports(since, until) {
return axios.get(`${this.url}/inboxes`, {
params: { since, until },
});
}
}
export default new ReportsAPI();

View File

@@ -11,39 +11,34 @@ describe('#Reports API', () => {
expect(reportsAPI).toHaveProperty('create');
expect(reportsAPI).toHaveProperty('update');
expect(reportsAPI).toHaveProperty('delete');
expect(reportsAPI).toHaveProperty('getAccountReports');
expect(reportsAPI).toHaveProperty('getAccountSummary');
expect(reportsAPI).toHaveProperty('getReports');
expect(reportsAPI).toHaveProperty('getSummary');
expect(reportsAPI).toHaveProperty('getAgentReports');
expect(reportsAPI).toHaveProperty('getLabelReports');
expect(reportsAPI).toHaveProperty('getInboxReports');
});
describeWithAPIMock('API calls', context => {
it('#getAccountReports', () => {
reportsAPI.getAccountReports(
'conversations_count',
1621103400,
1621621800
);
expect(context.axiosMock.get).toHaveBeenCalledWith(
'/api/v2/reports',
{
params: {
metric: 'conversations_count',
since: 1621103400,
until: 1621621800,
type: 'account'
},
}
);
reportsAPI.getReports('conversations_count', 1621103400, 1621621800);
expect(context.axiosMock.get).toHaveBeenCalledWith('/api/v2/reports', {
params: {
metric: 'conversations_count',
since: 1621103400,
until: 1621621800,
type: 'account',
},
});
});
it('#getAccountSummary', () => {
reportsAPI.getAccountSummary(1621103400, 1621621800);
reportsAPI.getSummary(1621103400, 1621621800);
expect(context.axiosMock.get).toHaveBeenCalledWith(
'/api/v2/reports/summary',
{
params: {
since: 1621103400,
until: 1621621800,
type: 'account'
type: 'account',
},
}
);
@@ -61,5 +56,31 @@ describe('#Reports API', () => {
}
);
});
it('#getLabelReports', () => {
reportsAPI.getLabelReports(1621103400, 1621621800);
expect(context.axiosMock.get).toHaveBeenCalledWith(
'/api/v2/reports/labels',
{
params: {
since: 1621103400,
until: 1621621800,
},
}
);
});
it('#getInboxReports', () => {
reportsAPI.getInboxReports(1621103400, 1621621800);
expect(context.axiosMock.get).toHaveBeenCalledWith(
'/api/v2/reports/inboxes',
{
params: {
since: 1621103400,
until: 1621621800,
},
}
);
});
});
});