feat: optimize routing and operations views
This commit is contained in:
@@ -189,7 +189,7 @@ describe('OperationsService', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('filters send-chain messages by tenant, application, channel, content, date, task, phone, and status', async () => {
|
||||
it('filters send-chain messages by tenant, application, channel, carrier, content, date, task, phone, and status', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new OperationsService(prisma as never);
|
||||
|
||||
@@ -202,6 +202,7 @@ describe('OperationsService', () => {
|
||||
messageId: 'MSG-1',
|
||||
phoneNumber: '13800000001',
|
||||
contentKeyword: '验证码',
|
||||
carrier: 'mobile',
|
||||
queuedAtFrom: '2026-07-01',
|
||||
queuedAtTo: '2026-07-02',
|
||||
status: 'delivered',
|
||||
@@ -215,6 +216,7 @@ describe('OperationsService', () => {
|
||||
batchTaskId: 'task-1',
|
||||
messageId: 'MSG-1',
|
||||
phoneNumber: '13800000001',
|
||||
carrier: { in: ['mobile', 'cmcc', '移动', '中国移动'] },
|
||||
status: 'delivered',
|
||||
content: { contains: '验证码', mode: 'insensitive' },
|
||||
channel: { name: { contains: '移动通道', mode: 'insensitive' } },
|
||||
@@ -238,6 +240,34 @@ describe('OperationsService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('treats null and nonstandard carrier values as unrecognized', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new OperationsService(prisma as never);
|
||||
|
||||
await service.listMessages({ carrier: 'unknown' });
|
||||
|
||||
expect(prisma.smsMessageRecord.findMany).toHaveBeenCalledWith(expect.objectContaining({
|
||||
where: expect.objectContaining({
|
||||
AND: [
|
||||
{
|
||||
OR: [
|
||||
{ carrier: null },
|
||||
{
|
||||
carrier: {
|
||||
notIn: [
|
||||
'mobile', 'cmcc', '移动', '中国移动',
|
||||
'unicom', 'cucc', '联通', '中国联通',
|
||||
'telecom', 'ctcc', '电信', '中国电信',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('separates upstream submit failures from post-acceptance delivery failures', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new OperationsService(prisma as never);
|
||||
@@ -369,7 +399,13 @@ describe('OperationsService', () => {
|
||||
todaySpendCents: 24000n,
|
||||
balanceCents: 1000000n,
|
||||
creditCents: 50000n,
|
||||
}]);
|
||||
}]).mockResolvedValueOnce([
|
||||
{ hour: 9, submittedCount: 12n, successCount: 10n },
|
||||
{ hour: 10, submittedCount: 5n, successCount: 4n },
|
||||
]).mockResolvedValueOnce([
|
||||
{ category: 'templates', count: 3n, averageProcessingMs: 90_000n },
|
||||
{ category: 'signatures', count: 2n, averageProcessingMs: 120_000n },
|
||||
]);
|
||||
prisma.cmppDownstreamDelivery.count = jest.fn()
|
||||
.mockResolvedValueOnce(3)
|
||||
.mockResolvedValueOnce(2)
|
||||
@@ -394,6 +430,17 @@ describe('OperationsService', () => {
|
||||
total: 5,
|
||||
},
|
||||
today: expect.objectContaining({ returnedCents: 10 }),
|
||||
hourlySendTrend: expect.arrayContaining([
|
||||
{ hour: 9, label: '09:00', submittedCount: 12, successCount: 10 },
|
||||
{ hour: 10, label: '10:00', submittedCount: 5, successCount: 4 },
|
||||
]),
|
||||
auditProcessingSpeed: [
|
||||
{ category: 'enterpriseCertifications', label: '企业认证', count: 0, averageProcessingMs: null },
|
||||
{ category: 'smsAudits', label: '短信审核', count: 0, averageProcessingMs: null },
|
||||
{ category: 'templates', label: '模板', count: 3, averageProcessingMs: 90000 },
|
||||
{ category: 'signatures', label: '签名', count: 2, averageProcessingMs: 120000 },
|
||||
{ category: 'drainageInfos', label: '引流信息', count: 0, averageProcessingMs: null },
|
||||
],
|
||||
enterpriseSpendRanks: [{
|
||||
tenantId: 'tenant-1',
|
||||
tenantName: '租户A',
|
||||
|
||||
Reference in New Issue
Block a user