feat: optimize routing and operations views

This commit is contained in:
hectorzhao
2026-07-29 22:32:28 +08:00
parent 500f43f673
commit c0a4317a7e
21 changed files with 718 additions and 86 deletions
+21 -1
View File
@@ -143,7 +143,7 @@ function createPrismaMock() {
findMany: jest.fn().mockResolvedValue([{ carrier: 'mobile', pattern: '^13[4-9]', priority: 1, status: 'active' }]),
},
phoneSegment: {
findUnique: jest.fn().mockResolvedValue({ prefix: '1380000', province: '山东', city: '济南' }),
findMany: jest.fn().mockResolvedValue([{ prefix: '1380000', province: '山东', city: '济南' }]),
},
smsChannel: {
findFirst: jest.fn().mockResolvedValue(channel),
@@ -1873,6 +1873,26 @@ describe('SendChainService', () => {
});
});
it('reuses persisted carrier and province without querying routing dictionaries again', async () => {
const { service, prisma } = createService();
service['identifyCarrier'] = jest.fn();
service['identifyProvince'] = jest.fn();
await expect(service['selectChannelForMessage']({
id: 'record-1',
tenantId: 'tenant-1',
applicationId: 'app-1',
signatureId: 'sig-1',
phoneNumber: '13800000001',
carrier: 'mobile',
province: '山东',
})).resolves.toEqual(expect.objectContaining({ carrier: 'mobile', province: '山东' }));
expect(service['identifyCarrier']).not.toHaveBeenCalled();
expect(service['identifyProvince']).not.toHaveBeenCalled();
expect(prisma.smsMessageRecord.update).not.toHaveBeenCalled();
});
it('updates submit result status, charges billing, and task progress', async () => {
const { service, prisma, billing } = createService();