2021-05-25 08:30:21 +00:00
|
|
|
import reportsAPI from '../reports';
|
2020-05-11 06:10:14 +00:00
|
|
|
import ApiClient from '../ApiClient';
|
2021-05-25 08:30:21 +00:00
|
|
|
import describeWithAPIMock from './apiSpecHelper';
|
2020-05-11 06:10:14 +00:00
|
|
|
|
|
|
|
describe('#Reports API', () => {
|
|
|
|
it('creates correct instance', () => {
|
2021-05-25 08:30:21 +00:00
|
|
|
expect(reportsAPI).toBeInstanceOf(ApiClient);
|
|
|
|
expect(reportsAPI.apiVersion).toBe('/api/v2');
|
|
|
|
expect(reportsAPI).toHaveProperty('get');
|
|
|
|
expect(reportsAPI).toHaveProperty('show');
|
|
|
|
expect(reportsAPI).toHaveProperty('create');
|
|
|
|
expect(reportsAPI).toHaveProperty('update');
|
|
|
|
expect(reportsAPI).toHaveProperty('delete');
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
expect(reportsAPI).toHaveProperty('getReports');
|
|
|
|
expect(reportsAPI).toHaveProperty('getSummary');
|
2021-05-25 08:30:21 +00:00
|
|
|
expect(reportsAPI).toHaveProperty('getAgentReports');
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
expect(reportsAPI).toHaveProperty('getLabelReports');
|
|
|
|
expect(reportsAPI).toHaveProperty('getInboxReports');
|
2021-10-06 18:23:51 +00:00
|
|
|
expect(reportsAPI).toHaveProperty('getTeamReports');
|
2021-05-25 08:30:21 +00:00
|
|
|
});
|
|
|
|
describeWithAPIMock('API calls', context => {
|
|
|
|
it('#getAccountReports', () => {
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
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.getSummary(1621103400, 1621621800);
|
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
|
|
'/api/v2/reports/summary',
|
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1621103400,
|
|
|
|
until: 1621621800,
|
|
|
|
type: 'account',
|
|
|
|
},
|
|
|
|
}
|
2021-05-25 08:30:21 +00:00
|
|
|
);
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('#getAgentReports', () => {
|
|
|
|
reportsAPI.getAgentReports(1621103400, 1621621800);
|
2021-05-25 08:30:21 +00:00
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
'/api/v2/reports/agents',
|
2021-05-25 08:30:21 +00:00
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1621103400,
|
|
|
|
until: 1621621800,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
it('#getLabelReports', () => {
|
|
|
|
reportsAPI.getLabelReports(1621103400, 1621621800);
|
2021-05-25 08:30:21 +00:00
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
'/api/v2/reports/labels',
|
2021-05-25 08:30:21 +00:00
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1621103400,
|
|
|
|
until: 1621621800,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
it('#getInboxReports', () => {
|
|
|
|
reportsAPI.getInboxReports(1621103400, 1621621800);
|
2021-05-25 08:30:21 +00:00
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
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>
2021-09-30 07:43:45 +00:00
|
|
|
'/api/v2/reports/inboxes',
|
2021-05-25 08:30:21 +00:00
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1621103400,
|
|
|
|
until: 1621621800,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2021-10-06 18:23:51 +00:00
|
|
|
|
|
|
|
it('#getTeamReports', () => {
|
|
|
|
reportsAPI.getTeamReports(1621103400, 1621621800);
|
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
|
|
'/api/v2/reports/teams',
|
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1621103400,
|
|
|
|
until: 1621621800,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2020-05-11 06:10:14 +00:00
|
|
|
});
|
|
|
|
});
|