mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
* feat: add heatmap component * feat: add heatmap component * feat: add dummy heatmap * refactor: compact tiles * feat: allow hour * feat: wire up heatmap query * feat: allow arbritrary number of weeks * feat: update position of the widget * chore: update heatmap title * refactor: move traffic heatmap to overview * chore: add comment for perf * feat: add reconcile logic for heatmap fetching Fetching the data for the last 6 days all the time is wasteful So we fetch only the data for today and reconcile it with the data we already have * refactor: re-org code for new utils * feat: add translations * feat: translate days of the week * chore: update chatwoot utils * feat: add markers to heatmap * refactor: update class names * refactor: move flatten as a separate method * test: Heatmap Helpers * chore: add comments * refactor: method naming * refactor: use heatmap-level mixin * refactor: cleanup css * chore: remove log * refactor: reports.js to use object instead of separate params * refactor: report store to use new API design * refactor: rename HeatmapHelper -> ReportsDataHelper * refactor: separate clampDataBetweenTimeline * feat: add tests * fix: group by hour * feat: add scroll for smaller screens * refactor: add base data to reconcile with * fix: tests * fix: overflow only on smaller screens * feat: translate tooltip * refactor: simplify reconcile * chore: add docs * chore: remoev heatmap from account report * feat: let Heatmap handle loading state * chore: Apply suggestions from code review Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> * feat: update css * refactor: color assignment to range * feat: add short circuit * Update app/javascript/dashboard/routes/dashboard/settings/reports/components/Heatmap.vue --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
124 lines
3.4 KiB
JavaScript
124 lines
3.4 KiB
JavaScript
import reportsAPI from '../reports';
|
|
import ApiClient from '../ApiClient';
|
|
import describeWithAPIMock from './apiSpecHelper';
|
|
|
|
describe('#Reports API', () => {
|
|
it('creates correct instance', () => {
|
|
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');
|
|
expect(reportsAPI).toHaveProperty('getReports');
|
|
expect(reportsAPI).toHaveProperty('getSummary');
|
|
expect(reportsAPI).toHaveProperty('getAgentReports');
|
|
expect(reportsAPI).toHaveProperty('getLabelReports');
|
|
expect(reportsAPI).toHaveProperty('getInboxReports');
|
|
expect(reportsAPI).toHaveProperty('getTeamReports');
|
|
});
|
|
describeWithAPIMock('API calls', context => {
|
|
it('#getAccountReports', () => {
|
|
reportsAPI.getReports({
|
|
metric: 'conversations_count',
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
});
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith('/api/v2/reports', {
|
|
params: {
|
|
metric: 'conversations_count',
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
type: 'account',
|
|
timezone_offset: -0,
|
|
},
|
|
});
|
|
});
|
|
|
|
it('#getAccountSummary', () => {
|
|
reportsAPI.getSummary(1621103400, 1621621800);
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/summary',
|
|
{
|
|
params: {
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
type: 'account',
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#getAgentReports', () => {
|
|
reportsAPI.getAgentReports({
|
|
from: 1621103400,
|
|
to: 1621621800,
|
|
businessHours: true,
|
|
});
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/agents',
|
|
{
|
|
params: {
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
business_hours: true,
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#getLabelReports', () => {
|
|
reportsAPI.getLabelReports({ from: 1621103400, to: 1621621800 });
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/labels',
|
|
{
|
|
params: {
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#getInboxReports', () => {
|
|
reportsAPI.getInboxReports({ from: 1621103400, to: 1621621800 });
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/inboxes',
|
|
{
|
|
params: {
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#getTeamReports', () => {
|
|
reportsAPI.getTeamReports({ from: 1621103400, to: 1621621800 });
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/teams',
|
|
{
|
|
params: {
|
|
since: 1621103400,
|
|
until: 1621621800,
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#getConversationMetric', () => {
|
|
reportsAPI.getConversationMetric('account');
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v2/reports/conversations',
|
|
{
|
|
params: {
|
|
type: 'account',
|
|
page: 1,
|
|
},
|
|
}
|
|
);
|
|
});
|
|
});
|
|
});
|