feat: 支持配置证书文本模板和作者显示方式

This commit is contained in:
Nixevol
2026-09-20 09:54:03 +08:00
parent c5c0168e4c
commit 6669722c00
13 changed files with 202 additions and 21 deletions
@@ -16,7 +16,7 @@ function fixture(state = 'PENDING') {
updateMany: jest.fn().mockResolvedValue({ count: 1 }),
findUniqueOrThrow: jest.fn().mockResolvedValue(row),
},
traceCode: { findUnique: jest.fn().mockResolvedValue({ shortCode: '123456000001', status: 'ACTIVE', artwork: { status: 'ACTIVE', auditStatus: 'APPROVED' }, proofs: [row] }) },
traceCode: { findUnique: jest.fn().mockResolvedValue({ shortCode: '123456000001', status: 'ACTIVE', artwork: { title: '测试作品', archiveNo: 'ARTVERIS-000001', status: 'ACTIVE', auditStatus: 'APPROVED' }, proofs: [row] }) },
$transaction: jest.fn(),
};
const config = { getAllRaw: jest.fn().mockResolvedValue(settings), get: jest.fn().mockResolvedValue('true') };
@@ -105,15 +105,15 @@ describe('Consumer certificate lifecycle', () => {
expect(row.certificateRequest).toBe(saved);
expect(writes).toBe(1);
});
it('freezes only the artwork title and physical trace code, separated by a newline', async () => {
it('defaults to title and version using the template label rather than assuming a version key', async () => {
const { service, prisma, row } = fixture('NONE');
prisma.traceCode.findUnique.mockResolvedValue({
shortCode: '295708006702', status: 'ACTIVE',
artwork: { title: '风生水起莲花生肖青蛙手工茶器', status: 'ACTIVE', auditStatus: 'APPROVED' },
artwork: { title: '十二生肖莲花手工杯', status: 'ACTIVE', auditStatus: 'APPROVED', dynamicFields: { size: '一个装' }, template: { fields: [{ label: '版本', fieldKey: 'size' }] } },
proofs: [row],
} as any);
await service.request('295708006702');
expect(prisma.blockchainProof.updateMany.mock.calls[0][0].data.certificateRequest.text)
.toBe('风生水起莲花生肖青蛙手工茶器\n295708006702');
.toBe('十二生肖莲花手工杯 一个装');
});
});