feat: add access number routing and admin list improvements
This commit is contained in:
@@ -92,6 +92,34 @@ describe('RiskReviewService', () => {
|
||||
expect(prisma.smsSendTask.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('batch rejects unique tasks with one required rejection reason', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.smsSendTask.findUnique.mockImplementation(({ where }: { where: { id: string } }) => Promise.resolve({
|
||||
id: where.id,
|
||||
status: 'pending_review',
|
||||
reviewReason: '命中风控',
|
||||
}));
|
||||
prisma.smsSendTask.update.mockImplementation(({ where, data }: { where: { id: string }; data: Record<string, unknown> }) => Promise.resolve({
|
||||
id: where.id,
|
||||
...data,
|
||||
riskHits: [],
|
||||
}));
|
||||
const service = new RiskReviewService(prisma as never);
|
||||
|
||||
await expect(service.rejectTasks({ ids: ['task-1', 'task-2', 'task-1'], reason: '批量人工拒绝' })).resolves.toEqual([
|
||||
expect.objectContaining({ id: 'task-1', status: 'rejected', rejectReason: '批量人工拒绝' }),
|
||||
expect.objectContaining({ id: 'task-2', status: 'rejected', rejectReason: '批量人工拒绝' }),
|
||||
]);
|
||||
expect(prisma.smsSendTask.update).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('requires task ids and a reason for batch rejection', async () => {
|
||||
const service = new RiskReviewService(createPrismaMock() as never);
|
||||
|
||||
await expect(service.rejectTasks({ ids: [], reason: '拒绝' })).rejects.toThrow('At least one SMS send task id is required');
|
||||
await expect(service.rejectTasks({ ids: ['task-1'], reason: ' ' })).rejects.toThrow('Batch rejection reason is required');
|
||||
});
|
||||
|
||||
it('rejects tasks over the application max phone threshold', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.smsApplication.findUnique.mockResolvedValue({ id: 'app-1', maxPhonesPerTask: 2 });
|
||||
|
||||
Reference in New Issue
Block a user