feat: strengthen risk controls and review workflows
This commit is contained in:
@@ -17,6 +17,9 @@ function createPrismaMock() {
|
||||
create: jest.fn().mockResolvedValue(tenant),
|
||||
update: jest.fn().mockResolvedValue(tenant),
|
||||
},
|
||||
smsApplication: {
|
||||
count: jest.fn().mockResolvedValue(0),
|
||||
},
|
||||
enterpriseCertification: {
|
||||
findFirst: jest.fn().mockResolvedValue(null),
|
||||
create: jest.fn().mockResolvedValue({ id: 'cert-1' }),
|
||||
@@ -81,6 +84,18 @@ describe('TenantsService', () => {
|
||||
expect(prisma.tenant.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('blocks enterprise deletion while applications are active or disabling', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.smsApplication.count.mockResolvedValue(2);
|
||||
const service = new TenantsService(prisma as never);
|
||||
|
||||
await expect(service.delete('tenant-1')).rejects.toThrow('还有 2 个启用或停用中的企业应用');
|
||||
expect(prisma.tenant.update).not.toHaveBeenCalled();
|
||||
expect(prisma.smsApplication.count).toHaveBeenCalledWith({
|
||||
where: { tenantId: 'tenant-1', status: { in: ['active', 'disabling'] } },
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects enterprise credit codes containing non-alphanumeric characters', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new TenantsService(prisma as never);
|
||||
|
||||
Reference in New Issue
Block a user