feat: add signature quality period trends
This commit is contained in:
@@ -677,6 +677,7 @@ describe('OperationsService', () => {
|
||||
averageArrivalMs: 1200,
|
||||
rowCount: 12,
|
||||
}])
|
||||
.mockResolvedValueOnce([{ count: 4 }])
|
||||
.mockResolvedValueOnce([
|
||||
{
|
||||
signatureId: 'signature-1',
|
||||
@@ -727,6 +728,18 @@ describe('OperationsService', () => {
|
||||
averageArrivalMs: 1800,
|
||||
},
|
||||
]);
|
||||
prisma.$queryRaw.mockResolvedValueOnce([
|
||||
{
|
||||
signatureId: 'signature-1',
|
||||
channelId: 'channel-1',
|
||||
channelName: '通道一',
|
||||
carrier: 'mobile',
|
||||
date: '2026-07-24',
|
||||
businessMessageCount: 3,
|
||||
deliveredMessageCount: 2,
|
||||
deliveryRate: 66.7,
|
||||
},
|
||||
]);
|
||||
const service = new OperationsService(prisma as never);
|
||||
|
||||
await expect(service.signatureQuality({
|
||||
@@ -736,6 +749,7 @@ describe('OperationsService', () => {
|
||||
pageSize: 5,
|
||||
})).resolves.toEqual({
|
||||
date: '2026-07-24',
|
||||
selectedDaySignatureCount: 4,
|
||||
items: [expect.objectContaining({
|
||||
signatureId: 'signature-1',
|
||||
signatureName: '【测试签名】',
|
||||
@@ -763,27 +777,31 @@ describe('OperationsService', () => {
|
||||
expect.objectContaining({ channelId: 'channel-1', carrier: 'mobile', drainageState: 'with', total: 4 }),
|
||||
expect.objectContaining({ channelId: 'channel-2', carrier: 'telecom', drainageState: 'without', total: 2 }),
|
||||
],
|
||||
dailyBreakdowns: [
|
||||
expect.objectContaining({ channelId: 'channel-1', carrier: 'mobile', date: '2026-07-24', businessMessageCount: 3 }),
|
||||
],
|
||||
})],
|
||||
total: 12,
|
||||
page: 2,
|
||||
pageSize: 5,
|
||||
});
|
||||
expect(prisma.$queryRaw).toHaveBeenCalledTimes(3);
|
||||
expect(prisma.$queryRaw).toHaveBeenCalledTimes(5);
|
||||
});
|
||||
|
||||
it('does not query channel details when the selected date has no registered signatures', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.$queryRaw.mockResolvedValueOnce([]);
|
||||
prisma.$queryRaw.mockResolvedValueOnce([]).mockResolvedValueOnce([{ count: 0 }]);
|
||||
const service = new OperationsService(prisma as never);
|
||||
|
||||
await expect(service.signatureQuality({ date: '2026-07-24' })).resolves.toEqual({
|
||||
date: '2026-07-24',
|
||||
selectedDaySignatureCount: 0,
|
||||
items: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
expect(prisma.$queryRaw).toHaveBeenCalledTimes(1);
|
||||
expect(prisma.$queryRaw).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('returns trace details and reconciliation diffs', async () => {
|
||||
|
||||
Reference in New Issue
Block a user