optimize ui loading and dashboard performance
This commit is contained in:
@@ -4,6 +4,22 @@ import { buildTrendBuckets, callMetrics, DashboardService, startOfShanghaiDayUtc
|
||||
import type { DashboardRepository } from './dashboard.repository.js';
|
||||
|
||||
describe('dashboard service', () => {
|
||||
it('loads summary and trends together for the overview response', async () => {
|
||||
const repository = {
|
||||
summaryWindow: async () => ({
|
||||
cdrs: [], ratedCdrs: [], failureCodes: [], abnormalGateways: [],
|
||||
activeCustomers: 0, activeCustomerGateways: 0, activeVendorGateways: 0, pendingQuality: 0
|
||||
}),
|
||||
trendWindow: async () => ({ cdrs: [], ratedCdrs: [] })
|
||||
} as unknown as DashboardRepository;
|
||||
const service = new DashboardService(repository);
|
||||
|
||||
const result = await service.overview({ hours: 1, bucketMinutes: 60 });
|
||||
|
||||
expect(result.summary).toHaveProperty('calls.totalCalls', 0);
|
||||
expect(result.trends.buckets).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('uses Asia/Shanghai day boundary for today summary', async () => {
|
||||
const calls: Array<{ start: Date; end: Date }> = [];
|
||||
const repository = {
|
||||
|
||||
Reference in New Issue
Block a user