fix: decouple channel test sms records

This commit is contained in:
hectorzhao
2026-07-09 12:23:43 +08:00
parent c58a010951
commit e0579857c6
13 changed files with 190 additions and 135 deletions
+19 -1
View File
@@ -556,7 +556,24 @@ describe('SendChainService', () => {
it('updates admin channel test message status without business retry routing', async () => {
const { service, prisma, billing } = createService();
prisma.smsBatchTask.findUnique.mockResolvedValue({ id: 'task-1', tenantId: 'tenant-1', sourceType: 'admin_channel_test' });
prisma.smsMessageRecord.findFirst.mockResolvedValueOnce({
id: 'record-1',
tenantId: null,
batchTaskId: null,
applicationId: null,
templateId: null,
messageId: 'MSG-1',
phoneNumber: '13800000001',
content: 'hello',
billingUnits: 1,
unitPrice: 0,
amountCents: 0,
status: 'submit_queued',
queuePriority: 'normal',
submitId: 'SUB-1',
gatewayMessageId: null,
channelId: 'channel-1',
});
await service.handleSubmitResult({
messageId: 'MSG-1',
@@ -572,6 +589,7 @@ describe('SendChainService', () => {
expect(prisma.channelRouteRule.findFirst).not.toHaveBeenCalled();
expect(billing.release).not.toHaveBeenCalled();
expect(prisma.smsBatchTask.update).not.toHaveBeenCalled();
expect(prisma.smsMessageRecord.update).toHaveBeenCalledWith({
where: { id: 'record-1' },
data: expect.objectContaining({