feat: refine report material workflow states
This commit is contained in:
@@ -1106,6 +1106,44 @@ describe('SmsConfigService', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('keeps an operator-edited signature approved and records the operator audit', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.smsSignature.findUnique.mockResolvedValue({
|
||||
id: 'sig-1', tenantId: 'tenant-1', applicationId: 'app-1', name: '【旧签名】',
|
||||
purpose: '通知', drainageInfo: {}, auditStatus: 'approved',
|
||||
});
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
const result = await service.updateSignature(
|
||||
'sig-1',
|
||||
{ name: '【新签名】' },
|
||||
undefined,
|
||||
{ initialAuditStatus: 'approved', reviewerId: 'operator-1' },
|
||||
);
|
||||
|
||||
expect(prisma.smsSignature.update).toHaveBeenCalledWith(expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
auditStatus: 'approved',
|
||||
rejectReason: null,
|
||||
materialVersion: { increment: 1 },
|
||||
pendingReport: true,
|
||||
}),
|
||||
}));
|
||||
expect(prisma.auditRecord.create).toHaveBeenCalledWith({
|
||||
data: expect.objectContaining({
|
||||
action: 'admin_update_approved',
|
||||
reviewerId: 'operator-1',
|
||||
statusBefore: 'approved',
|
||||
statusAfter: 'approved',
|
||||
}),
|
||||
});
|
||||
expect(result).toEqual(expect.objectContaining({
|
||||
auditStatus: 'approved',
|
||||
reportMaterialChanged: true,
|
||||
reportPoolAvailableAfter: 'immediate',
|
||||
}));
|
||||
});
|
||||
|
||||
it('resets an approved template to pending when key content is changed', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.smsTemplate.findUnique.mockResolvedValue({
|
||||
@@ -1223,6 +1261,7 @@ describe('SmsConfigService', () => {
|
||||
const result = await service.listSignaturesPage({ page: 1, pageSize: 10 });
|
||||
|
||||
expect(result.total).toBe(1);
|
||||
expect(result.pendingReportMaterialTotal).toBe(0);
|
||||
expect(result.pendingReportDetailTotal).toBe(0);
|
||||
expect(result.items[0]).toEqual(expect.objectContaining({ id: 'sig-1', name: '【签名A】' }));
|
||||
expect(result.items[0]).not.toHaveProperty('materials');
|
||||
@@ -1280,6 +1319,7 @@ describe('SmsConfigService', () => {
|
||||
|
||||
const result = await service.listSignaturesPage({ signatureKeyword: '测试', page: 1, pageSize: 10 });
|
||||
|
||||
expect(result.pendingReportMaterialTotal).toBe(1);
|
||||
expect(result.pendingReportDetailTotal).toBe(expectedTotal);
|
||||
expect(prisma.smsSignature.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user