feat: add phone frequency controls and modularize codebase
This commit is contained in:
@@ -6,6 +6,9 @@ function createPrismaMock() {
|
||||
user: {
|
||||
findFirst: jest.fn().mockResolvedValue({ tenantId: 'tenant-1' }),
|
||||
},
|
||||
tenant: {
|
||||
findUnique: jest.fn().mockResolvedValue({ id: 'tenant-1', name: '企业A' }),
|
||||
},
|
||||
smsBatchTask: {
|
||||
findMany: jest.fn().mockResolvedValue([{ id: 'task-1', taskNo: 'BATCH-1' }]),
|
||||
count: jest.fn().mockResolvedValue(3),
|
||||
@@ -50,6 +53,7 @@ function createPrismaMock() {
|
||||
},
|
||||
enterpriseCertification: {
|
||||
count: jest.fn().mockResolvedValue(1),
|
||||
findFirst: jest.fn().mockResolvedValue({ id: 'certification-1' }),
|
||||
},
|
||||
smsApplication: {
|
||||
findMany: jest.fn().mockResolvedValue([
|
||||
@@ -388,6 +392,22 @@ describe('OperationsService', () => {
|
||||
|
||||
expect(dashboard.gatewayConnections).toEqual([]);
|
||||
expect(dashboard.recentTasks).toEqual([expect.objectContaining({ id: 'task-1', taskNo: 'BATCH-1' })]);
|
||||
expect(dashboard.clientOverview).toEqual({
|
||||
enterpriseName: '企业A',
|
||||
certificationStatus: 'certified',
|
||||
signatureCount: 1,
|
||||
pendingBatchTaskCount: 3,
|
||||
});
|
||||
expect(prisma.smsBatchTask.count).toHaveBeenCalledWith({
|
||||
where: { tenantId: 'tenant-1', sourceType: 'client', status: 'pending_review' },
|
||||
});
|
||||
expect(prisma.enterpriseCertification.findFirst).toHaveBeenCalledWith({
|
||||
where: { tenantId: 'tenant-1', status: 'approved' },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(prisma.smsSignature.count).toHaveBeenCalledWith({
|
||||
where: { tenantId: 'tenant-1', auditStatus: { notIn: ['deleted', 'disabled'] } },
|
||||
});
|
||||
expect(JSON.stringify(dashboard)).not.toMatch(/passwordCipher|supplier|cipher|unitPrice/);
|
||||
});
|
||||
|
||||
@@ -480,6 +500,10 @@ describe('OperationsService', () => {
|
||||
updatedAt: { gte: expect.any(Date) },
|
||||
},
|
||||
});
|
||||
const hourlyTrendQuery = prisma.$queryRaw.mock.calls[1]?.[0] as { sql?: string };
|
||||
expect(hourlyTrendQuery.sql).toContain(
|
||||
`HOUR FROM (message."queuedAt" AT TIME ZONE 'UTC') AT TIME ZONE 'Asia/Shanghai'`,
|
||||
);
|
||||
expect(prisma.accountTransaction.aggregate).toHaveBeenCalledWith({
|
||||
where: {
|
||||
tenantId: 'tenant-1',
|
||||
|
||||
Reference in New Issue
Block a user